You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ephemeris Lappis <ep...@gmail.com> on 2023/04/03 06:46:46 UTC

Re: Camel JMS / Set message time to live

Hello.

Thanks for your idea. I had a look at the JMs component unit tests,
but I've not found any that use only headers to set messages time to
live.
Could you please give us some example ?

Thanks again. Regards

Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com> a écrit :
>
> A good idea is to look at the unit tests in the camel components
>
> On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > Hello.
> >
> > I've not found any way to set messages time to live when sending to a
> > JMS (activemq) queue.
> >
> > I'd like to set headers only, without changing the endpoint URI. Is it
> > possible ?
> > I've read (and tested it too) that if a message header is set for the
> > JMSExpiration, it's not taken into account if the option
> > "preserveMessageQos" is not added into the URI. So, is there any other
> > way using other headers ?
> >
> > Thanks for your help.
> >
> > Regards.
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel JMS / Set message time to live

Posted by Ephemeris Lappis <ep...@gmail.com>.
Hello again !

The code I've given before, setting the header "JMSExpiration" with a
computed date ("now+30m", it seems that Camel takes the timestamp's
long value, and not the date string, to set the sent message header)
works if and only if I add "preserveMessageQos=true" to the endpoint's
URI.
There is my problem : I can't modify the URI in this case because of
some bug in our test framework that does not support options in the
JMS producer's URI.

The best way I found was to set a single option "timeToLive=1800000"
in the URI that works exactly the same way, in both cases the
"JMSExpiration" is set with the right value, and the AMQ server
removes messages after 30 minutes, but this also breaks our tests...

Regards.


