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.
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 have message in one queue and need to send to other queue(destination) both are active MQs. When destination is down message will be in source Queue. I need to check in continuous intervals whether destination is up r not. if it is up I need to send to destination. I'm facing difficulty in checking the destination availability..,
please help me., Thanks..,
I think in general, this kind of problem is best solved using transactions.
I'm assuming you are working with two different ActiveMQ brokers, which leads to the chance that the destination queue is not available.
In the simplest case, you could accomplish your goal this way:
Start JMS Transaction
Receive message from queue A on broker 1
Do any required logic and/or transformation
Publish message to queue B on broker 2
If successful, commit your JMS transaction
If not, rollback your JMS transaction
Example:
<flow name="simpleExample">
<jms:inbound-endpoint queue="queueA" connector-ref="broker1">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
<flow-ref name="doLogic" />
<jms:outbound-endpoint queue="queueB" connector-ref="broker2">
<jms:transaction action="ALWAYS_JOIN" />
</jms:outbound-endpoint>
</flow>
When the rollback occurs, this method will immediately retry. If you want to control how long to wait before trying again, configure the redelivery policy on the ActiveMQ connector for Broker 1.
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 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>