What is the difference between using private flow versus VM transport?

MuleSoft Image

In this post, I will show the differences between chaining with VM transport versus chaining with flow reference. When I need to divide my into reusable units, I often break them into smaller and then chain them together in a main flow.

Flows can be chained together using flow-refs or using VM connectors; most recent examples use the flow-refs. However, flow-refs are a Mule 3 addition and in Mule 2 VM connectors were used to chain flows.

Given this background and with flow-refs being more of the recommended approach, is there a scenario when we would want to use VM connectors? Yes, there is! But the majority of the time flow-refs are preferred over the VM transport and here is why.

* VM connector creates a transport barrier in the flow: In a transport barrier, your Mule message goes through an entire serialization and deserialization process which results in a new Mule message with the same payload. Read about the effect of transport barrier on a mule message here.

When one would prefer to use a VM transport over a flow reference

One case would be that VM endpoints enable message redelivery strategies to be configured in your exception handling blocks – this is not possible with flow-refs. VMs can do this because they internally use a queue to hold messages while flow-refs are similar to simple method calls.

Look at the sample flow below; here the message will be redelivered five times and is enabled by the use of VM inbound

VM-inbound

Contrast that to a private flow and chaining with flow-refs, if an exception occurs in the called flow even though we have a rollback strategy configured it will NOT execute because there is no internal queue involved.

flow and vmflow

To summarize, don’t hesitate to use VM transports if you need redelivery of messages. There are also differences in the use of thread pools between private flows and VMs, but I will leave that for another post. The sample source code for this post is available on Github

If you want to learn more about Mule ESB, Mule ESB is a great platform for developers to connect applications together quickly and easily. Feel free to try Anypoint Platform for 30 days


We'd love to hear your opinion on this post


4 Responses to “What is the difference between using private flow versus VM transport?”

  1. When VM is used the performance is better due to the fact that it grasp the seda architecture?

    • Thanks for asking that, I would say that flow-ref would “typically” have better performance compared to a VM because VM is a transport barrier and therefore a Mule message has to be serialized and de-serialized each time it goes over the VM transport. This is not the case with a flow-ref.

  2. Is there any limitation on size of message via vm transport?

    • The VM transport is an in-memory transport and uses queues internally, so it is limited by the JVM heap size. Consider using streaming connectors for large messages. Hope this helps.