You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Andrei Stoica <an...@gmail.com> on 2015/04/03 07:01:13 UTC

Conditional skipping when intercepting message

Hello. It seems that conditional skipping when intercepting a message is not
working anymore. My route is this:

		interceptSendToEndpoint("jms:variableQueue")
		.process(new Processor() {
			
			@Override
			public void process(Exchange exchange) throws Exception {
				
				// Code that puts a property on an echange
			}
		})
		.skipSendToOriginalEndpoint().when(constant(false).isEqualTo(true));

This condition is put for testing means to check if the code forwards the
message. The above code should always forward the exchange but actual it
doesn't.

My actual skip condition is this:
              
.skipSendToOriginalEndpoint().when(exchangeProperty("skip").isEqualTo(true));


Can someone confirm this?



--
View this message in context: http://camel.465427.n5.nabble.com/Conditional-skipping-when-intercepting-message-tp5765255.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Conditional skipping when intercepting message

Posted by Andrei Stoica <an...@gmail.com>.
I forgot to mention. Version that I use is: 2.15.1



--
View this message in context: http://camel.465427.n5.nabble.com/Conditional-skipping-when-intercepting-message-tp5765255p5765267.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Conditional skipping when intercepting message

Posted by Claus Ibsen <cl...@gmail.com>.
What version of Camel do you use?

On Fri, Apr 3, 2015 at 7:01 AM, Andrei Stoica
<an...@gmail.com> wrote:
> Hello. It seems that conditional skipping when intercepting a message is not
> working anymore. My route is this:
>
>                 interceptSendToEndpoint("jms:variableQueue")
>                 .process(new Processor() {
>
>                         @Override
>                         public void process(Exchange exchange) throws Exception {
>
>                                 // Code that puts a property on an echange
>                         }
>                 })
>                 .skipSendToOriginalEndpoint().when(constant(false).isEqualTo(true));
>
> This condition is put for testing means to check if the code forwards the
> message. The above code should always forward the exchange but actual it
> doesn't.
>
> My actual skip condition is this:
>
> .skipSendToOriginalEndpoint().when(exchangeProperty("skip").isEqualTo(true));
>
>
> Can someone confirm this?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Conditional-skipping-when-intercepting-message-tp5765255.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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 skipping when intercepting message

Posted by Andrei Stoica <an...@gmail.com>.
Claus Ibsen-2 wrote
> interceptSendToEndpoint("mock:skippable").skipSendToOriginalEndpoint()
>                         .when(body().isEqualTo("skip")).to("mock:detour");

When does the to() occur? Is it like: all routes are skipped and the ones
that have the body equals to "skip" are sent on the to queue? 

The idea is that I want to set a property on the exchange *before* deciding
if I want to skip it or not.

I found a replacement solution like this:

		interceptSendToEndpoint("jms:variableQueue")
		.process(new Processor() {
			
			@Override
			public void process(Exchange exchange) throws Exception {
				
                                        // set the skip property to true or
false based on the current exchange
					exchange.setProperty("skip", false/true);
					
			}
		})
		.choice()
			.when(exchangeProperty("skip").isEqualTo(true)).stop();

But I'm not using the skipSendToOriginalEndpoint, which is best practice for
what I saw. 



--
View this message in context: http://camel.465427.n5.nabble.com/Conditional-skipping-when-intercepting-message-tp5765255p5765352.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Conditional skipping when intercepting message

Posted by Claus Ibsen <cl...@gmail.com>.
You need the condition before the processor.

such as


interceptSendToEndpoint("mock:skippable").skipSendToOriginalEndpoint()
                        .when(body().isEqualTo("skip")).to("mock:detour");

On Fri, Apr 3, 2015 at 7:01 AM, Andrei Stoica
<an...@gmail.com> wrote:
> Hello. It seems that conditional skipping when intercepting a message is not
> working anymore. My route is this:
>
>                 interceptSendToEndpoint("jms:variableQueue")
>                 .process(new Processor() {
>
>                         @Override
>                         public void process(Exchange exchange) throws Exception {
>
>                                 // Code that puts a property on an echange
>                         }
>                 })
>                 .skipSendToOriginalEndpoint().when(constant(false).isEqualTo(true));
>
> This condition is put for testing means to check if the code forwards the
> message. The above code should always forward the exchange but actual it
> doesn't.
>
> My actual skip condition is this:
>
> .skipSendToOriginalEndpoint().when(exchangeProperty("skip").isEqualTo(true));
>
>
> Can someone confirm this?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Conditional-skipping-when-intercepting-message-tp5765255.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/