I don't believe the qpid objects are thread-safe. I had a case with two
threads sending messages using the same session object and found that it
didn't work unless I protected access to the qpid objects with a mutex.


On Wed, Jan 20, 2010 at 12:54 PM, Adam Crain <[email protected]
> wrote:

> Hi,
>
>
>
> I have an application that needs to both read and write messages to a
> broker, i.e. events can come from two sources
>
>
>
> 1)      the broker, something I've setup callbacks for
>
> 2)      the outside world, for arguments sake say someone presses a
> button
>
>
>
> Can I make read/write equally responsive using a single Session object?
>
>
>
> i.e. can I launch a thread to handle my subscriptions, i.e.:
>
>
>
> connection.open(host, port);
> Session session =  connection.newSession();
>
> SubscriptionManager subscriptions(session);
>
> Listener listener(subscriptions);
>
> subscriptions.subscribe(listener, "message_queue");
>
> subscriptions.start(); //non-blocking call, starts another thread, runs
> until stop is called
>
>
>
> and then continue on in the parent thread responding to events from the
> other source:
>
>
>
> void OnEvent()
>
> {
>
>        message.getDeliveryProperties().setRoutingKey("routing_key");
>        message.setData("Hi, Mom!");
>        session.messageTransfer(arg::content=message,
> arg::destination="amq.direct");
>
> }
>
>
>
> These were just code fragments taken from
> http://qpid.apache.org/docs/api/cpp/html/index.html. Any insight you can
> provide into this would be appreciated.
>
>
>
>
>
> Adam Crain
>
> Manager of R&D
>
> Plymouth Systems, Inc.
>
> 919-428-1002
>
>
>
>

Reply via email to