I have an issue with ActiveMQ loadbalancing with Mule. I am using Mule 3.2.0 and ActiveMQ 5.5.1
I have a Mule FLow application which uses JMS inbound Endpoint to listen to queues in ActiveMQ.
I have 2 instances of AMQ running each having a queue called "MyQueue".
Lets name them AMQ1 and AMQ2.
I also have 2 mule instances running - each having the same app. Let's name them Mule1 and Mule2.
Now I want each mule instance to pick up messages from either of the AMQ queues. So say a Message Sender sends the message to the queue MyQueue in either AMQ1 or AMQ2 (Message sender load balances using failover transport supported by ActiveMQ - and that bit works fine). Say it reached AMQ1. Now ideally I would like to have 10 consumers each of Mule1 and Mule2 registered in each AMQ instance. So both of them are listening for incoming messages in both the queues. One of them should pick up the message from the queue and process it.
This is the config I am using in Mule to connect to both the AMQ brokers.
<jms:activemq-connector name="Active_MQ" brokerURL="failover:tcp://10.0.64.158:61616,tcp://10.0.64.160:61616)?randomize=true" eagerConsumer="true" numberOfConsumers="10" dynamicNotification="true" validateConnections="true" clientId="MuleInstance1" doc:name="Active MQ">
<reconnect count="5" frequency="3000" blocking="false"/>
</jms:activemq-connector>
kindly note clientId is different for different Mule instances. Also currently AMQ 1 and Mule1 share the same machine and AMQ2 and Mule2 share another machine.
However I am noticing soem random behaviour. AT times all consumers(both of Mule1 and Mule2) register only to one AMQ instance. At times Mule1 is registering only to AMQ1 and Mule 2 to AMQ2.
What ideally I want is cosnumers of both Mule1 and Mule2 to register to both AM1 and AMQ2
I followed the instructions here
http://www.mulesoft.org/documentation-3.2/display/MULE3USER/ActiveMQ+Integration
Basically I wanted to use the network of broker architecture so that there is no loss of service whether a Mule instance or AMQ instance goes down or has to be restarted.
Not sure the randomize=true query param in helping in this case.
Can someone kindly advise how to achieve the above using Mule 3.2.0 and Active MQ 5.5.1?
If there isn't a solution sadly I may have to make Mule1 listen to AMQ1 and Mule2 listen to only AMQ2 and it won't really be clustered :(
Thanks in advance.
Got it working.
Got a suggestion the Mule forum itself.
http://forum.mulesoft.org/mulesoft/topics/activemq_loadbalancing_with_mule
So basically instead of relying on AMQ load balancing for the consumer I used 2 AMQ connectors and used a composite source in each mule app listenign to 2 Inbound EndPoints. And it works a treat. Bringing up/Shutting down Mule and AMQ instances - all worked a treat. here's teh config
<jms:activemq-connector name="Active_MQ_1" brokerURL="failover: (tcp://10.0.64.158:61616)" eagerConsumer="true" numberOfConsumers="10" dynamicNotification="true" validateConnections="true" clientId="MuleInstance1" doc:name="Active MQ">
<reconnect count="5" frequency="3000" blocking="false"/>
</jms:activemq-connector>
<jms:activemq-connector name="Active_MQ_2" brokerURL="failover:(tcp://10.0.64.160:61616)" eagerConsumer="true" numberOfConsumers="10" dynamicNotification="true" validateConnections="true" clientId="MuleInstance1" doc:name="Active MQ">
<reconnect count="5" frequency="3000" blocking="false"/>
</jms:activemq-connector>
Now refer to that from within your flow with composite-source
<flow name="MyAutomationFlow" doc:name="MyAutomationFlow">
<composite-source>
<jms:inbound-endpoint queue="MyOrderQ" connector-ref="Active_MQ1" doc:name="JMS Inbound Endpoint"/>
<jms:inbound-endpoint queue="MyOrderQ" connector-ref="Active_MQ2" doc:name="JMS Inbound Endpoint"/>
</composite-source>
........
Worked a treat!
Related
My requirement is to clear all the messages from queue(not delete the queue only purge the messages from queue) before processing the flow or publishing anything in the queue. We are using rabbitMQ and due to some reason messages are stucked in the queue and because of that we are facing some issue when we are counting the queue based on the messages. so for the next time before processing we have to clear the queue. Here we have multiple queue like slave1, slave2,slave3 and when api will be triggered in the process section we have to clear the queue.
Mule 3 has a generic AMQP connector so i think we have to use http requester to do the same.
Kindly help to get the HTTP API to connect to rabbitMQ and do the purging. I have gone through some forum but not getting the clear idea. How do I delete all messages from a single queue using the CLI?
If I understand correctly you need help to implement the same HTTP request that is performed using curl in the previous answers, but using Mule 3.
The answer shows how to use RabbitMQ management plugin's REST API to delete the contents of a queue:
curl -i -u guest:guest -XDELETE http://localhost:15672/api/queues/vhost_name/queue_name/contents
In Mule 3 something equivalent would be:
<http:request-config name="HTTP_Request_Configuration" host="httpbin.org" port="80" doc:name="HTTP Request Configuration" >
<http:basic-authentication username="${user}" password="${password}"/>
</http:request-config>
<flow name="deleteQueueFlow">
<http:request method="DELETE" doc:name="Request" config-ref="HTTP_Request_configuration" path="/api/queues/${vhostname}/${queuename}/contents"/>
</flow>
How can we store failed messages in VM Connector in MULE
Assume it is a transient flow .
Scenario is like when ever mule server is down and at the same time messages sent to publish connector.
what will be best way. Hope I am clear or bear with me for any confusion.
thanks
The VM connector works like a queue in memory, but it is not an external message broker like for example ActiveMQ or IBM MQ. The VM connector implementation is inside the Mule Runtime implementation. It can not be used to send messages to other Mule servers, nor other non-Mule applications. Also if the Mule Runtime instance is down, then it will not work at all so there is not way to publish nor receive messages. If you want that kind of reliability you need to use an external JMS message broker.
I am using Mule community-3.8 version. I have a scenario where i need to connect MQ via JMS and should have retry strategy connection in forever mode. It is working fine on the happy scenario incase of MQ/channel restart happened.
But in case of queue manager down and Mule tries to connect forever, then that moment I couldn't able to undeploy the flows even if I remove the flow directory and anchor file as well still it retries.
I feel this is an open bug in Mule? Can anyone suggest is this the existing behaviour?
Code snippet
<spring:beans>
<spring:bean id="ConnectionFactory" name="ConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory">
</spring:bean>
</spring:beans>
<jms:connector name="jms-conn" username="xxxx" password="xxxx" specification="1.1" connectionFactory-ref="ConnectionFactory" validateConnections="true" numberOfConsumers="1" persistentDelivery="true">
<reconnect-forever frequency="30000" />
</jms:connector>
Moreover, I am able to undeploy the flow if i use blocking=false in the jms:connector. But I really don't need that feature to be there in my usecase.
JMS retry option will work in a single thread model, hence this can hold the new thread process until this gets reconnected successfully.
I'm started to work with Mule and Mule Studio (version 3.5): my goal is rewriting some flows that now is workign, but with a bad syntax.
In this moment I have a flow with some JMS connector and JMS endpoint for acquiring data (my flows are using ActiveMQ 5.10): the configuration XML file is ok and I want to test this flow, but I have'nt a big experience in JMS and system integration.
I think to create a JMS producer and, into run,
start up Mule (with all his flows, endpoints, etc, JMS queues);
start the JMS producer: in run the producer
links to name queue defined in configuration Mule
create a message
send this message to Mule
And the test asserts the
Mule receive the message by the producer
Mule don't loss the message
Mule turn this message to correct flow and relative elaboration
My problem is the lack of manuality and pratical work-ability to link Mule and producer: I tried to use http://activemq.apache.org/hello-world.html but the code is useless for me because it work correctly without Mule, but in my case the tests has to fail if Mule is stopped.
Has everybody any suggest, please?
Just set up an activemq connector without addresss, that will use the default address of vm://localhost that instructs the connector and activemq to act as a local embedded server.
<jms:activemq-connector name="JmsConnector" specification="1.1" />
I'm new to active MQ.
I have a requirement to create a local Active MQ and connect it to a remote IBM MQ.
Can anyone help me on how to connect to Distributed Queue manager and Queues .
You can use Apache Camel to bridge between the two providers. The routes can be run from within the broker, pull from the ActiveMQ queue and push to the WMQ Queue (or the other way around). The concept is almost like the concept of a Channel in WMQ pulling from a transmit queue and pushing it to the appropriate destination on the remote queue manager.
Assuming you are using WMQ V7+ for all QMgrs and Clients, its simply a matter of learning how to set up the route and configure the connection factories. Older versions of WMQ and you may have to understand how to deal with RFH2 headers for native WMQ clients if they are the consumers.
The most simple route configured in spring would look like:
<route id="amq-to-wmq" >
<from uri="amq:YOUR.QUEUE" />
<to uri="wmq:YOUR.QUEUE" />
</route>
The "wmq" and "amq" would point to beans where the JMS components are configured. This is where you would set up you connection factories to each provider and how the clients behave (transacted or not for example), so I'll hold off on giving an example on that.
This would go in the camel.xml (or whatever you name it) and get imported from your broker's XML. ActiveMQ comes with several examples you can use to get you started using Camel JMS components. Just take a look at the default camel.xml that comes with a normal install.