Jonas Byström
Jonas Byström

Reputation: 26169

Apache Camel: keeping filtered messages

Say I have a queue containing the messages A, A, B, A, B, A. I'd like to log+drop all B messages, but I'd like to keep all A messages untouched. So basically I need some type of ignore functionality, rather than a discarding filter.

If that's not available I probably need to do something similar to:

from("jms:queue:from")
    .filter(header("head").isEqualTo("B")).to("log:com.acme?level=INFO").end()
    .to("jms:queue:from");

This type of thing seems like a fairly common pattern? How do people usually do this type of thing?

Upvotes: 0

Views: 307

Answers (1)

sanbhat
sanbhat

Reputation: 17622

I think choice is a better option than filter

    from("jms:queue:from")
    .choice()
        .when(header("head").isEqualTo("B")).to("log:com.acme?level=INFO")
        .otherwise().to("jms:queue:from")
    .end()

Upvotes: 2

Related Questions