You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Jan Šmucr <Ja...@aimtecglobal.com> on 2022/08/05 09:06:03 UTC

A question about ClientMessage.setOutputStream()

Hello.

The Large Messages documentation states that:
> setOutputStream(OutputStream): Set the OutputStream that will receive the body of a message. This method does not block.

However if I write something like this:

InputStream input = new PipedInputStream(1);
OutputStream output = new PipedOutputStream(input);
msg.setOutputStream(output);
// Now imagine I read something from the input and then:
msg.waitOutputStreamCompletion(0);

…then never make it beyond the msg.setOutputStream(output) line.

Is there something I don’t understand about the method being non blocking as opposed to the saveToOutputStream method?

Thank you.
Jan

Re: A question about ClientMessage.setOutputStream()

Posted by Robbie Gemmell <ro...@gmail.com>.
I would guess that if you look at what its actually blocking at
specifically, its going to be doing something like writing output
already available before the stream was set. So the doc should perhaps
clarify the method does that, and 'wont block for message
completion...but may as long as the provided OutputStream itself does
while writing any data already available'

On Fri, 5 Aug 2022 at 17:04, Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> That’s an option, but given that it’s an AWS Lambda function, I’d prefer to stream it, so that there’s no need to use either the memory or the underlying ephemeral storage.
>
> However that’s not the point. I just wanted to know if the setOutputStream function is supposed to block, or if I’m doing something wrong. I’d write a test but first I need to know if I use the method right. 😊
>
> Thank you.
>
> From: Clebert Suconic<ma...@gmail.com>
> Sent: pátek 5. srpna 2022 17:57
> To: dev@activemq.apache.org<ma...@activemq.apache.org>
> Cc: Zuzana Káčereková<ma...@aimtecglobal.com>
> Subject: Re: A question about ClientMessage.setOutputStream()
>
> I would save the Message locally before you forward it anywhere else.
>
> On Fri, Aug 5, 2022 at 7:35 AM Jan Šmucr <Ja...@aimtecglobal.com> wrote:
> >
> > Hi Domenico,
> > thank you for your response.
> > Unfortunately, this does not work either.
> >
> > Tests which use this method pass fine, because the output stream happens to be a FileOutputStream instance which does not block (unless there’s some issue with the underlying file system).
> >
> > Jan
> >
> > From: Domenico Francesco Bruscino<ma...@gmail.com>
> > Sent: pátek 5. srpna 2022 12:57
> > To: dev@activemq.apache.org<ma...@activemq.apache.org>
> > Subject: Re: A question about ClientMessage.setOutputStream()
> >
> > Hi Jan,
> >
> > calling checkCompletion() or getBodyBuffer() before
> > calling setOutputStream(OutputStream) should fix your issue.
> >
> > Regards,
> > Domenico
> >
> > On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com> wrote:
> >
> > > Hello.
> > >
> > > The Large Messages documentation states that:
> > > > setOutputStream(OutputStream): Set the OutputStream that will receive
> > > the body of a message. This method does not block.
> > >
> > > However if I write something like this:
> > >
> > > InputStream input = new PipedInputStream(1);
> > > OutputStream output = new PipedOutputStream(input);
> > > msg.setOutputStream(output);
> > > // Now imagine I read something from the input and then:
> > > msg.waitOutputStreamCompletion(0);
> > >
> > > …then never make it beyond the msg.setOutputStream(output) line.
> > >
> > > Is there something I don’t understand about the method being non blocking
> > > as opposed to the saveToOutputStream method?
> > >
> > > Thank you.
> > > Jan
> > >
> >
>
>
> --
> Clebert Suconic
>

Re: A question about ClientMessage.setOutputStream()

Posted by Clebert Suconic <cl...@gmail.com>.
It’s been a while I wrote that.  I remember there was a method for sabe
that would block. saveSomethint

I will check later.

On Fri, Aug 5, 2022 at 12:04 PM Jan Šmucr <Ja...@aimtecglobal.com>
wrote:

