2013-05-27 103 views
3

我想通过骆驼路由在Weblogic JMS队列中放置消息。从骆驼路由发送消息到Weblogic JMS队列

我的目标是最终配置一个Route来使用jms队列中的消息来发布早期路由中的数据。

这里是我的配置:

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> 
    <property name="environment"> 
     <props> 
      <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
      <prop key="java.naming.provider.url">t3://localhost:7001</prop> 
      <!-- opional ... --> 
      <prop key="java.naming.security.principal">weblogic</prop> 
      <prop key="java.naming.security.credentials">weblogic</prop> 
     </props> 
    </property> 
</bean> 

<!-- Gets a Weblogic JMS Connection factory object from JDNI Server by jndiName--> 
<bean id="webLogicJmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiTemplate" ref="jndiTemplate" /> 
    <property name="jndiName" value="jms/TestConnectionFactory" /> <!-- the connection factory object is store under this name --> 
</bean> 

<!-- Create a new WebLogic Jms Camel Component --> 
<bean id="wmq" class="org.apache.camel.component.jms.JmsComponent"> 
    <property name="connectionFactory" ref="webLogicJmsConnectionFactory"/> 
</bean> 

我的路线是这样的:

from("cxfrs:bean:rsServer") 
    .setBody().body(TestRequest.class) 
    .process(new Processor(){ 
     @Override 
     public void process(Exchange exchange) throws Exception { 
      TestRequest request = exchange.getIn().getBody(TestRequest.class); 
      TestResponse response = new TestResponse(); 
      response.setAddress(request.getAddress()); 
      response.setName(request.getName()); 
     } 

    }).to("wmq:queue:TestJMSQueue"); 

当我尝试执行此路由我得到这个异常:

May 27, 2013 6:37:47 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse 
WARNING: javax.ws.rs.WebApplicationException: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is weblogic.jms.common.JMSException: [JMSExceptions:045101]The destination name passed to createTopic or createQueue "TestJMSModule!TestJMSQueue" is invalid. If the destination name does not contain a "/" character then it must be the name of a distributed destination that is available in the cluster to which the client is attached. If it does contain a "/" character then the string before the "/" must be the name of a JMSServer or a ".". The string after the "/" is the name of a the desired destination. If the "./" version of the string is used then any destination with the given name on the local WLS server will be returned. 
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.returnResponse(CxfRsInvoker.java:149) 
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.asyncInvoke(CxfRsInvoker.java:104) 
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:57) 
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor 
... 
Caused by: weblogic.jms.common.JMSException: [JMSExceptions:045101]The destination name passed to createTopic or createQueue "TestJMSModule!TestJMSQueue" is invalid. If the destination name does not contain a "/" character then it must be the name of a distributed destination that is available in the cluster to which the client is attached. If it does contain a "/" character then the string before the "/" must be the name of a JMSServer or a ".". The string after the "/" is the name of a the desired destination. If the "./" version of the string is used then any destination with the given name on the local WLS server will be returned. 
at weblogic.jms.frontend.FEManager.destinationCreate(FEManager.java:202) 
at weblogic.jms.frontend.FEManager.invoke(FEManager.java:544) 
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961) 
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184) 
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287) 
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59) 
at weblogic.jms.client.JMSSession.createDestination(JMSSession.java:3118) 
at weblogic.jms.client.JMSSession.createQueue(JMSSession.java:2514) 

我按照程序创建一个Queue这里提到:https://blogs.oracle.com/soaproactive/entry/how_to_create_a_simple

我正在创建一个JMS模块(TestJMSModule),并在其中创建了一个Queue(TestJMSQueue)和一个连接工厂。

我是JMS的新手,我知道我在做驼峰侧或Weblogic侧的配置时出错,但是无法弄清楚什么。任何帮助将不胜感激。

在此先感谢。

回答

0

不幸的是,我不是WebLogic配置方面的专家。 客户端配置看起来正确。 异常说明对象名称不正确。 在你提到的例子中,队列的jndi名称是“jms/TestJMSQueue”,而不仅仅是“TestJMSQueue”。 对我来说,这意味着你应该使用.to("wmq:queue:jms/TestJMSQueue");来代替。

6

您需要创建一个JMS服务器。然后,您需要在JMS模块中创建子部署,然后将子部署定位到JMS服务器。

那么语法必须 JMSServer/JMSModule!队列

+0

谢谢你的语法例子,一直推动我坚果。 – edclrk

+0

完美答案。面临同样的问题,在一秒钟内解决。谢谢 !! – AnirbanDebnath

0

我是春天(4.1.6)+ Apache的骆驼(2.15.2)和使用消息从JMS队列集成托管的Oracle WebLogic( 11克)。

的applicationContext.xml

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> 
    <property name="environment"> 
     <props> 
      <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> 
      <prop key="java.naming.provider.url">t3://localhost:7001</prop> 
      <prop key="java.naming.security.principal">weblogic</prop> 
      <prop key="java.naming.security.credentials">welcome1</prop> 
     </props> 
    </property> 
</bean> 

<bean id="webLogicJmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiTemplate" ref="jndiTemplate" /> 
    <!-- Connection factory JNDI name --> 
    <property name="jndiName" value="jms/TestConnectionFactory" /> 
</bean> 

<bean id="weblogicJmsComponent" class="org.apache.camel.component.jms.JmsComponent"> 
    <property name="connectionFactory" ref="webLogicJmsConnectionFactory" /> 
</bean> 

<camel:camelContext id="camel" xmlns:camel="http://camel.apache.org/schema/spring"> 
    <!-- Route to copy files --> 
    <camel:route startupOrder="1"> 
     <camel:from uri="file:data/inbox?noop=true" /> 
     <camel:process ref="loggingProcessor" /> 
     <camel:to uri="file:data/outbox" /> 
    </camel:route> 

    <!-- Route to read from JMS and process them in jmsReaderProcessor --> 
    <camel:route startupOrder="2"> 
     <camel:from uri="weblogicJmsComponent:queue:TestJMSServer/TestJMSModule!TestJMSQueue" /> 
     <camel:process ref="jmsReaderProcessor" /> 
    </camel:route> 
</camel:camelContext> 

loggingProcessor和jmsReaderProcessor两种骆驼处理器,只是注销从Exchange对象/消息。

public void process(Exchange exchange) throws Exception { 
    LOG.info("begin process()"); 
    LOG.info("process() -- Got exchange: {}", exchange); 

    Message messageIn = exchange.getIn(); 
    LOG.info("process() -- Got messageIn: {}", messageIn); 

    LOG.info("process() -- Got messageIn.getBody(): {}", messageIn.getBody()); 

    Message messageOut = exchange.getOut(); 
    LOG.info("process() -- Got messageOut: {}", messageOut); 

    LOG.info("end process()"); 
} 

亲切的问候,

克里斯蒂安Manoliu

相关问题