On Thu, Dec 15, 2011 at 8:18 AM, Christian Schneider <ch...@die-schneider.net> wrote: > This also hit me some times before. Perhaps we can improve the error > message. >
I guess we could improve the DirectProducer as it would know its tied to only work inside the same CamelContext as its consumer. So the DirectProducer could indeed check that the CamelContext must be in started mode to operate. Likewise the Producer itself should frankly be started also. But some producers can run without being started prior, and Camel have been forgiving about this. However we have improved the startup logic in the routing engine, so all producers etc. ought to be started as well, so for Camel 3.0 we could possible add more strict checking that a Producer must be in started mode, to be able to process an Exchange. However as Willem said, he is using low level API, and thus he must ensure to read the javadoc of the methods, and start the producer/endpoint/components manually. As he is handling their lifecycle. > Christian > > Am 15.12.2011 08:14, schrieb Claus Ibsen: > >> You need to start the CamelContext before you send a message to it. >> Invoke .start() on the camel instance. >> >> >> On Thu, Dec 15, 2011 at 8:11 AM, xiangqiuzhao<xiangqiuz...@gmail.com> >> wrote: >>> >>> MQQueueConnectionFactory cf = new MQQueueConnectionFactory(); >>> JmsConfiguration jc = new JmsConfiguration(cf); >>> >>> cf.setHostName("172.16.16.136"); >>> cf.setPort(1416); >>> cf.setQueueManager("QM2"); >>> cf.setChannel("BTOA"); >>> cf.setTransportType(1); >>> >>> JmsComponent ibmmq = new JmsComponent(jc); >>> ibmmq.setAcknowledgementModeName("AUTO_ACKNOWLEDGE"); >>> >>> CamelContext camel = new DefaultCamelContext(); >>> camel.addComponent("ibmmq", ibmmq); >>> >>> camel.addRoutes(new RouteBuilder() { >>> public void configure() { >>> from("direct:test").to("ibmmq:QRB"); >>> } >>> }); >>> >>> Endpoint endpoint = camel.getEndpoint("direct:test"); >>> Exchange exchange = endpoint.createExchange(); >>> String data = "send something"; >>> Producer producer = endpoint.createProducer(); >>> exchange.getIn().setBody(data); >>> producer.process(exchange); >>> System.out.println(new >>> String((byte[])exchange.getOut().getBody())); >>> >>> >>> Exception in thread "main" org.apache.camel.CamelExchangeException: No >>> consumers available on endpoint: Endpoint[direct://test]. >>> Exchange[Message: >>> send something] >>> at >>> >>> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:46) >>> at >>> com.sunyard.camel.TestJmsComponent.main(TestJmsComponent.java:51) >>> >>> >>> where is wrong in my program? >>> >>> -- >>> View this message in context: >>> http://camel.465427.n5.nabble.com/No-consumers-available-on-endpoint-exception-tp5076708p5076708.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> > > > -- > > Christian Schneider > http://www.liquid-reality.de > > Open Source Architect > Talend Application Integration Division http://www.talend.com > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/