You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by Frank Quinn <fq...@nyx.com> on 2013/08/14 12:30:28 UTC

Blocking nature of pn_messenger_send

Hi Folks,

If I try and use:

pn_messenger_send (messenger, 0);

The receiver never seems to receive the message. The comment in the header suggests:

"If n is 0 then this call won't block"

I guess technically that's true – the send didn't block when the send size was zero, but it also didn't send anything. I expected sending a value of "0" to have the effect of "-1" with the added behaviour that it does not block during the send but this simply seems to "send zero messages and return".

Is there a way built into qpid proton to send in unblocking mode within the publisher where pn_messenger_send doesn't block at all but still flushes the send queue in another thread?

Cheers,
Frank

________________________________

Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
------------------------------------------------------------------------------

Please consider the environment before printing this email.

Visit our website at http://www.nyse.com <http://www.nyse.com>
*****************************************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.

Re: Blocking nature of pn_messenger_send

Posted by Rafael Schloming <rh...@alum.mit.edu>.
I think this is a bug. Right now passing 0 is going to end up being a noop
whereas it should actually make an attempt to send the messages and only
return if it has to block. You should be able to work around this by using
pn_messenger_work. Internally send is doing something like:

while (pn_messenger_outgoing() > 0) {
    pn_messenger_work()
}

And now that pn_messenger_work() is part of the public API, you should be
able to break down what send does in a variety of different ways, including
from another thread if you want to. Obviously if you're using threads
you'll need to add locking so you don't have concurrent access to the
messenger object, but I believe you should be able to use
pn_messenger_put() from your publisher thread and pn_messenger_work from a
worker thread given appropriate synchronization and use of
pn_messenger_interrupt.

--Rafael



On Wed, Aug 14, 2013 at 6:30 AM, Frank Quinn <fq...@nyx.com> wrote:

> Hi Folks,
>
> If I try and use:
>
> pn_messenger_send (messenger, 0);
>
> The receiver never seems to receive the message. The comment in the header
> suggests:
>
> "If n is 0 then this call won't block"
>
> I guess technically that's true – the send didn't block when the send size
> was zero, but it also didn't send anything. I expected sending a value of
> "0" to have the effect of "-1" with the added behaviour that it does not
> block during the send but this simply seems to "send zero messages and
> return".
>
> Is there a way built into qpid proton to send in unblocking mode within
> the publisher where pn_messenger_send doesn't block at all but still
> flushes the send queue in another thread?
>
> Cheers,
> Frank
>
> ________________________________
>
> Please consider the environment before printing this e-mail.
>
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient or have received this e-mail in error,
> please advise the sender immediately by reply e-mail and delete this
> message and any attachments without retaining a copy.
>
> Any unauthorised copying, disclosure or distribution of the material in
> this e-mail is strictly forbidden.
>
> ------------------------------------------------------------------------------
>
> Please consider the environment before printing this email.
>
> Visit our website at http://www.nyse.com <http://www.nyse.com>
>
> *****************************************************************************
> Note: The information contained in this message and any attachment to it
> is privileged, confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify the sender immediately by replying to
> the message, and please delete it from your system. Thank you. NYSE
> Euronext.
>