You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jonathanq <jq...@abebooks.com> on 2009/10/17 01:37:16 UTC

Best way to throw away an exchange in a route in an otherwise() case

I apologize if this is a simple question - but I just need to be sure!

I am developing this route that handles multiple message types and uses a
"when()" predicate to send the message to the appropriate processor based on
a header value.  In the "Otherwise" case I want to send it to an unknown
format processor to log the error but I don't want the exchange to continue
from there (as there is further processing that needs to only occur on a
valid message).

Here is the route:

from("direct:incoming")
            .choice()
              .when(header("status").isEqualTo("1"))
                .process(status1processor)
              .when(header("status").isEqualTo("2))
                .process(status2processor)
              .otherwise().process(unknownstatusprocessor)
            .end()
            .process(someOtherProcessor)
            .to("mock:outgoing);

Now - I thought of just putting:

.otherwise().process(unknownstatusprocessor).to("mock:garbage")

The main concern I have is that I want this "garbage" endpoint to be
something we can use in our live environment.  I am not sure if "mock" is
wise.  I thought of "direct:garbage" - but as I understand it - that is an
"in memory queue" essentially.  And I don't want it to ever fill up if
exchanges just sit there unprocessed.

I just want to make sure that whatever endpoint I use - it truly is a
"garbage can".  We just want to log the information and get rid of the
message.  Am I over thinking the behavior of "mock" and it will just be the
black hole I am looking for?

Thanks for the help!
-- 
View this message in context: http://www.nabble.com/Best-way-to-throw-away-an-exchange-in-a-route-in-an-otherwise%28%29-case-tp25933807p25933807.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Best way to throw away an exchange in a route in an otherwise() case

Posted by jonathanq <jq...@abebooks.com>.


Claus Ibsen-2 wrote:
> 
> 
> Yeah stop() is the right way to do so. Its also easy to understand
> what it does :)
> 
> The message filter is another way (a more classic EIP solution)
> http://camel.apache.org/message-filter.html
> 
> 

I had wondered about the filter - but I didn't know what happened to
exchanges that failed the filter.  The incoming endpoint will be a JMS
messaging queue - so I didn't want to take a chance that a message failing
the filter would go back on the queue, or get sent to any deadletter queues.

But if an exchanging failing a filter is simply thrown away just like a
.stop() - then it would also work.  Just depends on what feels more natural
in our route.

Thanks for the help!
-- 
View this message in context: http://www.nabble.com/Best-way-to-throw-away-an-exchange-in-a-route-in-an-otherwise%28%29-case-tp25933807p25960512.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Best way to throw away an exchange in a route in an otherwise() case

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Oct 17, 2009 at 2:02 AM, jonathanq <jq...@abebooks.com> wrote:
>
> I think I found the solution in the documentation (that's what I get for
> finally posting a question - never fails I will find the answer 10 minutes
> later).
>
> This is waht I have now:
>
> from("direct:incoming")
>            .choice()
>              .when(header("status").isEqualTo("1"))
>                .process(status1processor)
>              .when(header("status").isEqualTo("2))
>                .process(status2processor)
>              .otherwise().process(unknownstatusprocessor).stop()
>            .end()
>            .process(someOtherProcessor)
>            .to("mock:outgoing);
>
> Specifically - I added the .stop() to the otherwise() path.
>
> .otherwise().process(getUnknownEmailStatusProcessor()).stop()
>
> Is that the correct way to do it?  My unit tests seem to say so..but I
> wanted to ask the experts to be sure.

Yeah stop() is the right way to do so. Its also easy to understand
what it does :)

The message filter is another way (a more classic EIP solution)
http://camel.apache.org/message-filter.html


> --
> View this message in context: http://www.nabble.com/Best-way-to-throw-away-an-exchange-in-a-route-in-an-otherwise%28%29-case-tp25933807p25933965.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Best way to throw away an exchange in a route in an otherwise() case

Posted by jonathanq <jq...@abebooks.com>.
I think I found the solution in the documentation (that's what I get for
finally posting a question - never fails I will find the answer 10 minutes
later).

This is waht I have now:

from("direct:incoming")
            .choice()
              .when(header("status").isEqualTo("1"))
                .process(status1processor)
              .when(header("status").isEqualTo("2))
                .process(status2processor)
              .otherwise().process(unknownstatusprocessor).stop()
            .end()
            .process(someOtherProcessor)
            .to("mock:outgoing);

Specifically - I added the .stop() to the otherwise() path. 

.otherwise().process(getUnknownEmailStatusProcessor()).stop()

Is that the correct way to do it?  My unit tests seem to say so..but I
wanted to ask the experts to be sure.
-- 
View this message in context: http://www.nabble.com/Best-way-to-throw-away-an-exchange-in-a-route-in-an-otherwise%28%29-case-tp25933807p25933965.html
Sent from the Camel - Users mailing list archive at Nabble.com.