开发者

send message from java program to activemq using mule

开发者 https://www.devze.com 2023-02-20 01:02 出处:网络
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

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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号