On Thu, 2016-03-17 at 20:02 +0100, Mark Banner wrote:
> Hi,
> 
> I am creating an application which is using the C++ API for AMQP
> (0.12) and
> I am trying to wrap my head around how to create a sender when I have
> a new
> message to send.
> 
> For receiving messages, I can create a receiver when the container is
> finished initializing and on_message will be called whenever a new
> message
> is received. However, for sending messages, if I create a sender when
> the
> reactor initializes, on_sendable will be called when it is not
> needed. From
> what I understand in the examples, the a sender should be closed when
> all
> the client's messages have been sent.
> 
> How should I go about telling the container I want to send a message?
> Is it
> safe to pass the connection which is set up in on_start outside of
> the
> container and to create a new sender in another thread?
> 
> Any help would be much appreciated,
> Mark

The container is not thread safe, and it is not safe to use any
container-owned proton objects outside the thread that calls
container::run(). Presently there is no way to stop it running. This is
a very serious limitation.

There is a plan to add "application event injection" which would allow
you to inject custom actions from arbitrary threads and have them
executed safely in the container::run() thread. I expect that to
materialize soon.

There is also an alternative to the container: the connection_engine.
It gives you full control over how IO and threads interact with proton.
Right now it is raw but usable (see the cpp/engine examples.) It is my
top priority to make this easy to use for all the common multi-threaded 
use cases. I would be happy to help you use it and to be guided by your
use cases in developing it for the future.

Cheers,
Alan.

Reply via email to