0

MULE を使用して Java プログラムから ActiveMQ のキューに文字列メッセージを送信しようとしています。これは私の 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"
        });

    }

ここでの間違いは何ですか。何を書くべきか明確ではありません

感謝と敬意

4

2 に答える 2

3

これは古い 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 プロセスは、キューに配置したメッセージ内のテキストを出力する必要があります。

于 2013-07-09T14:12:31.110 に答える
1

まず、jms:outbound-endpoint タグの connector-ref 属性があります。これは、送信メッセージの送信先を特定するために使用する必要があります。このような:

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

第二に、インバウンド ルートがないと、サービスでどのデータを操作するのかわかりません。例をさらに見てみましょう。

于 2011-04-20T00:19:04.503 に答える