DSL Route to a HornetQ queue
atgnatus Nov 29, 2011 8:23 PMHi,
I am trying to use a Camel Service to route to another service using a HornetQ queue but I'm getting an error when I invoke the service.
I was originally trying to ".to("jms:myqueue")" but got:
3-1322605936244-1-1. Exhausted after delivery attempt: 1 caught: java.lang.IllegalArgumentException: connectionFactory must be specified: java.lang.IllegalArgumentException: connectionFactory must be specified
I tried .to("jms:myqueue?connectionFactory=InVmConnectionFactory") but that failed because it could not convert from String to javax.jms.ConnectionFactory.
I googled around and saw what looked like a switchyard variant:
.to("hornetq:myqueue?transportConfiguration=#transportConfigBean")
But I did not see how to configure the transportConfiguration. The docs said:
<bean id="transportConfigBean" class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg value="org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"/>
</bean>
but I couldn't get that to work.
What is the correct approach?
BTW, my goal is to use a Camel Service to route to another service asynchronously. Is this the correct way to do that?
Thanks!
Chris
My DSL bean:
package com.example.switchyard.routerTest;
import org.apache.camel.builder.RouteBuilder;
import org.switchyard.component.camel.Route;
@Route(Router.class)
public class RouterBean extends RouteBuilder {
public void configure() {
from("switchyard://Router")
.log("+++ Message received in RouterBean Route")
.log("${body}")
.to("hornetq:GreetingServiceQueue?transportConfiguration=#transportConfigBean")
.to("switchyard://SinkTwo");
}
}
My switchyard.xml:
<?xml version="1.0" encoding="UTF-8"?>
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" name="routerTest" targetNamespace="urn:com.example.switchyard:routerTest:0.0.1-SNAPSHOT">
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="routerTest" targetNamespace="urn:com.example.switchyard:routerTest:0.0.1-SNAPSHOT">
<service name="SinkOne" promote="SinkOne">
<hornetq:binding.hornetq xmlns:hornetq="urn:switchyard-component-hornetq:config:1.0">
<hornetq:operationSelector operationName="processData"/>
<hornetq:config>
<hornetq:connector>
<hornetq:factoryClass>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</hornetq:factoryClass>
</hornetq:connector>
<hornetq:queue>jms.queue.GreetingServiceQueue</hornetq:queue>
</hornetq:config>
</hornetq:binding.hornetq>
</service>
<component name="RouterBean">
<implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">
<java class="com.example.switchyard.routerTest.RouterBean"/>
</implementation.camel>
<service name="Router">
<interface.java interface="com.example.switchyard.routerTest.Router"/>
</service>
<reference name="SinkOne">
<interface.java interface="com.example.switchyard.routerTest.SinkOne"/>
</reference>
<reference name="SinkTwo">
<interface.java interface="com.example.switchyard.routerTest.SinkTwo"/>
</reference>
</component>
<component name="SinkOne">
<implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.example.switchyard.routerTest.SinkOneBean"/>
<service name="SinkOne">
<interface.java interface="com.example.switchyard.routerTest.SinkOne"/>
</service>
</component>
<component name="SinkTwo">
<implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.example.switchyard.routerTest.SinkTwoBean"/>
<service name="SinkTwo">
<interface.java interface="com.example.switchyard.routerTest.SinkTwo"/>
</service>
</component>
<component name="Source">
<implementation.bean xmlns="urn:switchyard-component-bean:config:1.0" class="com.example.switchyard.routerTest.SourceBean"/>
<service name="Source">
<interface.java interface="com.example.switchyard.routerTest.Source"/>
</service>
<reference name="Router">
<interface.java interface="com.example.switchyard.routerTest.Router"/>
</reference>
</component>
</composite>
</switchyard>