You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Francesco Raviglione <fr...@gmail.com> on 2020/03/19 18:48:24 UTC

Qpid Proton C++: continue running a client application after entering the event loop

Dear all,
I am writing you because I'm trying to better understand how to use the
Qpid Proton C++ library, after learning a bit how to work with the C API.

My goal would be, in particular, to write a client/producer which can
connect to an external broker, from which other clients can then consume my
messages.

My issue is that I should integrate the client inside an application which
should continue running after I start the Qpid Proton event loop.
In particular, the application should perform other operations and prepare,
from time to time, the messages which should be dispatched to the broker.

Do you know whether there is a good way to achieve this goal directly
within Qpid Proton?

Looking at the "helloworld.cpp" example, the client is entering the event
loop by means of "proton::container(hw).run();", and exiting that loop only
when "d.connection().close();" is called.
Is there any way in which I can periodically "inject" some messages into
the event loop, letting the application run after the call to
"proton::container(hw).run();", and then going back to handling AMQP events
when I need to send a new packet, without the need of opening and closing
the connection every time (as the messages I need to prepare and send may
come quite at a fast rate, even less than every 100 ms)?
Should I rely on multiple threads?

Thank you very much in advance for your assistance.

Re: Qpid Proton C++: continue running a client application after entering the event loop

Posted by Francesco Raviglione <fr...@gmail.com>.
Dear Robbie,
Thank you very much for your reply.

I will surely investigate more the examples you provided, especially the
one related to the multithreaded client.

Thank you again for your assistance!



Il giorno lun 23 mar 2020 alle ore 12:45 Robbie Gemmell <
robbie.gemmell@gmail.com> ha scritto:

> I believe youll need to either schedule work on the container thread,
> or use multiple threads and hand work off between them safely. Perhaps
>
> http://qpid.apache.org/releases/qpid-proton-0.30.0/proton/cpp/api/scheduled_send_8cpp-example.html
> or
> http://qpid.apache.org/releases/qpid-proton-0.30.0/proton/cpp/api/multithreaded_client_8cpp-example.html
> could be useful to look at.
>
> Robbie
>
> On Thu, 19 Mar 2020 at 18:48, Francesco Raviglione
> <fr...@gmail.com> wrote:
> >
> > Dear all,
> > I am writing you because I'm trying to better understand how to use the
> > Qpid Proton C++ library, after learning a bit how to work with the C API.
> >
> > My goal would be, in particular, to write a client/producer which can
> > connect to an external broker, from which other clients can then consume
> my
> > messages.
> >
> > My issue is that I should integrate the client inside an application
> which
> > should continue running after I start the Qpid Proton event loop.
> > In particular, the application should perform other operations and
> prepare,
> > from time to time, the messages which should be dispatched to the broker.
> >
> > Do you know whether there is a good way to achieve this goal directly
> > within Qpid Proton?
> >
> > Looking at the "helloworld.cpp" example, the client is entering the event
> > loop by means of "proton::container(hw).run();", and exiting that loop
> only
> > when "d.connection().close();" is called.
> > Is there any way in which I can periodically "inject" some messages into
> > the event loop, letting the application run after the call to
> > "proton::container(hw).run();", and then going back to handling AMQP
> events
> > when I need to send a new packet, without the need of opening and closing
> > the connection every time (as the messages I need to prepare and send may
> > come quite at a fast rate, even less than every 100 ms)?
> > Should I rely on multiple threads?
> >
> > Thank you very much in advance for your assistance.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: Qpid Proton C++: continue running a client application after entering the event loop

Posted by Robbie Gemmell <ro...@gmail.com>.
I believe youll need to either schedule work on the container thread,
or use multiple threads and hand work off between them safely. Perhaps
http://qpid.apache.org/releases/qpid-proton-0.30.0/proton/cpp/api/scheduled_send_8cpp-example.html
or http://qpid.apache.org/releases/qpid-proton-0.30.0/proton/cpp/api/multithreaded_client_8cpp-example.html
could be useful to look at.

Robbie

On Thu, 19 Mar 2020 at 18:48, Francesco Raviglione
<fr...@gmail.com> wrote:
>
> Dear all,
> I am writing you because I'm trying to better understand how to use the
> Qpid Proton C++ library, after learning a bit how to work with the C API.
>
> My goal would be, in particular, to write a client/producer which can
> connect to an external broker, from which other clients can then consume my
> messages.
>
> My issue is that I should integrate the client inside an application which
> should continue running after I start the Qpid Proton event loop.
> In particular, the application should perform other operations and prepare,
> from time to time, the messages which should be dispatched to the broker.
>
> Do you know whether there is a good way to achieve this goal directly
> within Qpid Proton?
>
> Looking at the "helloworld.cpp" example, the client is entering the event
> loop by means of "proton::container(hw).run();", and exiting that loop only
> when "d.connection().close();" is called.
> Is there any way in which I can periodically "inject" some messages into
> the event loop, letting the application run after the call to
> "proton::container(hw).run();", and then going back to handling AMQP events
> when I need to send a new packet, without the need of opening and closing
> the connection every time (as the messages I need to prepare and send may
> come quite at a fast rate, even less than every 100 ms)?
> Should I rely on multiple threads?
>
> Thank you very much in advance for your assistance.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org