Le lun. 3 avr. 2023 à 15:18, ski n <ra...@gmail.com> a écrit :
>
> I think setting "JMSExpiration" from a header isn't supported. Only these
> four:
>
> CamelJMSDestinationName (producer)
> CamelJmsRequestTimeout (producer)
> JMSCorrelationID (producer)
> JMSReplyTo (producer)
>
>
>
>
>
>
> Don't know why, but other ones have no effect. The component does some
> message mapping though, because when I don't put long in the value it says:
>
> "org.apache.camel.TypeConversionException: Error during type conversion
> from type: java.lang.String to the required type: java.lang.Long with value
> blabla due to java.lang.NumberFormatException: For input string: "blabla"
>
> When I provide a number I don't see it on the broker. I tried it with
> another client (non-camel) and then the JMSExperiation is set as expected.
>
> Regards,
>
> Raymond
>
>
>
>
>
>
>
>
>
> On Mon, Apr 3, 2023 at 1:32 PM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > No, I can't : we work on a Red-Hat Fuse cluster, and the brokers and
> > the related configured components are provided by the cluster (in
> > groups including Karaf instances), and are shared for all our business
> > bundles and their queues. We'd want to set time to live (expiration)
> > only for some queues, not all the queues that are managed by the same
> > broker group.
> >
> > That's why I need to set this time to live using headers only for some
> > messages sent to some queues...
> >
> > Thanks.
> >
> > Le lun. 3 avr. 2023 à 13:08, ski n <ra...@gmail.com> a écrit :
> > >
> > > Can you set the parameter globally like this:
> > >
> > > ActiveMQComponent activeMQComponent = new ActiveMQComponent();
> > > activeMQComponent.setPreserveMessageQos(true);
> > > context.addComponent("activemq2",activeMQComponent);
> > >
> > >
> > > On Mon, Apr 3, 2023 at 12:27 PM Ephemeris Lappis <
> > ephemeris.lappis@gmail.com>
> > > wrote:
> > >
> > > > Hello.
> > > >
> > > > In fact I think I'd only need to set one header for expiration time.
> > > > Something like that :
> > > >
> > > >             <setHeader name="JMSExpiration">
> > > >                 <simple>${date:now+30m}</simple>
> > > >             </setHeader>
> > > >             <to uri="jms:queue:fifi1?connectionFactory=#myJMS" />
> > > >
> > > > But it seems that for overriding the default JMSExpiration another
> > > > change must be done on the endpoint (otherwise the JMSExpiration is
> > > > not set before the message is sent) :
> > > >
> > > >             <to
> > > >
> > uri="jms:queue:fifi1?connectionFactory=#myJMS&amp;preserveMessageQos=true"
> > > > />
> > > >
> > > > So, is there any way to add the "preserveMessageQos=true" indication
> > > > using a header, since I can't modify the endpoint URI ?
> > > >
> > > > Thanks again.
> > > >
> > > > Regards.
> > > >
> > > > Le lun. 3 avr. 2023 à 09:43, ski n <ra...@gmail.com> a écrit
> > :
> > > > >
> > > > > I should be possible as Camel Headers are translated to JMS Headers
> > when
> > > > > sending to an ActiveMQ queue or topic. This can be tricky though as
> > > > > sometimes JMS Headers are not set by the client but by the broker
> > (for
> > > > > example JMSTimestamp), so you can't use all headers.
> > > > >
> > > > > You can check this page with the possibilities:
> > > > >
> > > > > https://activemq.apache.org/activemq-message-properties
> > > > >
> > > > > Another thing is that values you need to give are not always very
> > logical
> > > > > for example JMSDeliveryMode. According to the Java EE documentation:
> > > > >
> > > > > "The delivery modes supported by the JMS API are *PERSISTENT and
> > > > > NON_PERSISTENT* . A client marks a message as persistent if it feels
> > that
> > > > > the application will have problems if the message is lost in
> > transit. A
> > > > > client marks a message as non-persistent if an occasional lost
> > message is
> > > > > tolerable."
> > > > >
> > > > > As there are only two modes, you made expect that its a boolean
> > value.
> > > > > However it's int (as also noted on the ActiveMQ documentation page).
> > Then
> > > > > you may think the values used are 0 and 1. It's however 1
> > > > (NON-PERSISTENT)
> > > > > and 2 (PERSISTENT). Mostly in code static values are used, but when
> > > > sending
> > > > > headers as text, these are things to consider.
> > > > >
> > > > > Kind regards,
> > > > >
> > > > > Raymond
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <
> > > > ephemeris.lappis@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > Hello.
> > > > > >
> > > > > > Thanks for your idea. I had a look at the JMs component unit tests,
> > > > > > but I've not found any that use only headers to set messages time
> > to
> > > > > > live.
> > > > > > Could you please give us some example ?
> > > > > >
> > > > > > Thanks again. Regards
> > > > > >
> > > > > > Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com>
> > a
> > > > écrit
> > > > > > :
> > > > > > >
> > > > > > > A good idea is to look at the unit tests in the camel components
> > > > > > >
> > > > > > > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> > > > > > ephemeris.lappis@gmail.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Hello.
> > > > > > > >
> > > > > > > > I've not found any way to set messages time to live when
> > sending
> > > > to a
> > > > > > > > JMS (activemq) queue.
> > > > > > > >
> > > > > > > > I'd like to set headers only, without changing the endpoint
> > URI.
> > > > Is it
> > > > > > > > possible ?
> > > > > > > > I've read (and tested it too) that if a message header is set
> > for
> > > > the
> > > > > > > > JMSExpiration, it's not taken into account if the option
> > > > > > > > "preserveMessageQos" is not added into the URI. So, is there
> > any
> > > > other
> > > > > > > > way using other headers ?
> > > > > > > >
> > > > > > > > Thanks for your help.
> > > > > > > >
> > > > > > > > Regards.
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Claus Ibsen
> > > > > > > -----------------
> > > > > > > @davsclaus
> > > > > > > Camel in Action 2: https://www.manning.com/ibsen2
> > > > > >
> > > >
> >

Re: Camel JMS / Set message time to live

Posted by ski n <ra...@gmail.com>.
I think setting "JMSExpiration" from a header isn't supported. Only these
four:

CamelJMSDestinationName (producer)
CamelJmsRequestTimeout (producer)
JMSCorrelationID (producer)
JMSReplyTo (producer)






Don't know why, but other ones have no effect. The component does some
message mapping though, because when I don't put long in the value it says:

"org.apache.camel.TypeConversionException: Error during type conversion
from type: java.lang.String to the required type: java.lang.Long with value
blabla due to java.lang.NumberFormatException: For input string: "blabla"

When I provide a number I don't see it on the broker. I tried it with
another client (non-camel) and then the JMSExperiation is set as expected.

Regards,

Raymond









On Mon, Apr 3, 2023 at 1:32 PM Ephemeris Lappis <ep...@gmail.com>
wrote:

