Contact Free trial Login

Example: To Send Messages across Different Apps

Instead of using the <vm:listener> message source, you can consume messages in a VM queue through the <vm:consume> operation.

This operation can consume messages on demand, allowing you to:

  • Dynamically consume from different queues depending on a certain condition.

  • Have a tighter control on the rhythm at which the app consumes messages.

You can also send messages across apps by using Mule domains. Unlike Mule 3.x in which domains were reserved to a handful of supported components, starting in Mule 4, every connector can be placed in a domain.

So, you can create a VM configuration in a domain like in this:

<mule-domain xmlns=""

    <vm:config name="sharedVMConfig">
      <vm:queue queueName="sharedQueue" queueType="PERSISTENT" />


Then you place a listener in an application of the same domain:

<flow name="crossAppListener">
	<vm:listener queueName="sharedQueue" config-ref="sharedVMConfig" />
	<logger />

Then you publish messages from a second application, also of the same domain:

<flow name="crossAppRequester">
	<vm:publish queueName="sharedQueue" config-ref="sharedVMConfig" />

Notice how both the listener and publisher point to the same configuration defined in the domain.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub