【问题标题】:send message from java program to activemq using mule使用 mule 从 java 程序向 activemq 发送消息
【发布时间】:2011-07-24 09:07:49
【问题描述】:

我正在尝试使用 MULE 从 java 程序发送字符串消息到 ActiveMQ 中的队列。我是 mule 新手,这是我的 mule-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
      http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.1/mule-jms.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">


<jms:activemq-connector name="jmsConnector" 
    specification="1.1" 
    brokerURL="tcp://localhost:61616" />
<model name="jmsModel">
    <service name="jmsService">
        <inbound>

        </inbound>
        <outbound>
            <pass-through-router>
                <jms:outbound-endpoint queue="myQueue" />
            </pass-through-router>
        </outbound>
    </service>
</model>
</mule>

下面是我的java类

public class MuleCaller {

    public static void main(String args[])
    {

        MuleCaller springCaller = new MuleCaller();
        springCaller.runListner();
        //  spAsync.onMessage(null);
}
public void runListner(){

    ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {
            "mule-config.xml"
        });

    }

这里有什么错误,不清楚要写什么

感谢和问候

【问题讨论】:

    标签: java activemq mule


    【解决方案1】:

    首先,jms:outbound-endpoint 标记有一个 connector-ref 属性,您可能应该使用它来指定出站消息的去向。 像这样:

    <jms:outbound-endpoint connector-ref="jmsConnection" queue="myQueue" />
    

    其次,如果没有入站路由,我不知道您的服务要操作哪些数据。尝试通过更多示例。

    【讨论】:

      【解决方案2】:

      这是基于较旧的 Mule 版本 (3.1.2) 并使用流语法

      <?xml version="1.0" encoding="UTF-8"?>
      <mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
      xsi:schemaLocation="
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
          http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.1/mule-jms.xsd">
      
      <jms:activemq-connector name="jmsConnector"  
          brokerURL="tcp://localhost:61616"
          specification="1.1"
          maxRedelivery="30"
          disableTemporaryReplyToDestinations="true"
          createMultipleTransactedReceivers="true"
          acknowledgementMode="CLIENT_ACKNOWLEDGE"
          numberOfConcurrentTransactedReceivers="1"
          persistentDelivery="true">
      </jms:activemq-connector>
      
      <flow name="inbound JMS service">
          <jms:inbound-endpoint connector-ref="jmsConnector" queue="/jmsQueue" exchange-pattern="one-way">
              <jms:transaction action="BEGIN_OR_JOIN"/>
          </jms:inbound-endpoint>
      
          <echo-component/>
      </flow>
      

      使用 ActiveMQ 控制台,您可以创建一个名为 jmsQueue 的队列并手动向其发送消息。使用上述配置的 Mule 进程应该打印出您放置在队列中的消息中的任何文本。

      【讨论】:

        猜你喜欢
        • 2016-04-13
        • 2019-01-24
        • 2012-08-06
        • 2019-09-29
        • 2013-08-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-24
        相关资源
        最近更新 更多