7.2.5. Avoiding a Blocked Asynchronous Send


An asynchronous send call will place the message into the send buffer and return to execution immediately. However, if the send buffer is full the call will block until space is available.
If you need to ensure that an asynchronous send call does not block on a full buffer, you should query the buffer state before making the call. For example, in C++:
C++
  if (sender.getAvailable() > 0)
      sender.send(message, false)
   // else drop the message
Python
if sender.available() > 0:
  sender.send(message, sync=False)
else:
  # drop the message
You can also increase the size of the sender's replay buffer to reduce the chances of it filling up:
C++
sender.setCapacity(SOME_LARGE_NUMBER)
Python
sender.capacity = SOME_LARGE_NUMBER
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.