> No, I can't : we work on a Red-Hat Fuse cluster, and the brokers and
> the related configured components are provided by the cluster (in
> groups including Karaf instances), and are shared for all our business
> bundles and their queues. We'd want to set time to live (expiration)
> only for some queues, not all the queues that are managed by the same
> broker group.
>
> That's why I need to set this time to live using headers only for some
> messages sent to some queues...
>
> Thanks.
>
> Le lun. 3 avr. 2023 à 13:08, ski n <ra...@gmail.com> a écrit :
> >
> > Can you set the parameter globally like this:
> >
> > ActiveMQComponent activeMQComponent = new ActiveMQComponent();
> > activeMQComponent.setPreserveMessageQos(true);
> > context.addComponent("activemq2",activeMQComponent);
> >
> >
> > On Mon, Apr 3, 2023 at 12:27 PM Ephemeris Lappis <
> ephemeris.lappis@gmail.com>
> > wrote:
> >
> > > Hello.
> > >
> > > In fact I think I'd only need to set one header for expiration time.
> > > Something like that :
> > >
> > >             <setHeader name="JMSExpiration">
> > >                 <simple>${date:now+30m}</simple>
> > >             </setHeader>
> > >             <to uri="jms:queue:fifi1?connectionFactory=#myJMS" />
> > >
> > > But it seems that for overriding the default JMSExpiration another
> > > change must be done on the endpoint (otherwise the JMSExpiration is
> > > not set before the message is sent) :
> > >
> > >             <to
> > >
> uri="jms:queue:fifi1?connectionFactory=#myJMS&amp;preserveMessageQos=true"
> > > />
> > >
> > > So, is there any way to add the "preserveMessageQos=true" indication
> > > using a header, since I can't modify the endpoint URI ?
> > >
> > > Thanks again.
> > >
> > > Regards.
> > >
> > > Le lun. 3 avr. 2023 à 09:43, ski n <ra...@gmail.com> a écrit
> :
> > > >
> > > > I should be possible as Camel Headers are translated to JMS Headers
> when
> > > > sending to an ActiveMQ queue or topic. This can be tricky though as
> > > > sometimes JMS Headers are not set by the client but by the broker
> (for
> > > > example JMSTimestamp), so you can't use all headers.
> > > >
> > > > You can check this page with the possibilities:
> > > >
> > > > https://activemq.apache.org/activemq-message-properties
> > > >
> > > > Another thing is that values you need to give are not always very
> logical
> > > > for example JMSDeliveryMode. According to the Java EE documentation:
> > > >
> > > > "The delivery modes supported by the JMS API are *PERSISTENT and
> > > > NON_PERSISTENT* . A client marks a message as persistent if it feels
> that
> > > > the application will have problems if the message is lost in
> transit. A
> > > > client marks a message as non-persistent if an occasional lost
> message is
> > > > tolerable."
> > > >
> > > > As there are only two modes, you made expect that its a boolean
> value.
> > > > However it's int (as also noted on the ActiveMQ documentation page).
> Then
> > > > you may think the values used are 0 and 1. It's however 1
> > > (NON-PERSISTENT)
> > > > and 2 (PERSISTENT). Mostly in code static values are used, but when
> > > sending
> > > > headers as text, these are things to consider.
> > > >
> > > > Kind regards,
> > > >
> > > > Raymond
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <
> > > ephemeris.lappis@gmail.com>
> > > > wrote:
> > > >
> > > > > Hello.
> > > > >
> > > > > Thanks for your idea. I had a look at the JMs component unit tests,
> > > > > but I've not found any that use only headers to set messages time
> to
> > > > > live.
> > > > > Could you please give us some example ?
> > > > >
> > > > > Thanks again. Regards
> > > > >
> > > > > Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com>
> a
> > > écrit
> > > > > :
> > > > > >
> > > > > > A good idea is to look at the unit tests in the camel components
> > > > > >
> > > > > > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> > > > > ephemeris.lappis@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > Hello.
> > > > > > >
> > > > > > > I've not found any way to set messages time to live when
> sending
> > > to a
> > > > > > > JMS (activemq) queue.
> > > > > > >
> > > > > > > I'd like to set headers only, without changing the endpoint
> URI.
> > > Is it
> > > > > > > possible ?
> > > > > > > I've read (and tested it too) that if a message header is set
> for
> > > the
> > > > > > > JMSExpiration, it's not taken into account if the option
> > > > > > > "preserveMessageQos" is not added into the URI. So, is there
> any
> > > other
> > > > > > > way using other headers ?
> > > > > > >
> > > > > > > Thanks for your help.
> > > > > > >
> > > > > > > Regards.
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Claus Ibsen
> > > > > > -----------------
> > > > > > @davsclaus
> > > > > > Camel in Action 2: https://www.manning.com/ibsen2
> > > > >
> > >
>

Re: Camel JMS / Set message time to live

