I followed some examples in camel-jms package but still have problem.
I wrote my camel.xml
beans
xmlns=http://www.springframework.org/schema/beans;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd;
camelContext id=camel xmlns=http://camel.apache.org/schema/spring;
packageScan
packageorg.foo.bar/package
/packageScan
route
from uri=activemq:start/
bean ref=MyBean method=route /
to uri=activemq:finish/
/route
/camelContext
bean id=mybean class=com.testBeans.MyBean /
bean id=activemq
class=org.apache.activemq.camel.component.ActiveMQComponent
property name=connectionFactory
bean class=org.apache.activemq.ActiveMQConnectionFactory
property name=brokerURL
value=vm://localhost?create=falseamp;waitForStart=1 /
property name=userName value=${activemq.username}/
property name=password value=${activemq.password}/
/bean
/property
/bean
/beans
MyBean class still the same in the last post.
I create a class MyBeanTest.java :
public class MyBeanTest extends CamelTestSupport{
protected MockEndpoint resultEndpoint;
protected String componentName = activemq;
protected String startEndpointUri;
@Before
public void setUp() throws Exception {
startEndpointUri = componentName + :start;
super.setUp();
resultEndpoint = (MockEndpoint)
context.getEndpoint(mock:result);
}
protected AbstractXmlApplicationContext createApplicationContext() {
// TODO Auto-generated method stub
return new
ClassPathXmlApplicationContext(ressource/camel.xml);
}
@Test
public void testRoute() throws Exception {
Object requestBody = template.requestBody(startEndpointUri,
toto);
assertEquals(test, requestBody);
}
}
I create the jar and put it in lib directory for activeMQ and I copy the
content of local file camel.xml to the camel.xml in ActiveMQ.
I started ActiveMQ and the unit Test MyBeanTest but I go into an exception:
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: toto]
at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1156)
at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:456)
at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:441)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:119)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:135)
at
org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:283)
at com.testBeans.MyBeanTest.testRoute(MyBeanTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at