Reputation:
I have something where I basically always want to lose the first record in a list. It will always be of the form List<String> - and I don't care about the 'header' - which will always be the first element in the list and don't want it sent to my endpoint
[ "header", "message1", "message2" ... ]
.from( A ) // this sends Lists of StringBuffers. The first in the list will be header
.split().body() // now I have each
.to( B )
I would ideally like to lose the first message in the exchange and am thinking about the correct query to construct for it.
Something like ( this doesn't work - removeMessage isn't an camel option )
from( A )
.removeMessage( 0 ) // remove first message - this doesn't actually exist
.split().body().
.to( B )
I am looking at creating a filter which removes based on the CamelSplitIndex attribute on the exchange, but have at this point stopped and am wondering 'am I going about this the right way?'
Upvotes: 1
Views: 2862
Reputation:
I did it pretty much as I suggested, and similar to what the other guy suggested, but without using the Simple expression language, which (ironically) seems simpler to me
.split().body() .filter( header( "CamelSplitIndex" ).isNotEqual( 0 ) )
Upvotes: 1
Reputation: 22279
As you state, this seems like a good example of a mix of splitter and filter EIPs.
Something like this might be what you need.
from(A)
.split().body()
.filter().simple("${property.CamelSplitIndex} > 0")
.to(B);
There are several ways to handle this, but don't overcomplicate it if you can use basic EIPs like this.
You are always free to plug in some Java and if that serves the purpose, do it.
Upvotes: 0