You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jack <jr...@gmail.com> on 2014/04/28 19:42:08 UTC

conditional route without dequeuing all messages

Hi,

I¹m looking for a way to divert messages to an alternative queue based on an
expression.
I was hoping to use the choice mechanism for this. Something like:

<choice>
<when>
<simple>'10' &gt; ${in.body}</simple>
<to uri=³activemq:move.somewhere.else" />
</when>
</choice>

The problem with this approach is that all the messages that aren¹t matched
by the condition will get dropped.

Does anyone know a way I can filter off messages and leave the remaining
messages on the queue to be consumed by something else?
I¹ve scoured the docs but can¹t find anything that I can see will work.

Thanks for any help in advance!

- Jack




Re: conditional route without dequeuing all messages

Posted by "kraythe ." <kr...@gmail.com>.
Using selectors, I believe, will only cause the message to not be consumed
by anyone, not put back on the queue. If this is really necessary (and Id
like to see a use case), then the i'd try an idimpotent consumer and
putting the message back on the queue yourself in an otherwise clause.

Of course, most of the time people are trying to do this it means that the
design is wrong. If there are multiple consumers of different types of
messages on one queue, its best to create a route that sorts the messages
to destinations so as to create a typed channel that has their own
consumers. In the case where something is truly broadcast then I would
route the messages to a topic where the consumers can make thier own
decisions about the messages without affecting others.

The question is what is your use case for doing this Jack?

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Tue, Apr 29, 2014 at 1:41 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> You can use jms message selectors to filter only wanted messages.
> You set these on the jms endpoint.
>
> On Mon, Apr 28, 2014 at 7:42 PM, Jack <jr...@gmail.com> wrote:
> > Hi,
> >
> > I¹m looking for a way to divert messages to an alternative queue based
> on an
> > expression.
> > I was hoping to use the choice mechanism for this. Something like:
> >
> > <choice>
> > <when>
> > <simple>'10' &gt; ${in.body}</simple>
> > <to uri=³activemq:move.somewhere.else" />
> > </when>
> > </choice>
> >
> > The problem with this approach is that all the messages that aren¹t
> matched
> > by the condition will get dropped.
> >
> > Does anyone know a way I can filter off messages and leave the remaining
> > messages on the queue to be consumed by something else?
> > I¹ve scoured the docs but can¹t find anything that I can see will work.
> >
> > Thanks for any help in advance!
> >
> > - Jack
> >
> >
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>

Re: conditional route without dequeuing all messages

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use jms message selectors to filter only wanted messages.
You set these on the jms endpoint.

On Mon, Apr 28, 2014 at 7:42 PM, Jack <jr...@gmail.com> wrote:
> Hi,
>
> I¹m looking for a way to divert messages to an alternative queue based on an
> expression.
> I was hoping to use the choice mechanism for this. Something like:
>
> <choice>
> <when>
> <simple>'10' &gt; ${in.body}</simple>
> <to uri=³activemq:move.somewhere.else" />
> </when>
> </choice>
>
> The problem with this approach is that all the messages that aren¹t matched
> by the condition will get dropped.
>
> Does anyone know a way I can filter off messages and leave the remaining
> messages on the queue to be consumed by something else?
> I¹ve scoured the docs but can¹t find anything that I can see will work.
>
> Thanks for any help in advance!
>
> - Jack
>
>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/