> That’s an option, but given that it’s an AWS Lambda function, I’d prefer
> to stream it, so that there’s no need to use either the memory or the
> underlying ephemeral storage.
>
> However that’s not the point. I just wanted to know if the setOutputStream
> function is supposed to block, or if I’m doing something wrong. I’d write a
> test but first I need to know if I use the method right. 😊
>
> Thank you.
>
> From: Clebert Suconic<ma...@gmail.com>
> Sent: pátek 5. srpna 2022 17:57
> To: dev@activemq.apache.org<ma...@activemq.apache.org>
> Cc: Zuzana Káčereková<ma...@aimtecglobal.com>
> Subject: Re: A question about ClientMessage.setOutputStream()
>
> I would save the Message locally before you forward it anywhere else.
>
> On Fri, Aug 5, 2022 at 7:35 AM Jan Šmucr <Ja...@aimtecglobal.com>
> wrote:
> >
> > Hi Domenico,
> > thank you for your response.
> > Unfortunately, this does not work either.
> >
> > Tests which use this method pass fine, because the output stream happens
> to be a FileOutputStream instance which does not block (unless there’s some
> issue with the underlying file system).
> >
> > Jan
> >
> > From: Domenico Francesco Bruscino<ma...@gmail.com>
> > Sent: pátek 5. srpna 2022 12:57
> > To: dev@activemq.apache.org<ma...@activemq.apache.org>
> > Subject: Re: A question about ClientMessage.setOutputStream()
> >
> > Hi Jan,
> >
> > calling checkCompletion() or getBodyBuffer() before
> > calling setOutputStream(OutputStream) should fix your issue.
> >
> > Regards,
> > Domenico
> >
> > On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com>
> wrote:
> >
> > > Hello.
> > >
> > > The Large Messages documentation states that:
> > > > setOutputStream(OutputStream): Set the OutputStream that will receive
> > > the body of a message. This method does not block.
> > >
> > > However if I write something like this:
> > >
> > > InputStream input = new PipedInputStream(1);
> > > OutputStream output = new PipedOutputStream(input);
> > > msg.setOutputStream(output);
> > > // Now imagine I read something from the input and then:
> > > msg.waitOutputStreamCompletion(0);
> > >
> > > …then never make it beyond the msg.setOutputStream(output) line.
> > >
> > > Is there something I don’t understand about the method being non
> blocking
> > > as opposed to the saveToOutputStream method?
> > >
> > > Thank you.
> > > Jan
> > >
> >
>
>
> --
> Clebert Suconic
>
> --
Clebert Suconic

RE: A question about ClientMessage.setOutputStream()

Posted by Jan Šmucr <Ja...@aimtecglobal.com>.
That’s an option, but given that it’s an AWS Lambda function, I’d prefer to stream it, so that there’s no need to use either the memory or the underlying ephemeral storage.

However that’s not the point. I just wanted to know if the setOutputStream function is supposed to block, or if I’m doing something wrong. I’d write a test but first I need to know if I use the method right. 😊

Thank you.

From: Clebert Suconic<ma...@gmail.com>
Sent: pátek 5. srpna 2022 17:57
To: dev@activemq.apache.org<ma...@activemq.apache.org>
Cc: Zuzana Káčereková<ma...@aimtecglobal.com>
Subject: Re: A question about ClientMessage.setOutputStream()

I would save the Message locally before you forward it anywhere else.

On Fri, Aug 5, 2022 at 7:35 AM Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> Hi Domenico,
> thank you for your response.
> Unfortunately, this does not work either.
>
> Tests which use this method pass fine, because the output stream happens to be a FileOutputStream instance which does not block (unless there’s some issue with the underlying file system).
>
> Jan
>
> From: Domenico Francesco Bruscino<ma...@gmail.com>
> Sent: pátek 5. srpna 2022 12:57
> To: dev@activemq.apache.org<ma...@activemq.apache.org>
> Subject: Re: A question about ClientMessage.setOutputStream()
>
> Hi Jan,
>
> calling checkCompletion() or getBodyBuffer() before
> calling setOutputStream(OutputStream) should fix your issue.
>
> Regards,
> Domenico
>
> On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> > Hello.
> >
> > The Large Messages documentation states that:
> > > setOutputStream(OutputStream): Set the OutputStream that will receive
> > the body of a message. This method does not block.
> >
> > However if I write something like this:
> >
> > InputStream input = new PipedInputStream(1);
> > OutputStream output = new PipedOutputStream(input);
> > msg.setOutputStream(output);
> > // Now imagine I read something from the input and then:
> > msg.waitOutputStreamCompletion(0);
> >
> > …then never make it beyond the msg.setOutputStream(output) line.
> >
> > Is there something I don’t understand about the method being non blocking
> > as opposed to the saveToOutputStream method?
> >
> > Thank you.
> > Jan
> >
>