Posted by Ephemeris Lappis <ep...@gmail.com>.
No, I can't : we work on a Red-Hat Fuse cluster, and the brokers and
the related configured components are provided by the cluster (in
groups including Karaf instances), and are shared for all our business
bundles and their queues. We'd want to set time to live (expiration)
only for some queues, not all the queues that are managed by the same
broker group.

That's why I need to set this time to live using headers only for some
messages sent to some queues...

Thanks.

Le lun. 3 avr. 2023 à 13:08, ski n <ra...@gmail.com> a écrit :
>
> Can you set the parameter globally like this:
>
> ActiveMQComponent activeMQComponent = new ActiveMQComponent();
> activeMQComponent.setPreserveMessageQos(true);
> context.addComponent("activemq2",activeMQComponent);
>
>
> On Mon, Apr 3, 2023 at 12:27 PM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > Hello.
> >
> > In fact I think I'd only need to set one header for expiration time.
> > Something like that :
> >
> >             <setHeader name="JMSExpiration">
> >                 <simple>${date:now+30m}</simple>
> >             </setHeader>
> >             <to uri="jms:queue:fifi1?connectionFactory=#myJMS" />
> >
> > But it seems that for overriding the default JMSExpiration another
> > change must be done on the endpoint (otherwise the JMSExpiration is
> > not set before the message is sent) :
> >
> >             <to
> > uri="jms:queue:fifi1?connectionFactory=#myJMS&amp;preserveMessageQos=true"
> > />
> >
> > So, is there any way to add the "preserveMessageQos=true" indication
> > using a header, since I can't modify the endpoint URI ?
> >
> > Thanks again.
> >
> > Regards.
> >
> > Le lun. 3 avr. 2023 à 09:43, ski n <ra...@gmail.com> a écrit :
> > >
> > > I should be possible as Camel Headers are translated to JMS Headers when
> > > sending to an ActiveMQ queue or topic. This can be tricky though as
> > > sometimes JMS Headers are not set by the client but by the broker (for
> > > example JMSTimestamp), so you can't use all headers.
> > >
> > > You can check this page with the possibilities:
> > >
> > > https://activemq.apache.org/activemq-message-properties
> > >
> > > Another thing is that values you need to give are not always very logical
> > > for example JMSDeliveryMode. According to the Java EE documentation:
> > >
> > > "The delivery modes supported by the JMS API are *PERSISTENT and
> > > NON_PERSISTENT* . A client marks a message as persistent if it feels that
> > > the application will have problems if the message is lost in transit. A
> > > client marks a message as non-persistent if an occasional lost message is
> > > tolerable."
> > >
> > > As there are only two modes, you made expect that its a boolean value.
> > > However it's int (as also noted on the ActiveMQ documentation page). Then
> > > you may think the values used are 0 and 1. It's however 1
> > (NON-PERSISTENT)
> > > and 2 (PERSISTENT). Mostly in code static values are used, but when
> > sending
> > > headers as text, these are things to consider.
> > >
> > > Kind regards,
> > >
> > > Raymond
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <
> > ephemeris.lappis@gmail.com>
> > > wrote:
> > >
> > > > Hello.
> > > >
> > > > Thanks for your idea. I had a look at the JMs component unit tests,
> > > > but I've not found any that use only headers to set messages time to
> > > > live.
> > > > Could you please give us some example ?
> > > >
> > > > Thanks again. Regards
> > > >
> > > > Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com> a
> > écrit
> > > > :
> > > > >
> > > > > A good idea is to look at the unit tests in the camel components
> > > > >
> > > > > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> > > > ephemeris.lappis@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > Hello.
> > > > > >
> > > > > > I've not found any way to set messages time to live when sending
> > to a
> > > > > > JMS (activemq) queue.
> > > > > >
> > > > > > I'd like to set headers only, without changing the endpoint URI.
> > Is it
> > > > > > possible ?
> > > > > > I've read (and tested it too) that if a message header is set for
> > the
> > > > > > JMSExpiration, it's not taken into account if the option
> > > > > > "preserveMessageQos" is not added into the URI. So, is there any
> > other
> > > > > > way using other headers ?
> > > > > >
> > > > > > Thanks for your help.
> > > > > >
> > > > > > Regards.
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Claus Ibsen
> > > > > -----------------
> > > > > @davsclaus
> > > > > Camel in Action 2: https://www.manning.com/ibsen2
> > > >
> >

Re: Camel JMS / Set message time to live

