You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Xavier Coulon <xc...@gmail.com> on 2011/03/15 11:32:55 UTC
NullPointerException in SedaConsumer
Hello,
I'm trying to use an unmarshaller within a route that starts from a seda
endpoint:
from("seda:incoming.stocks")
.unmarshal(stockUnmarshaller)
.to("jpa:stock.domain.IntegrationStock?usePersist=true");
Basically, this endpoint consumes XML messages in a custom format and uses a
custom dataformat to unmarshal the xml input into a Java object that will be
persisted in database just after. For internal reasons, we don't use JAXB,
hence the custom dataformat 'stockUnmarshaller' here.
In the log console, I have the following error messages for each 'stock'
message:
Digging into the SedaEnpoint code, I found this:
protected synchronized MulticastProcessor getConsumerMulticastProcessor()
throws Exception {
if (!multicastStarted && consumerMulticastProcessor != null) {
// only start it on-demand to avoid starting it during stopping
ServiceHelper.startService(consumerMulticastProcessor);
multicastStarted = true;
}
return consumerMulticastProcessor;
}
In my case, the 'if' block is not executed because the
consumerMulticastProcessor is null. Thus, the return value is null too.
In the SedaConsumer class:
protected void sendToConsumers(Exchange exchange) throws Exception {
int size = endpoint.getConsumers().size();
// if there are multiple consumers then multicast to them
if (size > 1) {
// use a multicast processor to process it
MulticastProcessor mp = endpoint.getConsumerMulticastProcessor();
// and use the asynchronous routing engine to support it
AsyncProcessorHelper.process(mp, exchange, new AsyncCallback() {
public void done(boolean doneSync) {
// noop
}
});
} else {
...
}
}
the MulticastProcessor 'mp' is null, and the AsyncProcessorHelper.process()
method throws a NullPointerException.
How can I avoid this ?
Thank you in advance
Regards,
/Xavier
--
View this message in context: http://camel.465427.n5.nabble.com/NullPointerException-in-SedaConsumer-tp3696144p3696144.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: NullPointerException in SedaConsumer
Posted by Xavier Coulon <xc...@gmail.com>.
Ooops, it was to be my entire fault :-/
I my test case, I had the following MockEndpoint declaration:
from("seda:incoming.stocks").to(mockStocks);
With that extra endpoint consumer, the result of
endpoint.getConsumers().size() in the SedaEndpoint.sendToConsumers(..)
method was 2 and not 1, hence the attempt to use a MultiCastProcessor.
Sorry...
/xavier
--
View this message in context: http://camel.465427.n5.nabble.com/NullPointerException-in-SedaConsumer-tp3696144p3696766.html
Sent from the Camel - Users mailing list archive at Nabble.com.