I have a need to run multiple CometD endpoints where I can selectively
dispatch messages to each one based on data in my flow (splitting via
different comet subscriptions isn't sufficient). My plan was to run each
endpoint on it's own port so they wouldn't overlap but as soon as I try and
create a second endpoint I get the following error (this is the root error).

Caused by: java.lang.IllegalStateException: STARTED
at
org.eclipse.jetty.server.handler.HandlerWrapper.setHandler(HandlerWrapper.java:70)
at
org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:131)
at
org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:99)
at
org.apache.camel.component.cometd.CometdComponent.createServletForConnector(CometdComponent.java:162)
at
org.apache.camel.component.cometd.CometdComponent.connect(CometdComponent.java:115)
at
org.apache.camel.component.cometd.CometdEndpoint.connect(CometdEndpoint.java:67)
at
org.apache.camel.component.cometd.CometdProducer.start(CometdProducer.java:48)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:378)
... 98 more

I suspect it has to do with the fact the cometd component starts it's own
Jetty server and something about the Jetty servers isn't unique. Below is
the config I used to recreate the problem.

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
           xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"; xmlns:cxf="
http://cxf.apache.org/blueprint/core";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs";
           xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf";
           xmlns:camel="http://camel.apache.org/schema/blueprint";
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint/cxf
http://camel.apache.org/schema/blueprint/cxf/camel-cxf-2.8.3.xsd
             http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint-2.8.3.xsd
             http://cxf.apache.org/blueprint/jaxws
http://cxf.apache.org/schemas/blueprint/jaxws.xsd
             http://cxf.apache.org/blueprint/core
http://cxf.apache.org/schemas/blueprint/core.xsd
             http://cxf.apache.org/blueprint/jaxrs
http://cxf.apache.org/schemas/blueprint/jaxrs.xsd";
           default-activation="lazy">

    <camel:camelContext id="cometd-test-route">
        <camel:route>
            <camel:from uri="direct:start"/>
            <camel:filter>
                <camel:simple>${in.headers.ClientID} == 5</camel:simple>
                <camel:to uri="cometd://0.0.0.0:8082/events?baseResource=
."/>
            </camel:filter>
        </camel:route>

        <camel:route>
            <camel:from uri="direct:start"/>
            <camel:filter>
                <camel:simple>${in.headers.ClientID} == 4</camel:simple>
                <camel:to uri="cometd://0.0.0.0:8083/events?baseResource=
."/>
            </camel:filter>
        </camel:route>
    </camel:camelContext>
</blueprint>


If you comment out the second route it all works like a champ. Any help
would be appreciated.

Thanks,
Chris

Reply via email to