Posted by ski n <ra...@gmail.com>.
Can you set the parameter globally like this:

ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setPreserveMessageQos(true);
context.addComponent("activemq2",activeMQComponent);


On Mon, Apr 3, 2023 at 12:27 PM Ephemeris Lappis <ep...@gmail.com>
wrote:

> Hello.
>
> In fact I think I'd only need to set one header for expiration time.
> Something like that :
>
>             <setHeader name="JMSExpiration">
>                 <simple>${date:now+30m}</simple>
>             </setHeader>
>             <to uri="jms:queue:fifi1?connectionFactory=#myJMS" />
>
> But it seems that for overriding the default JMSExpiration another
> change must be done on the endpoint (otherwise the JMSExpiration is
> not set before the message is sent) :
>
>             <to
> uri="jms:queue:fifi1?connectionFactory=#myJMS&amp;preserveMessageQos=true"
> />
>
> So, is there any way to add the "preserveMessageQos=true" indication
> using a header, since I can't modify the endpoint URI ?
>
> Thanks again.
>
> Regards.
>
> Le lun. 3 avr. 2023 à 09:43, ski n <ra...@gmail.com> a écrit :
> >
> > I should be possible as Camel Headers are translated to JMS Headers when
> > sending to an ActiveMQ queue or topic. This can be tricky though as
> > sometimes JMS Headers are not set by the client but by the broker (for
> > example JMSTimestamp), so you can't use all headers.
> >
> > You can check this page with the possibilities:
> >
> > https://activemq.apache.org/activemq-message-properties
> >
> > Another thing is that values you need to give are not always very logical
> > for example JMSDeliveryMode. According to the Java EE documentation:
> >
> > "The delivery modes supported by the JMS API are *PERSISTENT and
> > NON_PERSISTENT* . A client marks a message as persistent if it feels that
> > the application will have problems if the message is lost in transit. A
> > client marks a message as non-persistent if an occasional lost message is
> > tolerable."
> >
> > As there are only two modes, you made expect that its a boolean value.
> > However it's int (as also noted on the ActiveMQ documentation page). Then
> > you may think the values used are 0 and 1. It's however 1
> (NON-PERSISTENT)
> > and 2 (PERSISTENT). Mostly in code static values are used, but when
> sending
> > headers as text, these are things to consider.
> >
> > Kind regards,
> >
> > Raymond
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <
> ephemeris.lappis@gmail.com>
> > wrote:
> >
> > > Hello.
> > >
> > > Thanks for your idea. I had a look at the JMs component unit tests,
> > > but I've not found any that use only headers to set messages time to
> > > live.
> > > Could you please give us some example ?
> > >
> > > Thanks again. Regards
> > >
> > > Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com> a
> écrit
> > > :
> > > >
> > > > A good idea is to look at the unit tests in the camel components
> > > >
> > > > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> > > ephemeris.lappis@gmail.com>
> > > > wrote:
> > > >
> > > > > Hello.
> > > > >
> > > > > I've not found any way to set messages time to live when sending
> to a
> > > > > JMS (activemq) queue.
> > > > >
> > > > > I'd like to set headers only, without changing the endpoint URI.
> Is it
> > > > > possible ?
> > > > > I've read (and tested it too) that if a message header is set for
> the
> > > > > JMSExpiration, it's not taken into account if the option
> > > > > "preserveMessageQos" is not added into the URI. So, is there any
> other
> > > > > way using other headers ?
> > > > >
> > > > > Thanks for your help.
> > > > >
> > > > > Regards.
> > > > >
> > > >
> > > >
> > > > --
> > > > Claus Ibsen
> > > > -----------------
> > > > @davsclaus
> > > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
>

Re: Camel JMS / Set message time to live

Posted by Ephemeris Lappis <ep...@gmail.com>.
Hello.

In fact I think I'd only need to set one header for expiration time.
Something like that :

            <setHeader name="JMSExpiration">
                <simple>${date:now+30m}</simple>
            </setHeader>
            <to uri="jms:queue:fifi1?connectionFactory=#myJMS" />

But it seems that for overriding the default JMSExpiration another
change must be done on the endpoint (otherwise the JMSExpiration is
not set before the message is sent) :

            <to
uri="jms:queue:fifi1?connectionFactory=#myJMS&amp;preserveMessageQos=true"
/>

So, is there any way to add the "preserveMessageQos=true" indication
using a header, since I can't modify the endpoint URI ?

Thanks again.

Regards.

