activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: [camel] using camel spring container
Date Tue, 01 May 2007 09:01:01 GMT
BTW I've created a little test case for this kinda use case...

https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingProcessor.xml

https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java


On 4/30/07, dr.jeff <jlansing@systechnologies.com> wrote:
>
> My xml looks like this:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
>        http://www.springframework.org/schema/beans ./spring-beans-2.0.xsd
>        http://activemq.apache.org/camel/schema/camel-1.0.xsd ./camel-1.0.xsd
> ">
>   <bean id="stringProcessor" class="test.StringProcessor"
> init-method="init"/>
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
>     <routes>
>       <route>
>         <from uri="direct:outgoing"/>
>         <process ref="#stringProcessor"/>
>       </route>
>     </routes>
>   </camelContext>
> </beans>
>
> StringProcessor.java looks like this:
>
> public class StringProcessor implements Processor<Exchange> {
>
>         public StringProcessor() {
>         }
>         public void init() {
>                 System.out.println("new string processor");
>         }
>         public void process(Exchange e) {
>                 System.out.println("process: " + e.getIn());
>         }
> }
>
> I call it like this:
>
>         public TestSimpleXml(String ctxFile) {
>                 ctx = new ClassPathXmlApplicationContext(ctxFile);
>                 try {
>                         container = (CamelContext) ctx.getBean("camel");
>                         Endpoint<Exchange> endpoint = container.getEndpoint("direct:incoming");
>                         Exchange exchange = endpoint.createExchange();
>                 Message m = exchange.getIn();
>                 m.setBody("test message");
>                 Producer<Exchange> producer = endpoint.createProducer();
>                 producer.process(exchange);
>                 Thread.sleep(5000); //let queues clean out
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                 }
>         }
>
> I see that the init() method of StringProcessor is being called. I expect to
> see the message reach the process() method, but I do not.
>
> This seems so simple. Am I still missing something?

You're using 2 different URIs...

* direct:outgoing
* direct:incoming

shouldn't they be the same? :)

(I've started to use direct:start everywhere as the first entry point
to a test case to avoid myself getting confused :)

-- 
James
-------
http://macstrac.blogspot.com/

Mime
View raw message