Hi,
>> I have a use case where I want to drop certain messages where the body
>> is null (or conversely I want to process messages where the body is
>> not null)
>>
>> I have the following config
>>
>> public static class ContextConfig extends RouteBuilder {
>>
>> �...@override
>> public void configure() {
>> from("direct:start").split(body(String.class).tokenize("\n"))
>> .bean(Unmarshaller.class).filter(
>> body().isNotNull())
>> .to("mock:result");
>>
>> }
>> }
>>
>> The Unmarshaller returns either a valid object or null, it is a POJO
>> and has no knowledge of Camel (and I want to keep it that way so I
>> don't want to change the code to inject a value into the header).
>>
> Always remember to write version number used.
Sorry 2.1 in this case
>
> I have looked into it and discovered a bug in the camel bean component.
> https://issues.apache.org/activemq/browse/CAMEL-2436
>
> Will be fixed in the next 2.2 release.
I managed to get a workaround working:
public static class ContextConfig extends RouteBuilder {
@Override
public void configure() {
from("direct:start").split(body(String.class).tokenize("\n"))
.bean(Unmarshaller.class)
.filter(body().convertTo(Bean.class).isNotNull())
.to("mock:result");
}
}
Without the convertTo(), camel seemed to automatically generate a
non-null message
Thanks,
Kev