2011-03-28 85 views
0

蔭試圖從Java程序發送一個字符串消息使用MULE.Iam新騾子這ActiveMQ的排隊是我的騾子-config.xml中從java程序將消息發送到ActiveMQ的用騾子

<?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" 
     }); 

    } 

什麼是這裏的錯誤,不IAM清除

由於寫什麼,並認爲

回答

1

首先,jms:outbound-endpoint標記有一個connector-ref屬性,您應該使用它來指定出站消息的去向。 這樣的:

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

其次,如果沒有呼入路由,我不知道什麼數據到服務上進行操作。試着通過一些更多的例子。

3

這是基於一箇舊版本的騾子(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進程應該打印出放在隊列中的消息中的任何文本。