3

我正在尝试通过 Camel Route 将消息放在 Weblogic JMS 中的队列上。

我的目标是最终配置一个路由来使用 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)

我按照这里提到的创建队列的过程:https ://blogs.oracle.com/soaproactive/entry/how_to_create_a_simple

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

我是 JMS 的新手,我知道我在 Camel 端或 Weblogic 端的配置有问题,但无法弄清楚是什么。任何帮助将不胜感激。

提前致谢。

4

3 回答 3

9

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

那么语法需要是 JMSServer/JMSModule!Queue

于 2013-10-18T09:52:00.857 回答
0

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

于 2013-05-30T09:04:08.617 回答
0

我将集成 Spring (4.1.6) + Apache Camel (2.15.2) 并使用托管在 Oracle Weblogic (11g) 上的 JMS 队列中的消息。

应用程序上下文.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 是两个 Camel 处理器,它们只记录来自 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()");
}

亲切的问候,

克里斯蒂安·马诺留

于 2015-06-18T13:45:13.963 回答