7.2.6. Asynchronous Message Sending Example
The following code demonstrates using the properties of a sender to manage asynchronous send operations, with the option to avoid synchronous blocking when the sender is at capacity:
- C++
sender.setCapacity(MY_CAPACITY); // Later bool resend = true; while (resend) { if (sender.getAvailable()>0) { sender.send(message,false); resend = false; } else { // May wish to do nothing here // or send to log file std::cout << "Warning: Capacity \ full. Retry" << std::endl; } } // Later if (sender.getUnsettled()) { session.sync(); }
- Python
snd.capacity = MY_CAPACITY # Later resend = True while (resend): if (snd.available()>0): snd.send(msg, sync = False) resend = False else: print "Warning: Capacity full" # Later if (snd.unsettled()): ssn.sync()