客户机代码将轮询输出队列以获得响应,或等待响应消息交付时的回调通知。
The client code would either poll the output queue for the response or wait for some kind of call-back notification when the response message has been delivered.
现在,我们不是在代码中直接使用队列和主题,而是使用通用基类(例如Destination)来产生消息。
Now, instead of using queues and topics directly in the code, we can use generic base classes, such as Destination, to produce the message.
就这么简单—将一条消息放到sqs队列仅需要那三行代码。
That's it - it took just those three lines of code to place a message on an SQS queue.
向一个sqs队列写一条消息需要三行代码。
Writing a message to an SQS queue takes three lines of code.
也许会通过应用程序的代码在数据库更新失败的时候“撤销”对队列的操作。
Perhaps the application code will try to "undo" the queue operation if the database update fails.
在旧的规范下,必须专门为队列或主题编写应用程序代码,因为类本身是特定于域的。
Under the older specification, the application code had to be written specifically for queues or topics because the classes themselves were domain-specific.
客户端部署描述符,在一个称为application-client.xml的文件中,包含对用于上述代码中JMS连接工厂和队列中JNDI名称的引用。
The client deployment descriptor, in a file called application-client.xml, contains references to the JNDI names of the JMS connection factory and queue that are used in the above code.
现在,使用清单14中的代码将包含购买订单的消息发送到AmazonSQS队列。
Now, send the message containing the purchase order to the Amazon SQS queue using the code in Listing 14.
清单8中的代码为队列定义了适当的行为。
使用JNDI可以让您随时调整服务器上的JMS主题或队列的位置和实现,而不必修改您的代码。
Using JNDI allows you to change the locations and implementations of your topics or queues on the server without having to update any of your code.
事实上,大多数应用程序代码从来不需要知道对象是否表示队列或主题,甚至不需要知道使用的是哪一个供应商的提供程序。
In fact, most of the application code need never know whether the object represents a queue or a topic, or even which vendor's provider is being used.
在清单5所示的代码片段中,进程创建了一个可包含20个整数的消息队列。
Listing 5 shows a code snippet in which a process has created a message queue of 20 integers.
虽然AWSSDK提供大量其他功能和特性,目前为止的代码是您读写消息到SQS队列所需的一切。
While the AWS SDK provides a number of other functions and features, the code so far is all you need to read and write messages to SQS queues.
侦听发送到输入队列的消息的某个后端守护程序进程将接收此消息,并将其分派到可以处理此消息的某段代码。
Some back-end daemon process listening for messages posted to the input queue would receive the message and dispatch it to some piece of code capable of handling the message.
可是,这些较大的平均窗口也意味着SACK接收代码需要对收到的每个包做很多工作,因为需要扫描的队列包含更多的包。
However, those larger average Windows also mean the SACK receiving code needs to do a lot more work for every packet received as the queue to be scanned contains more packets.
本文研究了Python的线程,并且说明了如何使用队列来降低复杂性和减少细微的错误、并提高代码可读性的最佳实践。
This article explored threads in Python and demonstrated the best practice of using queues to allieviate complexity and subtle errors, and to promote readable code.
代码样本显示了EJB组件如何使用连接对象来访问消息队列资源。
This code sample shows how an EJB component might access a message queue resource, using connection objects.
如您所见,清单8中的两行相关代码建立AWS连接并获取我的' locations _ queue '队列的句柄。
As you can see, the two lines of relevant code from Listing 8 establish a connection to AWS and grab a handle to my queue named 'locations_queue'.
WebSphereMQ监视工具可能采取此操作,此类工具会在应用程序检索到相应的返回代码前检测到队列或介质已满的情况。
This action may be used by WebSphere MQ monitoring tools that detect the queue or media full condition prior to the application receiving the return code.
下面是用于创建MQseriesQueueConnectionFactory和获取特定队列管理器连接的样本代码。
Here's the sample code to create an MQSeries QueueConnectionFactory and acquire a connection to a specific queue manager.
处理代码将处理请求,并准备要发送到输出队列的响应消息。
The handling code would process the request and prepare some response message that is posted to an output queue.
清单2中的代码显示了如何为AmazonSQS创建HTTP客户端,以及如何向队列发送一个简单的消息。
The code in Listing 2 shows how to create the HTTP client for Amazon SQS and how to send a simple message to the queue.
清单1中的代码显示了如何为AmazonSQS创建HTTP客户端、实例化CreateQueueRequest对象和调用队列创建请求。
The code in Listing 1 shows how to create the HTTP client for Amazon SQS, instantiate the CreateQueueRequest object, and invoke the queue creation request.
因为线程执行的是相同的代码,所以它们应作出类似的动态优先级调整并在相同的运行队列中轮替执行。
Because the threads execute identical code, they should have similar dynamic priority adjustments and execute in a round-robin fashion from the same run-queues.
对于这个示例,有更多的代码需要说明,但与第一个线程示例相比,它并没有复杂多少,这正是因为使用了队列模块。
This example has a bit more code to explain, but it isn't that much more complicated than the first threading example, thanks to the use of the queuing module.
该代码从对话框中获得订阅名、要使用的队列管理器以及要发送消息的队列名。
The code gets the subscription name, the queue manager to use, and the queue name to send the message from the dialog.
下面是显示消息队列提供者束如何以束服务的形式提供消息队列框架功能的源代码。
Following is the source code showing how message queue provider Bundle provides message queue framework functions in the form of a Bundle service.
发布者的代码与点到点应用程序的对应项完全一样,这是因为JMS 1.1API允许使用可以产生发布到队列和主题的消息的JMS代码。
The code for the publisher is identical to that of the point-to-point application, because the JMS 1.1 API enables JMS code that can produce messages onto either a queue or a topic.
清单1中的代码说明了如何找到Queue和QueueConnectionFactory、如何创建连接和会话、如何将XML填充到TextMessage,以及如何将消息发送给队列。
The code in Listing 1 demonstrates how to locate a queue and QueueConnectionFactory, create a connection and a session, stuff the XML into a TextMessage, and send the message to the queue.
清单1中的代码说明了如何找到Queue和QueueConnectionFactory、如何创建连接和会话、如何将XML填充到TextMessage,以及如何将消息发送给队列。
The code in Listing 1 demonstrates how to locate a queue and QueueConnectionFactory, create a connection and a session, stuff the XML into a TextMessage, and send the message to the queue.
应用推荐