ActiveMQ Resource Adapter works pretty well with SwitchYard JCA component in both directions - inbound and outbound.
ActiveMQ Resource Adapter
Standard ActiveMQ resource adapter doesn't require any changes. Just download ActiveMQ RAR from maven centaral. I used activemq-rar-5.8.0.rar. After download rename it to activemq-ra.rar, to don't use version specific name and copy it to $AS7/standalone/deployments.
Application Server config
If you plan use inbound connection you don't need admin-object entries. They're necessary when you use outbound connections when JCA Component retrieve destinations from JNDI tree. Thus make sure that all destinations you produce too are listed as administrative objects. Example above shows basic configuration which connects to local ActiveMQ instance at standard port 61616.
<subsystem xmlns="urn:jboss:domain:resource-adapters:1.1"> <resource-adapters> <resource-adapter id="activemq-ra.rar"> <archive> activemq-ra.rar </archive> <connection-definitions> <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/JmsXA" pool-name="QueueConnectionFactory"> <config-property name="ServerUrl"> tcp://127.0.0.1:61616 </config-property> </connection-definition> </connection-definitions> <admin-objects> <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/ShippingQueue" pool-name="ShippingQueue"> <config-property name="PhysicalName"> ShippingQueue </config-property> </admin-object> <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/FillingStockQueue" pool-name="FillingStockQueue"> <config-property name="PhysicalName"> FillingStockQueue </config-property> </admin-object> </admin-objects> </resource-adapter> </resource-adapters> </subsystem>
JCA Component Configuration
Inside your switchyard.xml you need reffer your resource adapter name. If you followed this instruction from begining then the name is activemq-ra.rar. Below you may find configuration examples for both inbound and outbound interaction.
<binding.jca xmlns="urn:switchyard-component-jca:config:1.0"> <operationSelector xmlns="urn:switchyard-config:switchyard:1.0" operationName="process"/> <inboundConnection> <resourceAdapter name="activemq-ra.rar"/> <activationSpec> <property name="destinationType" value="javax.jms.Queue"/> <property name="destination" value="OrderQueue"/> </activationSpec> </inboundConnection> <inboundInteraction> <listener>javax.jms.MessageListener</listener> <endpoint type="org.switchyard.component.jca.endpoint.JMSEndpoint"/> <transacted>true</transacted> </inboundInteraction> </binding.jca>
<binding.jca xmlns="urn:switchyard-component-jca:config:1.0"> <outboundConnection> <resourceAdapter name="activemq-ra.rar"/> <connection jndiName="java:/JmsXA"/> </outboundConnection> <outboundInteraction> <processor type="org.switchyard.component.jca.processor.JMSProcessor"> <property name="messageType" value="Text" /> <property name="destination" value="ShippingQueue"/> </processor> </outboundInteraction> </binding.jca>
Comments