簡體   English   中英

使用Mule將消息從Java程序發送到activemq

[英]send message from java program to activemq using mule

我試圖使用MULE從Java程序發送字符串消息到ActiveMQ中的隊列.mam新來的這是我的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"
        });

    }

這里有什么錯誤,我不清楚要寫什么

謝謝並恭祝安康

這基於較舊的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進程應打印出您放在隊列中的消息中的任何文本。

首先,您可能應該使用jms:outbound-endpoint標記的connector-ref屬性,以特定於出站消息的去向。 像這樣:

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

其次,如果沒有入站路由,我不知道您的服務將要處理哪些數據。 嘗試通過更多示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM