« Return to Thread: Want to write a standalone java class that uses MuleClient for sending messages to ActiveMQ
antoine.borg wrote:Hi,
The cleanest way to do it would be:
1) Create a Java class that creates the message you want to send. This
message should be returned as the return value of a method.
2) Configure a service in Mule that uses your Java class as the component
and sends the message to a JMS queue or topic using the outbound router.
This is one of the key advantages of Mule - you do not need to code routing
mechanisms into your classes but can (indeed should) leave it up to Mule.
Cheers
Antoine Borg, Senior Consultant | Tel: +32 28 504 696
ricston Ltd., BP 2, 1180 Uccle, Brussels, BELGIUM
email: antoine.borg@ricston.com | blog: blog.ricston.com | web: ricston.com
-----Original Message-----
From: Manupriya [mailto:manupriya.sinha@gmail.com]
Sent: Friday, August 29, 2008 8:20 AM
To: user@mule.codehaus.org
Subject: Re: [mule-user] Want to write a standalone java class that uses
MuleClient for sending messages to ActiveMQ
Hi,
My requirement is to have a java class that creates and puts JMS messages to
an ActiveMQ topic.
At present I am using JNDI lookup for the topic and then I am creating a JMX
producer for this topic. After this I create a JMS message and putting it on
the topic.
I read through some of the articles on net that I can use Mule Client for
achieving the same. I am quite new to Mule, Can you please suggest which
would be a better design approach - using JMS producer or Mule Client?
Thanks,
Manu
Vineet Khilani wrote:
>
> If you must use MuleClient, then you can try this:
>
> public void sendMessage(Object msg){
> Map props = new HashMap();
> props.put("Sender", "Mule Client");
> MuleClient muleClient = new MuleClient();
> muleClient.dispatch("jms://localhost:61616/topic:manu.topic", msg,
> props); } The only problem with this is that your Java class needs to
> have the information about Active MQ, topic name, etc.
>
> But if you want to send a message through Mule but don't have to use
> MuleClient, I would recommend this approach to remove all transport
> specific information from your Java client:
>
> Add this to your mule config:
> <jms:activemq-connector name="JMSConnector"
> connectionFactory-ref="activeMqConnectionFactory">
> <spring:beans>
> <spring:bean name="activeMqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
> <spring:property name="brokerURL" value="tcp://localhost:61616"/>
> </spring:bean>
> </spring:beans>
> </jms:activemq-connector>
> <service name="TopicService">
> <outbound>
> <outbound-pass-through-router>
> <jms:outbound-endpoint queue="topic:manu.topic"
> transformer-refs="ObjectToJMSTransformer" />
> </outbound-pass-through-router>
> </outbound>
> </service>
>
>
> And in your Java class, you can send your message using the service
> name
> "TopicService":
>
> Service service =
> MuleServer.getMuleContext().getRegistry().lookupService("TopicService"
> );
>
>
>
>
>
> Manupriya wrote:
>>
>> 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-MuleCl
ient-for-sending-messages-to-ActiveMQ-tp18976660p19214301.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
| Free embeddable forum powered by Nabble | Forum Help |