5.2.4. Receiving Messages from Multiple Sources
Prerequisites:
A
Receiver
object receives messages from a single subscription. An application can create many receivers, and may wish to deal with messages from these various receivers in the order that the messages are received. The session
object provides a method nextReceiver
that allows an application to read messages from multiple receivers in a federated order.
Note: To use the Next Receiver feature,
prefetch
must be enabled for the receivers, and the receivers must be using the same session.
- Python
receiver1 = session.receiver(address1) receiver1.capacity = 10 receiver2 = session.receiver(address) receiver2.capacity = 10 message = session.next_receiver().fetch() print message.content session.acknowledge()
- C++
Receiver receiver1 = session.createReceiver(address1); receiver1.setCapacity(10); Receiver receiver2 = session.createReceiver(address2); receiver2.setCapacity(10); Message message = session.nextReceiver().fetch(); std::cout << message.getContent() << std::endl; session.acknowledge(); // acknowledge message receipt
- .NET/C#
Receiver receiver1 = session.CreateReceiver(address1); receiver1.SetCapacity(10); Receiver receiver2 = session.CreateReceiver(address2); receiver2.SetCapacity(10); Message message = new Message(); message = session.NextReceiver().Fetch(); Console.WriteLine("{0}", message.GetContent()); session.Acknowledge();