activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dr.jeff" <jlans...@systechnologies.com>
Subject Re: [camel] using camel spring container
Date Mon, 30 Apr 2007 17:12:02 GMT

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?


James.Strachan wrote:
> 
> 
> ...
> 
> and see the test case work
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/-camel--using-camel-spring-container-tf3663875s2354.html#a10257108
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message