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

发布于 2024-10-27 04:04:40 字数 1851 浏览 6 评论 0原文

我正在尝试使用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"
        });

    }

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

和问候

Iam trying to send a string message from a java program to queue in ActiveMQ using MULE.Iam new to mule this is my 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>

and following is my java class

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

    }

What are the mistakes here, and iam not clear what to be written in

Thanks and regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我做我的改变 2024-11-03 04:04:40

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

This is based on an older Mule version (3.1.2) and is using flow syntax

<?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>

Using the ActiveMQ console you can create a queue called jmsQueue and manually send messages to it. A Mule process using the config above should print out whatever text is in the message you place on the queue.

最好是你 2024-11-03 04:04:40

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

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

其次,如果没有入站路由,我不知道您的服务要操作哪些数据。尝试再看一下这个例子。

Firstly, there is a connector-ref attribute of the jms:outbound-endpoint tag that you should likely use to specific to where outbound messages are to go.
like this:

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

Secondly, without an inbound route, i've no clue what data is to be operated on by your service. try to go through some more of the example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文