Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Last active December 9, 2016 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeltuelho/3caa128578250ecf4d34 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/3caa128578250ecf4d34 to your computer and use it in GitHub Desktop.
Testing Messaging in JBoss Fuse and ActiveMQ with Camel Routes
  • configure an embedded local Messaging Broker
  <!-- This creates an embedded ActiveMQ Broker -->
  <broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" persistent="false">
    <transportConnectors>
      <transportConnector uri="tcp://localhost:61616" />
    </transportConnectors>
  </broker>

  <!-- Lets connect the Camel ActiveMQ component to the embedded broker.
       See http://camel.apache.org/activemq.html for more information.
  -->
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="failover:tcp://localhost:61616"/>
  </bean>
  • configure an inMemory (JVM) Messaging Broker
  <!-- Configure an inVM ActiveMQ Broker for test purposes -->
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
     <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
  </bean>
  • a sample Camel route using the activemq component endpoint
  <camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="file:src/data?noop=true"/>
    <to uri="activemq:personnel.records"/>
  </route>
  <route>
    <from uri="activemq:personnel.records"/>
    <choice>
      <when>
        <xpath>/person/city = 'London'</xpath>
        <to uri="file:target/messages/uk"/>
      </when>
      <otherwise>
        <to uri="file:target/messages/others"/>
      </otherwise>
    </choice>
  </route>
</camelContext>
@rafaeltuelho
Copy link
Author

rafaeltuelho commented Apr 14, 2015

to use the ActiveMQ Messagin Broker in you Camel Project you have to add the following maven dep:

    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-camel</artifactId>
      <version>${activemq.camel.version}</version>
    </dependency>

	    <!-- embed ActiveMQ broker -->
	    <dependency>
	      <groupId>org.apache.activemq</groupId>
	      <artifactId>activemq-broker</artifactId>
	    </dependency>
	    <!-- 
	    <dependency>
	      <groupId>org.apache.activemq</groupId>
	      <artifactId>activemq-spring</artifactId>
	    </dependency>
	    -->
	    <dependency>
	      <groupId>org.apache.activemq</groupId>
	      <artifactId>activemq-kahadb-store</artifactId>
	    </dependency>	
	    <!-- ActiveMQ client -->
	    <dependency>
	      <groupId>org.apache.activemq</groupId>
	      <artifactId>activemq-client</artifactId>
	    </dependency>
	    <dependency>
	      <groupId>org.apache.activemq</groupId>
	      <artifactId>activemq-pool</artifactId>
	    </dependency>
	    <!--	    
        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-spring</artifactId>
        </dependency>
        -->
		<!-- https://mvnrepository.com/artifact/org.apache.xbean/xbean-blueprint -->
		<dependency>
		    <groupId>org.apache.xbean</groupId>
		    <artifactId>xbean-blueprint</artifactId>
		</dependency>
        <!-- -->
		<!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-blueprint -->
		<dependency>
		    <groupId>org.apache.activemq</groupId>
		    <artifactId>activemq-blueprint</artifactId>
		    <version>5.11.0.redhat-630187</version>
		</dependency>
		

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment