You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Kannan <ra...@gmail.com> on 2010/09/14 17:36:48 UTC

example to set priority in message?

I tried to set message priory like below mentioned code.  It didn’t work for
me.I am not sure what changes still needed to be done.


<route errorHandlerRef="deadLetterErrorHandler">
      <from ref="queue1" />
      <transacted ref="required" />
      <convertBodyTo type="com.domain.Message" />
      <choice>
        <when>
          <simple>${body.entity} is Foo</simple>
          <setHeader
headerName="JMSPriority"><constant>1</constant></setHeader>
          <to ref="olapQueue" />
        </when>
        <when>
          <simple>${body.entity} is Bar</simple>
          <setHeader
headerName="JMSPriority"><constant>2</constant></setHeader>
          <to ref="oltpQueue" />
        </when>
        <otherwise>
          <to ref="deadLetterQueue" />
        </otherwise>
      </choice>      
    </route>



<route errorHandlerRef="deadLetterErrorHandler">
      <from ref="queue1" />
       <resequence>
         <header>JMSPriority</header>        
         <to uri="mock:result" />
         <batch-config batchSize="300" batchTimeout="4000" />        
       </resequence>
      <choice>
        <when>
          <simple>${body} is Foo</simple>
          <bean ref="service" method="save" />
        </when>
        <when>
          <simple>${body.entity} is Bar</simple>
          <bean ref="userservice" method="update" />
        </when>
      </choice>
      <transacted ref="required" />
    </route>

-- 
View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839328.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: example to set priority in message?

Posted by Claus Ibsen <cl...@gmail.com>.
And you most likely need to set preserveMessageQos=true
http://camel.apache.org/jms


On Tue, Sep 14, 2010 at 5:39 PM, Claus Ibsen <cl...@gmail.com> wrote:
> What JMS broker are you using? Not all support JMSPriority.
>
>
> On Tue, Sep 14, 2010 at 5:36 PM, Kannan <ra...@gmail.com> wrote:
>>
>> I tried to set message priory like below mentioned code.  It didn’t work for
>> me.I am not sure what changes still needed to be done.
>>
>>
>> <route errorHandlerRef="deadLetterErrorHandler">
>>      <from ref="queue1" />
>>      <transacted ref="required" />
>>      <convertBodyTo type="com.domain.Message" />
>>      <choice>
>>        <when>
>>          <simple>${body.entity} is Foo</simple>
>>          <setHeader
>> headerName="JMSPriority"><constant>1</constant></setHeader>
>>          <to ref="olapQueue" />
>>        </when>
>>        <when>
>>          <simple>${body.entity} is Bar</simple>
>>          <setHeader
>> headerName="JMSPriority"><constant>2</constant></setHeader>
>>          <to ref="oltpQueue" />
>>        </when>
>>        <otherwise>
>>          <to ref="deadLetterQueue" />
>>        </otherwise>
>>      </choice>
>>    </route>
>>
>>
>>
>> <route errorHandlerRef="deadLetterErrorHandler">
>>      <from ref="queue1" />
>>       <resequence>
>>         <header>JMSPriority</header>
>>         <to uri="mock:result" />
>>         <batch-config batchSize="300" batchTimeout="4000" />
>>       </resequence>
>>      <choice>
>>        <when>
>>          <simple>${body} is Foo</simple>
>>          <bean ref="service" method="save" />
>>        </when>
>>        <when>
>>          <simple>${body.entity} is Bar</simple>
>>          <bean ref="userservice" method="update" />
>>        </when>
>>      </choice>
>>      <transacted ref="required" />
>>    </route>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839328.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: example to set priority in message?

Posted by Kannan <ra...@gmail.com>.
I used custom headers instead of JMSPriority to resequence message based on
custom priority header. where as  the consumer is not consuming  based on
resequence order.

<route errorHandlerRef="deadLetterErrorHandler">
      <from ref="queue1" />
       <resequence>
	   <simple>${header.msgPriority}<simple>  	         
         <to uri="mock:result" />
         <batch-config batchSize="300" batchTimeout="4000" />        
       </resequence>
      <choice>
        <when>
          <simple>${body} is Foo</simple>
          <bean ref="service" method="save" />
        </when>
        <when>
          <simple>${body.entity} is Bar</simple>
          <bean ref="userservice" method="update" />
        </when>
      </choice>
      <transacted ref="required" />
    </route>

-- 
View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839369.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: example to set priority in message?

Posted by Claus Ibsen <cl...@gmail.com>.
A bit info here
http://activemq.apache.org/per-destination-policies.html

The docu will be improved in the near future


On Tue, Sep 14, 2010 at 5:52 PM, Claus Ibsen <cl...@gmail.com> wrote:
> On Tue, Sep 14, 2010 at 5:43 PM, Kannan <ra...@gmail.com> wrote:
>>
>> I am using ActiveMQ 5.4.0
>
> You need to enable priority queues in the config somehow. It just been
> added into AMQ 5.4.0.
>
>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839339.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: example to set priority in message?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Sep 14, 2010 at 5:43 PM, Kannan <ra...@gmail.com> wrote:
>
> I am using ActiveMQ 5.4.0

You need to enable priority queues in the config somehow. It just been
added into AMQ 5.4.0.


> --
> View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839339.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: example to set priority in message?

Posted by Kannan <ra...@gmail.com>.
I am using ActiveMQ 5.4.0
-- 
View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839339.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: example to set priority in message?

Posted by Claus Ibsen <cl...@gmail.com>.
What JMS broker are you using? Not all support JMSPriority.


On Tue, Sep 14, 2010 at 5:36 PM, Kannan <ra...@gmail.com> wrote:
>
> I tried to set message priory like below mentioned code.  It didn’t work for
> me.I am not sure what changes still needed to be done.
>
>
> <route errorHandlerRef="deadLetterErrorHandler">
>      <from ref="queue1" />
>      <transacted ref="required" />
>      <convertBodyTo type="com.domain.Message" />
>      <choice>
>        <when>
>          <simple>${body.entity} is Foo</simple>
>          <setHeader
> headerName="JMSPriority"><constant>1</constant></setHeader>
>          <to ref="olapQueue" />
>        </when>
>        <when>
>          <simple>${body.entity} is Bar</simple>
>          <setHeader
> headerName="JMSPriority"><constant>2</constant></setHeader>
>          <to ref="oltpQueue" />
>        </when>
>        <otherwise>
>          <to ref="deadLetterQueue" />
>        </otherwise>
>      </choice>
>    </route>
>
>
>
> <route errorHandlerRef="deadLetterErrorHandler">
>      <from ref="queue1" />
>       <resequence>
>         <header>JMSPriority</header>
>         <to uri="mock:result" />
>         <batch-config batchSize="300" batchTimeout="4000" />
>       </resequence>
>      <choice>
>        <when>
>          <simple>${body} is Foo</simple>
>          <bean ref="service" method="save" />
>        </when>
>        <when>
>          <simple>${body.entity} is Bar</simple>
>          <bean ref="userservice" method="update" />
>        </when>
>      </choice>
>      <transacted ref="required" />
>    </route>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/example-to-set-priority-in-message-tp2839328p2839328.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus