Search code examples
apache-camelblueprint-osgicamel-jms

Setup independent ActiveMQ broker in camel blueprint xml


I am setting up a ServieMix instance using apache-camel as the routing engine, with my routes defined in a blueprint.xml. I am trying to configure ActiveMQ for my blueprint to be completely isolated from anything else (use its own, private, broker).

Here is my camel blueprint XML

<?xml version="1.0" encoding="UTF-8"?>
<blueprint 
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
>

    <bean id="record_ip" class="my.service.RecordIP"/>

    <bean id="jmsConnectionFactory" 
       class="org.apache.activemq.ActiveMQConnectionFactory">
       <property name="brokerURL" value="vm://myBroker?create=true&amp;waitForStart=10000" />
       <property name="userName" value="shadow"/>
       <property name="password" value="broker"/>
    </bean>

    <bean id="pooledConnectionFactory" 
       class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
       <property name="maxConnections" value="8" />
       <property name="connectionFactory" ref="jmsConnectionFactory" />
    </bean>

    <bean id="jmsConfig" 
       class="org.apache.camel.component.jms.JmsConfiguration">
       <property name="connectionFactory" ref="pooledConnectionFactory"/>
       <property name="concurrentConsumers" value="10"/>
    </bean>

    <bean id="activemq" 
        class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="configuration" ref="jmsConfig"/>
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">

      <route id="tracing_route">
        <from uri="jetty:http://localhost:9696/trace"/>
        <inOnly uri="activemq:queue:ip_capture"/>
      </route>

      <route id="ip_capture">
        <from uri="activemq:queue:ip_capture?concurrentConsumers=1&amp;maxConcurrentConsumers=64&amp;maxMessagesPerTask=100"/>
        <bean ref="record_ip"/>
        <log message="Finished!" loggingLevel="WARN" />
      </route>
    </camelContext>

</blueprint>

I don't think it's using the setup at all because I get the following error

Could not refresh JMS Connection for destination 'ip_capture' - retrying in 5000 ms. Cause: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Broker named 'amq-broker' does not exist.

And amq-broker is the default broker.

I'm pouring through everything I can find but something important is missing

I am using

  • ServiceMix 7.0.0
  • apache-camel/camel-blueprint 2.16.4
  • activemq-client/camel/blueprint 5.14.3

So long story sort, How do I properly configure ActiveMQ for my blueprint to be completely isolated from anything else?


Solution

  • I ended up not really needing to do this, because for all intents and purposes, the broker is independent, and setting up a new one doesn't change anything.