Reputation: 584
I want to instantiate a bean and send/receive vm:// messages to/from flows. I followed this but the overridden methods do not get any messages. Do I need to instantiate a VM connector and pass its reference to the bean that implements MuleSubscriptionEventListener first?
Upvotes: 0
Views: 1037
Reputation: 5115
VM are perfectly valid in many cases, specially in Mule EE with the HA cluster.
If what you need is to send to vm from a spring referenced java component you have two options to consider:
Upvotes: 2
Reputation: 3860
Generally Mule encourages developers to not use vm-endpoints anymore, see for example the Mule VM docs
Quote:
The VM transport has often been used to implement complex integrations made up of multiple applications. Improvements in Mule 3 obviate the need for VM in many cases. You can use Flow References to directly reference one flow from another without a transport in the middle.
I would really consider Flow References, they are much better. For VM-Endpoints Mule creates a entire different thing (passing variables around in the header of the message payload) et cetera.
VM Endpoints only make sense if you want to make certain sub-flows possible to call from external, like for example from a Unit-Test.
I think the implementation described in the docs you linked are quite complicated. Why are you not simply putting a Java-Component into the Mule flow that links to Spring bean? That way you can fully control the invocation from Mule to Spring. It can be either a Java Transformer or a Java Component. I think so far Java Component sounds more like what you need:
See: https://docs.mulesoft.com/mule-user-guide/v/3.6/using-spring-beans-as-flow-components
Upvotes: 0