I want to implement a consumer kind behaviour using Mule, ActiveMQ which can read JMS messages....there is some third party queue/topic. need to subscribe to them and start listening. How can I achieve that in mule?
Follow the instructions in this blog post to get a working connector. If you are using JMS1.1 you don't even need to specify queue or topic, they will behave the same. If you are using 1.0b, please make sure you specify the correct type.
Then, instead of using an outbound endpoint use an inbound endpoint:
<jms:inbound-endpoint topic="myTopic" connector-ref="Active_MQ" />
I do, however, recommend to use Anypoint Studio, that will provide you a very simple interface for this kind of configurations.
To read a message from activemq queue ot topic, can simply put in your flow for example:
<flow name="insert-operation" doc:name="insert-operation" doc:description="">
<jms:inbound-endpoint connector-ref="Active_MQ" exchange-pattern="request-response" queue="insert-jms" doc:name="JMS">
<idempotent-redelivery-policy idExpression="#[message.inboundProperties['JMSMessageID']]" />
<xa-transaction action="ALWAYS_BEGIN" />
</jms:inbound-endpoint>
...
</flow>
Related
I have a composite source enclosing Multiple jms end connector... I want to know which endpoint within composite source received the message . Note: inbound property does not have end point details. Basically,I want to get the JMS server address ... Or the server address what i have given in the jms endpoint will also be enough.
Got this solution refering to mulesoft documentation:
<composite-source doc:name="Composite Source">
<jms:inbound-endpoint queue="${jms1.queue}"
connector-ref="jms-connector1" doc:name="JMS1">
<set-property propertyName="source" value="jms1"></set-property>
</jms:inbound-endpoint>
<jms:inbound-endpoint queue="${jms2.queue}"
connector-ref="jms-connector2" doc:name="JMS2" >
<set-property propertyName="source" value="jms2"></set-property>
</jms:inbound-endpoint>
</composite-source>
I build spring application and send to RabbitMQ.
now I want to build project in Mule ESB that listen to queue and work with the information, if has variable a (for example) -> process to aa flow etc..., -> convert responses to JSON -> send back to RabbitMQ. -
1) It will need to be RabbitMQ or other it possible?
2) How to do that - listen to specific queue and process it?
3) And after, how to send back?
I saw some examples but didn't understand the topic perfect.
`*
</amqp:queue-profile> -->
<flow name="amqpChoiceAckNackService">
<amqp:inbound-endpoint queueName="my-queue"
connector-ref="amqpManualAckLocalhostConnector" />
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8080" path="message" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties['msg']]" doc:name="Set Payload"/>
<processor-chain doc:name="Processor Chain">
<amqp:outbound-endpoint queueName="test.queue1" responseTimeout="10000" doc:name="AMQP1" connector-ref="AMQP_Connector1"/>
<custom-processor class="CustomProcessor" doc:name="Custom Processor"/>
</processor-chain>
</flow>*`
Who can help me?
Thanks.
to listen to a queue in mule you need to have following configuration,(I am not familiar to amqp but this way also works)
<spring:bean id="rabbitMQconnectionFactory" class="RabbitMQconnectionFactoryClass">
<!--..whatever properties are required by this class (hint :- search how to make a rabbitMQ connection factory bean) -->
</spring:bean>
<jms:connector name="rabbitMQconnector" connectionFactory-ref="rabbitMQconnectionFactory" username="" password="" doc:name="JMS"/>
<flow name="flow1" doc:name="Flow1">
<jms:inbound-endpoint doc:name="JMS" connector-ref="rabbitMQconnector" queue="queueNameToListen"/>
</flow>
to verify if the code worked , put a message on the queue you want to listen and run the mule application, if that message gets consumed properly you will see the message as dequed and no pending messages.
hope this helps!
good luck!
The example you provided in your question will work just fine. You just need to add exchangeType="topic" to the endpoint component.
More info available in the AMQP connector guide below:
https://github.com/mulesoft/mule-transport-amqp/blob/master/GUIDE.md
Example flow:
<amqp:connector name="amqpConnector" host="${host}" port="${port}" username="${username}" password="${password}"/>
<amqp:endpoint name="myExchange" exchangeName="${exchangeName}" queueName="${topicName}" exchangeType="topic" exchangeAutoDelete="false" exchangeDurable="true" queueAutoDelete="false" queueDurable="true"connector-ref="amqpConnector"/>
<flow name="main">
<amqps:inbound-endpoint ref="myExchange"/>
<flow-ref name="doSomething"/>
<amqp:outbound-endpoint ref="myExchange"/>
</flow>
I have setup rabbitMQ and created application with http inbound.
<flow>
<http:inbound />
<amqp:outbound ../>
</flow>
the above flow works perfectly. but when i switch to https:inbound it get fails with error message 'invalid value in table'
<flow>
<https:inbound />
<amqp:outbound ../>
</flow>
For workaround, remove outbound property - LOCAL_CERTIFICATE before calling amqp.
This is a know issue however there is no public issue yet, just an internal one (I´m the official maintainer).
This will be fixed as soon as possible.
I work with Mule. And I have spring bean
<spring:bean id="`MyPropertiesSaver`" name="MyPropertiesSaver" class="MyPropertiesSaver">
<spring:property name="prop_name" value="${PROP_VALUE}"/>
</spring:bean>
Also I work with file in flow
<flow name="Handler" doc:name="Handler">
<file:inbound-endpoint `path="${PROP_VALUE}"` moveToPattern="#[header:originalFilename].txt" responseTimeout="10000" doc:name="File"/>
...
</flow>
So I get PROP_VALUE from system variables. I want to change path of file while programm is running. I change prop_name of class MyPropertiesSaver using MX4J. But path="${PROP_VALUE}" does not change. That's why I want to get prop_name from MyPropertiesSaver. Somthing like this
path="MyPropertiesSaver.prop_name"
How can I do that?
You need to extend the file message receiver to allow to externally set of the fileDir and disconnect-connect when this happens. Then in your connector use a service-override to use that customised message receiver.
Having a Dynamic Endpoint for File Inbound is not possible.
File Inbound should know where to look for when the flow is started.
If your usecase demands a dynamic file location and reading you can try the workaround with Mule Requester module.
Read throubh the following link for more details.
Unable to create dynamic file inbound endpoint in mule
Hope this helps.
From Mule, I am trying to build a flow to read the messages from active MQ and send it to DB. So within my flow, I have a JMS inbound endpoint,followed by Java component, where I am making JDBC connections.Now my problem is , I want to implement a rollback which will try to rollback messages to Q if there is any connection problem on the backend.
This does seems to be working, but partially. So when there is an exception on the java component, I see messages are rolling back. But even after reaching maximum redelivery attempts, I do not see the block under section getting executed.
What type of transaction should I be using in this case.?
Please suggest how to fix this issue.
`
<jms:inbound-endpoint queue="TestQ"
connector-ref="ActiveMQ" doc:name="JMS" >
<ee:multi-transaction action="ALWAYS_BEGIN"></ee:multi-transaction>
</jms:inbound-endpoint>
<component class="com.test.JDBCComponent" doc:name="Java"/>
<rollback-exception-strategy
maxRedeliveryAttempts="3" doc:name="Rollback Exception Strategy">
<on-redelivery-attempts-exceeded
doc:name="Redelivery exhausted">
<logger message="EXHAUSTER REDILVERY" level="INFO" doc:name="Logger" />
</on-redelivery-attempts-exceeded>
</rollback-exception-strategy>
</flow>
`
It should work aditya , as if this is not working you can use untill - successful scope.
https://docs.mulesoft.com/mule-user-guide/v/3.5/until-successful-scope
<jms:activemq-connector name="Active_MQ"
brokerURL="tcp://localhost:61616" maxRedelivery="5" />
maxRedelivery attribute in the connector definition goes in conflict with maxRedeliveryAttempts of the roll-back strategy
The smallest wins..
As per the transaction looks correctly configured.