--
Clebert Suconic


Re: A question about ClientMessage.setOutputStream()

Posted by Clebert Suconic <cl...@gmail.com>.
I would save the Message locally before you forward it anywhere else.

On Fri, Aug 5, 2022 at 7:35 AM Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> Hi Domenico,
> thank you for your response.
> Unfortunately, this does not work either.
>
> Tests which use this method pass fine, because the output stream happens to be a FileOutputStream instance which does not block (unless there’s some issue with the underlying file system).
>
> Jan
>
> From: Domenico Francesco Bruscino<ma...@gmail.com>
> Sent: pátek 5. srpna 2022 12:57
> To: dev@activemq.apache.org<ma...@activemq.apache.org>
> Subject: Re: A question about ClientMessage.setOutputStream()
>
> Hi Jan,
>
> calling checkCompletion() or getBodyBuffer() before
> calling setOutputStream(OutputStream) should fix your issue.
>
> Regards,
> Domenico
>
> On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com> wrote:
>
> > Hello.
> >
> > The Large Messages documentation states that:
> > > setOutputStream(OutputStream): Set the OutputStream that will receive
> > the body of a message. This method does not block.
> >
> > However if I write something like this:
> >
> > InputStream input = new PipedInputStream(1);
> > OutputStream output = new PipedOutputStream(input);
> > msg.setOutputStream(output);
> > // Now imagine I read something from the input and then:
> > msg.waitOutputStreamCompletion(0);
> >
> > …then never make it beyond the msg.setOutputStream(output) line.
> >
> > Is there something I don’t understand about the method being non blocking
> > as opposed to the saveToOutputStream method?
> >
> > Thank you.
> > Jan
> >
>


-- 
Clebert Suconic

RE: A question about ClientMessage.setOutputStream()

Posted by Jan Šmucr <Ja...@aimtecglobal.com>.
Hi Domenico,
thank you for your response.
Unfortunately, this does not work either.

Tests which use this method pass fine, because the output stream happens to be a FileOutputStream instance which does not block (unless there’s some issue with the underlying file system).

Jan

From: Domenico Francesco Bruscino<ma...@gmail.com>
Sent: pátek 5. srpna 2022 12:57
To: dev@activemq.apache.org<ma...@activemq.apache.org>
Subject: Re: A question about ClientMessage.setOutputStream()

Hi Jan,

calling checkCompletion() or getBodyBuffer() before
calling setOutputStream(OutputStream) should fix your issue.

Regards,
Domenico

On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com> wrote:

> Hello.
>
> The Large Messages documentation states that:
> > setOutputStream(OutputStream): Set the OutputStream that will receive
> the body of a message. This method does not block.
>
> However if I write something like this:
>
> InputStream input = new PipedInputStream(1);
> OutputStream output = new PipedOutputStream(input);
> msg.setOutputStream(output);
> // Now imagine I read something from the input and then:
> msg.waitOutputStreamCompletion(0);
>
> …then never make it beyond the msg.setOutputStream(output) line.
>
> Is there something I don’t understand about the method being non blocking
> as opposed to the saveToOutputStream method?
>
> Thank you.
> Jan
>


Re: A question about ClientMessage.setOutputStream()

Posted by Domenico Francesco Bruscino <br...@gmail.com>.
Hi Jan,

calling checkCompletion() or getBodyBuffer() before
calling setOutputStream(OutputStream) should fix your issue.

Regards,
Domenico

On Fri, 5 Aug 2022 at 11:06, Jan Šmucr <Ja...@aimtecglobal.com> wrote:

> Hello.
>
> The Large Messages documentation states that:
> > setOutputStream(OutputStream): Set the OutputStream that will receive
> the body of a message. This method does not block.
>
> However if I write something like this:
>
> InputStream input = new PipedInputStream(1);
> OutputStream output = new PipedOutputStream(input);
> msg.setOutputStream(output);
> // Now imagine I read something from the input and then:
> msg.waitOutputStreamCompletion(0);
>
> …then never make it beyond the msg.setOutputStream(output) line.
>
> Is there something I don’t understand about the method being non blocking
> as opposed to the saveToOutputStream method?
>
> Thank you.
> Jan
>