简体   繁体   中英

Session variable are wiped out when passing through VM endpoint in Mule ESB ( Uses AMQP)

I'm using very simple flow, From the first flow I'm taking message from AMQP ( Ack Mode: Manual ) and passing it to second flow via VM , In the 2nd flow where I'm using AMQP acknowledgement processor to acknowledge each message.

When we use VM, Both deliver tag and channel tag are wiped out( which is mandatory to AMQP acknowledge message processor as described in this url AMQP acknowledgement mule ). So I'm trying to save the deliver-tag and amqp.channel in session variable.

First time I wondered, Channel value which is stored in session variable is erased when it passed through VM, but can able to see delivery tag.

Observation:

  1. Instead of VM if we use flow-ref . It works fine. But in my case I need to use VM only.
  2. amqp.delivery-tag type (java.lang.long) amqp.channel type (com.rabbitmq.client.impl.ChannelN).

    If the `Type' of amqp.channel causing problem. If so how can I save this in session variable. Please suggest. Please find my config xml.

      <flow name="testrabbitmqFlow1" doc:name="testrabbitmqFlow1" > <amqp:inbound-endpoint queueName="amqp.test.queue" exchangeDurable="true" queueDurable="true" responseTimeout="1000000" connector-ref="AMQP_Test" doc:name="AMQP"> <amqp:transaction recoverStrategy="REQUEUE" action="ALWAYS_BEGIN"/> </amqp:inbound-endpoint> <byte-array-to-string-transformer doc:name="Byte Array to String"/> <set-session-variable variableName="storedeliveryTag" value="#[flowVars['amqp.delivery-tag']]" doc:name="Session Variable"/> <set-session-variable variableName="storeChannel" value="#[flowVars['amqp.channel']]" doc:name="Session Variable"/> <vm:outbound-endpoint exchange-pattern="one-way" path="/test" doc:name="VM"> <vm:transaction action="NONE"/> </vm:outbound-endpoint> 

    Do any one knows how to resolve the issue.

This will never work

<vm:outbound-endpoint exchange-pattern="one-way" ...

First because given that the pattern is one-way the original thread will end, and the message will be put in a seda queue for a different thread pool.

Then because, when you put a message on a transport like VM, Http, etc. Flow variables get lost, and object instances, even if you try to serialize them and send them to another host, it won't make sense to the other host, ie: open a file, try to serialize the descriptor somehow and send it to another host, it won't make sense.

My recomendation is to use a flow-ref rather than vm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM