Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 48842 invoked from network); 19 Jun 2008 17:07:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jun 2008 17:07:39 -0000 Received: (qmail 2731 invoked by uid 500); 19 Jun 2008 17:07:41 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 2714 invoked by uid 500); 19 Jun 2008 17:07:41 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 2702 invoked by uid 99); 19 Jun 2008 17:07:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jun 2008 10:07:41 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [62.75.158.78] (HELO mail.liquid-reality.de) (62.75.158.78) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jun 2008 17:06:50 +0000 Received: from [10.0.0.10] (HSI-KBW-085-216-027-031.hsi.kabelbw.de [85.216.27.31]) by mail.liquid-reality.de (Postfix) with ESMTP id CD6552420008 for ; Thu, 19 Jun 2008 17:07:06 +0000 (UTC) Message-ID: <485A9242.7050005@die-schneider.net> Date: Thu, 19 Jun 2008 19:07:14 +0200 From: Christian Schneider User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: camel-user@activemq.apache.org Subject: Re: Putting several services on the same queue References: <48538395.3060301@die-schneider.net> <4855B337.6000801@gmail.com> <48560765.8070209@die-schneider.net> <48561164.8000807@gmail.com> In-Reply-To: <48561164.8000807@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have set up an example for routing from a jms endpoint to a cxf endpoint using the camel transport in cxf. To test the service I am using a normal cxf client on the jms queue. When I run my test I get an exception. It seems the unmarshal method tries to convert the incoming message to either TextMessage, BytesMessage or ObjectMessage. As the class ActiveMqMessage is none of these it does not work. Any idea why this happens? I have attached the exception, my log, the java code and the cxf config. java.lang.ClassCastException: org.apache.activemq.command.ActiveMQMessage cannot be cast to javax.jms.ObjectMessage at org.apache.cxf.transport.jms.JMSTransportBase.unmarshal(JMSTransportBase.java:125) at org.apache.cxf.transport.jms.JMSConduit.receive(JMSConduit.java:162) at org.apache.cxf.transport.jms.JMSConduit.access$100(JMSConduit.java:55) at org.apache.cxf.transport.jms.JMSConduit$JMSOutputStream.handleResponse(JMSConduit.java:366) at org.apache.cxf.transport.jms.JMSConduit$JMSOutputStream.doClose(JMSConduit.java:258) at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:156) at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47) at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:159) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:177) at $Proxy36.echo(Unknown Source) at JmsToCXF.run(JmsToCXF.java:125) at JmsToCXF.main(JmsToCXF.java:136) ----- import java.util.Arrays; import javax.jms.ConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.cxf.HelloService; import org.apache.camel.component.cxf.HelloServiceImpl; import org.apache.camel.component.cxf.transport.CamelTransportFactory; import org.apache.camel.component.jms.JmsComponent; import org.apache.camel.impl.DefaultCamelContext; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.bus.spring.SpringBusFactory; import org.apache.cxf.endpoint.ServerImpl; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.apache.cxf.transport.ConduitInitiatorManager; import org.apache.cxf.transport.DestinationFactoryManager; /** * An example class for demonstrating some of the basics behind camel This * example will send some text messages on to a JMS Queue, consume them and * persist them to disk * * @version $Revision: 529902 $ */ public final class JmsToCXF { private JmsToCXF() { } /** * @return * @throws Exception */ private CamelContext createCamel() throws Exception { CamelContext context = new DefaultCamelContext(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); context.addRoutes(new RouteBuilder() { public void configure() { from("test-jms:queue:test") .to("direct:test"); } }); return context; } public void createCXFBus(CamelContext context) { //setup the camel transport for the bus Bus bus = new SpringBusFactory().createBus("cxf.xml"); CamelTransportFactory camelTransportFactory = new CamelTransportFactory(); camelTransportFactory.setCamelContext(context); camelTransportFactory.setBus(bus); // register the conduit initiator ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class); cim.registerConduitInitiator(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory); // register the destination factory DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); dfm.registerDestinationFactory(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory); // set the default bus for BusFactory.setDefaultBus(bus); String[] trIds = new String[] {CamelTransportFactory.TRANSPORT_ID}; camelTransportFactory.setTransportIds(Arrays.asList(trIds)); } public ServerImpl startService() { JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean(); svrBean.setAddress("camel://direct:test"); svrBean.setServiceClass(HelloService.class); svrBean.setServiceBean(new HelloServiceImpl()); svrBean.getInInterceptors().add(new LoggingInInterceptor()); svrBean.getOutInterceptors().add(new LoggingOutInterceptor()); ServerImpl server = (ServerImpl)svrBean.create(); server.start(); return server; } /** * Start a client that calls the service over hte jms queue to * test the route * @return */ public HelloService createClient() { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(HelloService.class); factory.setAddress("jms://"); return (HelloService) factory.create(); } public void run() throws Exception { /** * Start camel context with a jms component */ CamelContext context = createCamel(); /** * Create the cxf bus and integrate it with camel */ createCXFBus(context); ServerImpl server = startService(); HelloService client = createClient(); context.start(); String reply = client.echo("hallo"); context.stop(); server.stop(); //broker.stop(); System.exit(0); } public static void main(String args[]) throws Exception { new JmsToCXF().run(); } } ------------------- ------------------------------ 4.0.0 eu.cschneider cameltest 1.0.0-SNAPSHOT apache.incubating.releases Apache Incubating Release Distribution Repository http://people.apache.org/repo/m2-incubating-repository 2.5.4 2.1 1.3.0 org.springframework spring-core ${spring.version} org.springframework spring-beans ${spring.version} org.springframework spring-context ${spring.version} org.springframework spring-web ${spring.version} log4j log4j 1.2.14 org.apache.cxf cxf-rt-core ${cxf.version} org.apache.cxf cxf-rt-frontend-simple ${cxf.version} org.apache.cxf cxf-rt-frontend-jaxws ${cxf.version} org.apache.cxf cxf-rt-databinding-aegis ${cxf.version} org.apache.cxf cxf-rt-transports-local ${cxf.version} org.apache.cxf cxf-rt-transports-http ${cxf.version} org.apache.cxf cxf-rt-transports-http-jetty ${cxf.version} org.apache.cxf cxf-rt-transports-jms ${cxf.version} org.apache.cxf cxf-rt-management ${cxf.version} org.apache.cxf cxf-common-utilities ${cxf.version} junit junit 3.8.2 test com.tibco tibjms 4.3.0 org.apache.activemq activemq-core 5.1.0 org.apache.camel camel-core ${camel-version} org.apache.camel camel-jms ${camel-version} org.apache.camel camel-cxf ${camel-version} org.apache.cxf cxf-rt-core ${cxf.version} org.apache.cxf cxf-rt-frontend-simple ${cxf.version} org.apache.cxf cxf-rt-frontend-jaxws ${cxf.version} org.apache.cxf cxf-rt-databinding-aegis ${cxf.version} org.apache.cxf cxf-rt-transports-local ${cxf.version} org.apache.cxf cxf-rt-transports-http ${cxf.version} org.apache.cxf cxf-rt-transports-http-jetty ${cxf.version} org.apache.cxf cxf-rt-transports-jms ${cxf.version} org.apache.cxf cxf-rt-management ${cxf.version} org.apache.cxf cxf-common-utilities ${cxf.version} org.apache.cxf cxf-tools-common ${cxf.version} maven-compiler-plugin 1.5 1.5 Willem Jiang schrieb: > Hi Christian, > > The default exchange pattern of camel-cxf component is InOut, but for > the camel-jms consumer it just receive message from message queue. > If you want send the response message back , you have to put the > message to the response queue, just like this > > from("jms:myqueue").choice() > .when(xpath("//namespace=service1namespace")).to("cxf:mybeanname:myEndpointName").to("jms:responsequeue") > > .when(xpath("//namespace=service2namespace")).to("cxf:mybeanname2:myEndpointName2").to("jms:responsequeue") > > .otherwise().to("jms:deadletterqueue") > > BTW, If you alway want to let CXF take care of the service publishing > work, you could use camel transport which will be more effective than > the local transport. > Here are the example[1] and document[2] > > [1]http://cwiki.apache.org/CAMEL/cxf-example.html > [2]http://cwiki.apache.org/CAMEL/camel-transport-for-cxf.html > > Willem > > Christian Schneider wrote: