使用mule从java程序向activemq发送消息

使用mule从java程序向activemq发送消息,java,activemq,mule,Java,Activemq,Mule,我正在尝试使用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.

我正在尝试使用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>
这里有什么错误,我不清楚该写什么


首先,您应该使用jms:outbound端点标记的connector ref属性来指定出站消息的去向。 像这样:

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


其次,如果没有入站路线,我不知道您的服务将对哪些数据进行操作。请尝试阅读更多示例。

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

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


其次,如果没有入站路线,我不知道您的服务将对哪些数据进行操作。试着看更多的例子。

这是基于较旧的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进程应该打印出您放在队列上的消息中的任何文本。

这是基于较旧的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进程应该打印出您放在队列上的消息中的任何文本