Contact Free trial Login

Example: To publish and listen messages through the VM Connector

This procedure shows how to publish a message that is received in a different flow.

  1. Define a flow with a <vm:listener> as a message source, for example:

    <vm:config name="vm">
        <vm:queues>
            <vm:queue queueName="myQueue" queueType="PERSISTENT" />
        </vm:queues>
    </vm:config>
    
    <flow name="listener">
       <vm:listener queueName="myQueue" config-ref="vm" />
       <flow-ref name="yourIntegrationLogic"/>
    </flow>
  2. Feed messages into the newly created queue.

    For example, assume that a flow is triggered by an HTTP request with a JSON payload and that you want to extract the body attribute of that JSON object and publish it to the queue:

        <flow name="publish">
            <http:listener path="/json-here" allowedMethods="POST" config-ref="httpListener" />
            <vm:publish queueName="myQueue">
                <vm:content>#[payload.body]</vm:content>
            </vm:publish>
            <logger/>
        </flow>

    In this example, you can see:

    • The publish operation references the queue created in the config.

    • The content parameter allows you to use DataWeave to build the value to send (without having side effects on the message). Note that if you do not not specify a content, the entire payload will be sent.

    • The publish operation is one-way. Once the message is posted into the queue, the flow continues. The processing on the listening side happens asynchronously. You do not receive a notification about its outcome.

    • The queueName specified in the publish operation must have a matching <vm:listener> element that points to the same queue. If you attempt to publish to a queue for which no listener exists, an error will be raised. This behavior prevents message loss caused by sending messages into a queue that nobody is listening to.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.