正确配置传输Sender&接收方JMS?

时间:2017-05-16 20:49:56

标签: wso2 wso2esb

我有一些问题,因为文件不清楚..

如何设置WSO2 ESB环境以便能够从WSO2 MessageBroker读取和写入消息。

我关注ConfigurewithWSO2MessageBroker

  1. 我在同一台服务器上有ESB和MB(MB有Offset = 2) /repository/conf/axis2/axis2.xml
  2. ...

    <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
            <parameter name="JMSTopic" locked="false">
               <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
                <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
                <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
            </parameter>
    
            <parameter name="JMSQueue" locked="false">
                <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
                <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
               <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
            </parameter>
    
            <parameter name="default" locked="false">
                <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
                <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
                <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
            </parameter>
        </transportReceiver>
    

    ...

    和发件人部分

    <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender">    
          <parameter name="default" locked="false">
                     <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                     <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
                     <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">ConnectionFactory</parameter>
              </parameter>        
         </transportSender>
    

    jndi.properties文件

    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://gst-esb-qa-01:5674'
    connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://gst-esb-qa-01:5674'
    connectionfactory.ConnectionFactory      = amqp://admin:admin@clientID/carbon?brokerlist='tcp://gst-esb-qa-01:5674'
    
    queue.myQueue = myQueue
    queue.testQueue= testQueue
    
    topic.MyTopic = MyTopic
    

    我的代理

    <proxy name="SendMessagetoJMSProxy" transports="http" startOnLoad="true">
                      <target>
                         <endpoint>
                            <address uri="jms:/myQueue?&amp;transport.jms.DestinationType=queue"/>
                         </endpoint>
                         <inSequence>
                            <log level="custom">
                               <property name="STATE" value="message is sent to queue"/>
                            </log>
                            <property name="OUT_ONLY" value="true"/>
                            <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
                         </inSequence>
                         <outSequence/>
                      </target>
                   </proxy>
    

    我的SOAP UI调用

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
                       <soapenv:Header/>
                       <soapenv:Body>
                          <ser:dummy>
                                <xsd:symbol>IBM</xsd:symbol>
                          </ser:dummy>
                       </soapenv:Body>
                    </soapenv:Envelope>
    

    根据文档,我应该在JMS Message Broker中看到消息,但我得到

    构建直通流时出错

    TID [-1234] [ESB] [2017-05-16 12:52:47,137] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} - 构建Passthrough流时出错org.apache.axiom .om.impl.builder.StAXOMBuilder.lookahead(StAXOMBuilder.java:711)org.apache.axiom.soap.impl.llom.SOAPBodyImpl.hasLookahead(SOAPBodyImpl.java:191)org.apache.axiom.soap.impl.llom .SOAPBodyImpl.getFirstElementLocalName(SOAPBodyImpl.java:217)org.apache.axiom.soap.impl.llom.SOAPBodyImpl.hasFault(SOAPBodyImpl.java:99)org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.hasFault(SOAPEnvelopeImpl .java:305)org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:189)org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:137)org .apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:100)org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:140)org.apache.synapse.mediators.AbstractListMediator.me diate(AbstractListMediator.java:83)org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)org.apache。 synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:210)org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker。 java:403)org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)org.apache.axis2.transport.base.threads.NativeWorkerPool $ 1.run(NativeWorkerPool.java:172)java.util .concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)

    AND

    端点:地址为jms的AnonymousEndpoint:/ myQueue?&amp; transport.jms.DestinationType = queue将在失败时标记为SUSPENDED

    第一个问题: axis2.xml中的java.naming.provider.url param是否相对于[ESB Home]位置?

    我的案例服务器文件夹结构看起来像...... enter image description here

    也许应该看起来像...... ????

    <parameter name="java.naming.provider.url" locked="false">file:/home/wso2admin/wso2esb-5.0.0/repository/conf/jndi.properties</parameter>
    

    第二次: 这个错误与Message Builder和Formater ????

    有关

    任何帮助都会很好......我已经坚持了几天......

3 个答案:

答案 0 :(得分:2)

第一个问题:axis2.xml中的java.naming.provider.url param是否相对于[ESB Home]位置?

不,您不需要添加ESB家庭位置。

第二个问题:这个错误与Message Builder和Formater有关????

是的,您在使用邮件构建器时遇到错误。

只需验证您是否添加了客户端jar并验证您的代理。请创建一个代理,如下所示。

示例代理:

<proxy name="QueueProxy" startOnLoad="true" transports="jms">
    <target>
        <inSequence>
             <property name="OUT_ONLY" value="true"/>
             <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
            <send>
                <endpoint>
                    <address uri="jms:/MyQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/jndi.properties"/>
                </endpoint>
            </send>
        </inSequence>
    </target>
</proxy>

参考:https://docs.wso2.com/display/ESB500/ESB+as+a+JMS+Producer

答案 1 :(得分:1)

请尝试以下代理并检查您使用的网址格式

<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http">
<target>
    <inSequence>
        <property action="set" name="OUT_ONLY" value="true"/>
        <send>
            <endpoint>
                <address uri="jms:/myQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>

了解更多

答案 2 :(得分:1)

感谢Rajjaz和Jan ......

我创建了一个代理

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SendMessagetoJMSProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <log level="custom">
            <property name="STATE" value="message is sent to myQueue"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
      </inSequence>
      <outSequence/>
      <endpoint>
         <address uri="jms:/myQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/jndi.properties"/>
      </endpoint>
   </target>
   <description/>
</proxy>

我还想知道如果你在axis2.xml中为transportReceiver定义默认的JMS配置部分就足以放入Queue的名称

所以这也有效

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SendMessagetoJMSProxy2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <log level="custom">
            <property name="STATE" value="message is sent to GST_TMS_ASSOCIATE_LEASE Queue"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
      </inSequence>
      <outSequence/>
      <endpoint>
         <address uri="jms:/myQueue"/>
      </endpoint>
   </target>
   <description/>
</proxy>

现在我可以使用代理...

将消息发布到JMS队列

我很困惑(仍然)系统日志中所有这些日志的来源和原因?!![enter image description here] 1