Le lun. 3 avr. 2023 à 09:43, ski n <ra...@gmail.com> a écrit :
>
> I should be possible as Camel Headers are translated to JMS Headers when
> sending to an ActiveMQ queue or topic. This can be tricky though as
> sometimes JMS Headers are not set by the client but by the broker (for
> example JMSTimestamp), so you can't use all headers.
>
> You can check this page with the possibilities:
>
> https://activemq.apache.org/activemq-message-properties
>
> Another thing is that values you need to give are not always very logical
> for example JMSDeliveryMode. According to the Java EE documentation:
>
> "The delivery modes supported by the JMS API are *PERSISTENT and
> NON_PERSISTENT* . A client marks a message as persistent if it feels that
> the application will have problems if the message is lost in transit. A
> client marks a message as non-persistent if an occasional lost message is
> tolerable."
>
> As there are only two modes, you made expect that its a boolean value.
> However it's int (as also noted on the ActiveMQ documentation page). Then
> you may think the values used are 0 and 1. It's however 1 (NON-PERSISTENT)
> and 2 (PERSISTENT). Mostly in code static values are used, but when sending
> headers as text, these are things to consider.
>
> Kind regards,
>
> Raymond
>
>
>
>
>
>
>
>
>
> On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > Hello.
> >
> > Thanks for your idea. I had a look at the JMs component unit tests,
> > but I've not found any that use only headers to set messages time to
> > live.
> > Could you please give us some example ?
> >
> > Thanks again. Regards
> >
> > Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com> a écrit
> > :
> > >
> > > A good idea is to look at the unit tests in the camel components
> > >
> > > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> > ephemeris.lappis@gmail.com>
> > > wrote:
> > >
> > > > Hello.
> > > >
> > > > I've not found any way to set messages time to live when sending to a
> > > > JMS (activemq) queue.
> > > >
> > > > I'd like to set headers only, without changing the endpoint URI. Is it
> > > > possible ?
> > > > I've read (and tested it too) that if a message header is set for the
> > > > JMSExpiration, it's not taken into account if the option
> > > > "preserveMessageQos" is not added into the URI. So, is there any other
> > > > way using other headers ?
> > > >
> > > > Thanks for your help.
> > > >
> > > > Regards.
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> >

Re: Camel JMS / Set message time to live

Posted by ski n <ra...@gmail.com>.
I should be possible as Camel Headers are translated to JMS Headers when
sending to an ActiveMQ queue or topic. This can be tricky though as
sometimes JMS Headers are not set by the client but by the broker (for
example JMSTimestamp), so you can't use all headers.

You can check this page with the possibilities:

https://activemq.apache.org/activemq-message-properties

Another thing is that values you need to give are not always very logical
for example JMSDeliveryMode. According to the Java EE documentation:

"The delivery modes supported by the JMS API are *PERSISTENT and
NON_PERSISTENT* . A client marks a message as persistent if it feels that
the application will have problems if the message is lost in transit. A
client marks a message as non-persistent if an occasional lost message is
tolerable."

As there are only two modes, you made expect that its a boolean value.
However it's int (as also noted on the ActiveMQ documentation page). Then
you may think the values used are 0 and 1. It's however 1 (NON-PERSISTENT)
and 2 (PERSISTENT). Mostly in code static values are used, but when sending
headers as text, these are things to consider.

Kind regards,

Raymond









On Mon, Apr 3, 2023 at 8:47 AM Ephemeris Lappis <ep...@gmail.com>
wrote:

> Hello.
>
> Thanks for your idea. I had a look at the JMs component unit tests,
> but I've not found any that use only headers to set messages time to
> live.
> Could you please give us some example ?
>
> Thanks again. Regards
>
> Le ven. 31 mars 2023 à 18:34, Claus Ibsen <cl...@gmail.com> a écrit
> :
> >
> > A good idea is to look at the unit tests in the camel components
> >
> > On Fri, Mar 31, 2023 at 6:27 PM Ephemeris Lappis <
> ephemeris.lappis@gmail.com>
> > wrote:
> >
> > > Hello.
> > >
> > > I've not found any way to set messages time to live when sending to a
> > > JMS (activemq) queue.
> > >
> > > I'd like to set headers only, without changing the endpoint URI. Is it
> > > possible ?
> > > I've read (and tested it too) that if a message header is set for the
> > > JMSExpiration, it's not taken into account if the option
> > > "preserveMessageQos" is not added into the URI. So, is there any other
> > > way using other headers ?
> > >
> > > Thanks for your help.
> > >
> > > Regards.
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>