« Return to Thread: Want to write a standalone java class that uses MuleClient for sending messages to ActiveMQ

RE: Want to write a standalone java class that uses MuleClient for sending messages to ActiveMQ

by Manupriya :: Rate this Message:

Reply to Author | View in Thread

Thanks Pawan,

I tried the modifications suggested by you. But I am getting the following exception -

org.mule.api.transport.DispatchException: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=tcp://localhost:61616, connector=TcpConnector{this=105eb6f, started=true, initialised=true, name='connector.tcp.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[tcp], serviceOverrides=null}, transformer=[], name='endpoint.tcp.localhost.61616', properties={}, transactionConfig=Transaction{factory=null, action=NEVER, timeout=0}, filter=null, deleteUnacceptedMessages=false, securityFilter=null, synchronous=true, initialState=started, remoteSync=true, remoteSyncTimeout=10000, endpointEncoding=UTF-8}. Message payload is of type: String
        at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:188)
        at org.mule.transport.AbstractConnector.send(AbstractConnector.java:1890)
        at org.mule.endpoint.DefaultOutboundEndpoint.send(DefaultOutboundEndpoint.java:76)
        at org.mule.module.client.RemoteDispatcher.requestWireFormat(RemoteDispatcher.java:111)
        at org.mule.module.client.RemoteDispatcher.<init>(RemoteDispatcher.java:105)
        at org.mule.module.client.MuleClient.getRemoteDispatcher(MuleClient.java:990)
        at com.novus.generator.MessageGenerator.populateMesasgeQueueWithMuleClient(MessageGenerator.java:108)
        at com.novus.generator.MessageGenerator.main(MessageGenerator.java:102)
Caused by: java.io.IOException: An error occurred while verifying your connection.  You may not be using a consistent protocol on your TCP transport. Please read the documentation for the TCP transport, paying particular attention to the protocol parameter.
        at org.mule.transport.tcp.protocols.SafeProtocol.helpUser(SafeProtocol.java:110)
        at org.mule.transport.tcp.protocols.SafeProtocol.assertSiblingSafe(SafeProtocol.java:83)
        at org.mule.transport.tcp.protocols.SafeProtocol.read(SafeProtocol.java:37)
        at org.mule.transport.tcp.TcpMessageDispatcher.receiveFromSocket(TcpMessageDispatcher.java:150)
        at org.mule.transport.tcp.TcpMessageDispatcher.doSend(TcpMessageDispatcher.java:66)
        at org.mule.transport.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:157)
        ... 7 more
Caused by: java.io.IOException: Length 217 exceeds limit: 26
        at org.mule.transport.tcp.protocols.LengthProtocol.read(LengthProtocol.java:75)
        at org.mule.transport.tcp.protocols.SafeProtocol.assertSiblingSafe(SafeProtocol.java:79)
        ... 11 more

Can you please help me by pointing out what I am missing out?

Thanks,
Manupriya



Hello Manupriya,

I read your query. You can use mule client to send jms messages on particular topic. I did minor change in your code. I am using VM connector to send your message to Mule component (samplejms) defined in config file & later its outbound endpoint (jms) will dispatch your message on topic defined at jms endpoint using ActiveMQ Broker.  

Modified code:

        try {
               MuleClient client = new MuleClient();

                RemoteDispatcher dispatcher = client.getRemoteDispatcher("tcp://localhost:61616");
               
                 for (String rowValue : rowList) {
                         dispatcher.sendAsyncRemote("vm://manu.vm", rowValue, null);
                 }
                } catch (MuleException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }



Now your mule config will look like. Use the following config along with your existing configuration.

<vm:connector name="asyncVm" queueEvents="true" />

<endpoint name="samplejmsmessage"
                address="jms://topic:manu.topic" synchronous="false" connector-ref="jmsConnector"/>

 <service name="SampleJMS">
                        <inbound>
                                <vm:inbound-endpoint path="manu.vm" connector-ref="asyncVm" />
                        </inbound>
                        <bridge-component />
                        <outbound>
                                <multicasting-router>
                                        <outbound-endpoint ref="samplejmsmessage" />
                                </multicasting-router>
                        </outbound>
 </service>



I hope i answered your question.

Cheer,
Pawan Modi


Manupriya wrote:
Thanks Wayne,

I am currently using JMS messages only to create and put the messages in the Active MQ topic. But I wanted to try MuleClient for this. Can you please let me know in which scenarios should we use MuleClient?

Thanks,
Manupriya


Wayne Wundram wrote:
Dear Manupriya,

Why don't you just use JMS? Why the need for MuleClient?

Regards,
Wayne Wundram
www.miraculum.com
Johannesburg, South Africa

-----Original Message-----
From: Manupriya [mailto:manupriya.sinha@gmail.com]
Sent: Thursday, August 14, 2008 9:03 AM
To: user@mule.codehaus.org
Subject: [mule-user] Want to write a standalone java class that uses
MuleClient for sending messages to ActiveMQ


Hi,

My requirement is to have a standalone java class that just generates
messages and puts them to an Active MQ Topic. I want to write something
similar to following -

        try {
               MuleClient client = new MuleClient();

                RemoteDispatcher dispatcher =
client.getRemoteDispatcher("tcp://localhost:61616");
               
                 for (String rowValue : rowList) {
       
dispatcher.sendAsyncRemote("jms://topic:manu.topic", rowValue, null);
                 }
                } catch (MuleException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

Can you please help?

Thanks,
Manupriya
--
View this message in context:
http://www.nabble.com/Want-to-write-a-standalone-java-class-that-uses-Mu
leClient-for-sending-messages-to-ActiveMQ-tp18976660p18976660.html
Sent from the Mule - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Want to write a standalone java class that uses MuleClient for sending messages to ActiveMQ