You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org> on 2011/11/09 12:40:51 UTC
[jira] [Commented] (CAMEL-4650) NPE when using SEDA route and
attaching an extra consumer
[ https://issues.apache.org/jira/browse/CAMEL-4650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13146956#comment-13146956 ]
Babak Vahdat commented on CAMEL-4650:
-------------------------------------
I did a typo in the user forum about the condition which holds, causing the NPE. Correctly it's:
{code}
multicastStarted == true || consumerMulticastProcessor == null
{code}
Looking at SedaConsumer.sendToConsumers() it's:
{code}
protected void sendToConsumers(Exchange exchange) throws Exception {
int size = endpoint.getConsumers().size();
// if there are multiple consumers then multicast to them
if (size > 1) {
if (LOG.isDebugEnabled()) {
LOG.debug("Multicasting to {} consumers for Exchange: {}", endpoint.getConsumers().size(), exchange);
}
// 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 {
// use the regular processor and use the asynchronous routing engine to support it
AsyncProcessorHelper.process(processor, exchange, new AsyncCallback() {
public void done(boolean doneSync) {
// noop
}
});
}
}
{code}
Which as you see does call:
{code}
endpoint.getConsumerMulticastProcessor();
{code}
But doesn't take into the account that the returned reference (of type MulticastProcessor) could be null. In your case it *was* null, as apparently the condition I mentioned in user forum holds.
I would love to provide a patch for this, but the SedaEndpoint is to me one of those non-trivial camel's endpoint (concurrency was / is never trivial :-().
If some camel riders could give me a hint, I would assign the ticket to myself and would provide a patch (including a unit-test) proving the fix.
> NPE when using SEDA route and attaching an extra consumer
> ---------------------------------------------------------
>
> Key: CAMEL-4650
> URL: https://issues.apache.org/jira/browse/CAMEL-4650
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.8.2
> Environment: Java 6, Camel 2.8.2, Centos 4.
> Reporter: Tarjei Huse
>
> I'm trying to construct a system for moving some seda queues over to
> ActiveMQ during system shutdown. What I did was create a Route that
> connects to some of my seda queues and then drains the queue to activemq.
> Basicly I got two routes, the drainer:
> from("seda:" + sedaId + "?size=1000")
> .routeId(routeName +
> sedaIs).noAutoStartup().to(activeMQFailuresQueue);
> And the main route:
> from("seda:" + sedaId + "?size=1000")
> .routeId(routeName + sedaIs).to(SomeProcessor);
> Now, sometimes the main route stalls for various reasons I need to
> restart the jvm process it is running in, so I start the first route.
> But when trying this in production, I got:
> java.lang.NullPointerException
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
> at
> org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:210)
> at
> org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:155)
> at
> org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:129)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:619)
> Bvahdat added a comment:
> just a very tiny pointer:
> Looking at the source it seems that the
> SedaEndpoint.getConsumerMulticastProcessor() method returns 'null' causing
> the NPE, as the condition:
> multicastStarted == false || consumerMulticastProcessor == null
> is true.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira