Cloud Messaging

Implement the messaging functionality by bringing the JMS-based messaging capabilities. Publish messages and subscribe to those messages with ease.

Overview

Messaging is one of the integration patterns used by enterprise applications to solve integration challenges. Messaging systems allow independent applications to work together to accomplish some common task by means of exchanging messages without requiring direct connections. Messaging is also known as message-oriented middleware. The webMethods.io Integration messaging solution allows you to implement the publish/subscribe or point-to-point messaging styles by bringing the JMS-based messaging capabilities.

Note: Messaging is not available by default for a tenant. To enable this functionality, contact Software AG Global Support.

Terminology

High-level tasks for configuring messaging

Task Notes
Enable the messaging functionality Contact Global Support to enable the messaging functionality for your tenant in webMethods.io Integration.
Create a Destination The destination type can be a queue or a topic. The messaging server can hold up to 10000 messages per queue or topic.
To create a queue, go to Messaging > Queues > Add Queue. See the examples that follow, on how to create a queue.
To create a topic, go to Messaging > Topics > Add Topic. See the examples that follow, on how to create a topic.
Create a publisher FlowService or WorkFlow Create a FlowService or Workflow, which publishes specified messages to the queue or topic. The input data to the publisher FlowService or Workflow can be a string or a document.
Create a consumer FlowService or WorkFlow Create a consumer FlowService or Workflow. If the queue or topic receives messages, then the consumer FlowService or Workflow in the subscriber runs.
Create a Subscriber Subscriber listens to the messages received by the queue. You can also create a consumer FlowService or Workflow while creating a subscriber.
To create a subscriber, go to Messaging > Subscribers > Add Subscriber. See the examples that follow, on how to create a subscriber.
Run the publisher FlowService or Workflow The consumer FlowService or Workflow automatically runs when you run the publisher FlowService or Workflow. This is because, when you run the publisher FlowService, the publisher FlowService sends the message to the queue and as the subscriber is listening to the queue, it runs the consumer FlowService provided in the subscriber.

Metrics associated with Queues and Topics

After you create a queue or a topic, the metrics available for a queue or a topic appear when you click the queue or the topic link to view the details.



Other Considerations

Publish a message and subscribe to it to run a FlowService

Summary

In this example, we will publish a message and subscribe to it to run a FlowService.

Basic Flow

1.Log in to webMethods.io Integration and create a project, for example, Messaging_Ops. You can also select an existing project. Then click the Messaging tab.

2.On the Queues page, click Add Queue to create a queue (Q1) where you can publish the messages.

3.Click Save. After you click Save, queue Q1 appears on the Queues page.

4.Now let us create the publisher FlowService. Click the FlowServices tab and on the FlowServices page, click the icon.
5.Provide a name, for example, publisher_flowservice, and an optional description for the new FlowService. Type messaging and select the Messaging application, publish action, the destination type as Queue, the destination as Q1, and the account as DefaultAccount. You can also add a new destination by clicking the Add Destination option. The publisher FlowService will publish messages to the queue (Q1).

5.Click the edit mapping icon to map the input and output fields.

6.Double-click on the String field, enter the message I want to publish a message!, and then save the publisher FlowService.

7.Now let us create the consumer FlowService, for example, consumer_flowservice. You can either create the consumer FlowService directly from the FlowServices page or create it while creating a subscriber. The subscriber listens to messages that the queue receives. If the queue receives messages, then the consumer FlowService in the subscriber will run.

Let us create the consumer_flowservice from the Subscribers page. To do that, click the Messaging tab and then click Subscribers.

8.On the Subscribers page, click Add Subscriber. Provide the Subscriber Name (Subscriber1), an optional description, select the Destination Type as Queue and then select the Destination as Q1 created earlier.

9.Select the Invocation Type as FlowService and in the Select Invocation field, click the icon to create the consumer_flowservice. Note that to prevent repeated executions of the selected invocation, ensure that the selected FlowService or Workflow does not publish messages to the same queue or topic selected in the Select Destination field.

Note: Only FlowServices that have JMS trigger specifications will be listed in the Select Invocation field in the Subscriber window. Further, as you have created the consumer FlowService from the Subscribers page, the trigger specification reference appears automatically.

10.Now let us run the publisher FlowService (publisher_flowservice).
On the FlowServices page, click on the publisher_flowservice and then click the run icon. The consumer_flowservice will run automatically. The publisher_flowservice sends the message to the queue Q1 and as the Subscriber1 is listening to Q1, it runs the consumer_flowservice provided in the Subscriber1.

11.Go to Monitor > Execution Results > FlowService Execution and in the Executions panel, click consumer_flowservice.
The Invocation Channel for the consumer FlowService is Messaging Subscriber. The invocation channel for the publisher FlowService is User Interface.

Publish a message and subscribe to it to run a Workflow

Summary

In this example, we will publish a message and subscribe to it to run a Workflow.

Basic Flow

  1. Log in to webMethods.io Integration and create a project, for example, Messaging_Ops. You can also select an existing project. Click the Workflows tab and then click the icon. On the Start Building your Workflow page, click Create New Workflow to start creating a workflow to publish the message.
  2. On the workflow canvas, search for the messaging connector. Drag and drop the Messaging connector on the canvas.

  3. Now let us configure the Messaging connector. Click on the warning icon as shown in the above image. In the Messaging window, select the publish action, provide a name for the action (publisher_step), select the destination type as Topic, add a new destination (topic_name) by clicking the icon, and select DefaultAccount in the Connect to Messaging field. Click Next.

  4. Type the message you want to send or that needs to be published (My message!) in the string field and click Next.

  5. Click Test to test the action.

    The OUTPUT panel shows that the message has been sent. Click Done to return to the workflow canvas.

  6. Connect the messaging step to the Stop button, provide a name for the workflow (publisher_workflow) and save the workflow.

  7. Now let us create the consumer workflow (consumer_workflow), which runs when a message is sent to the topic. Click the Workflows tab and then click the icon. On the Start Building your Workflow page, click Create New Workflow. Click the Settings icon on the start step and on the Trigger window, search for the Messaging Service trigger.

  8. Select the Messaging Service trigger and click Next. On the Messaging Service window, fill up the Messaging Service fields. Provide a Trigger Label. In the Select Trigger field, select New Message. Provide the Subscriber Name (workflow_subscriber), select the Destination Type (Topic), and the Destination (topic_name). Click Save.

    On the Test Trigger window, if you want to test the trigger, you need to run the publisher workflow and then click on the Test button to see whether the message is received. On the Test Trigger window, click Skip and then click Done.

  9. The consumer workflow will log the message that it receives. Search for the Logger connector and drag and drop the Logger connector on to the canvas.

  10. Click the warning icon on the Logger and then click Next.

  11. On the Logger mapping screen, drag and drop string to the Log Data field. Click Next and then click Done.

  12. Connect Logger to the Stop step, provide a name for the workflow (consumer_workflow), and then Save the workflow.

  13. Now let us run the publisher workflow. Go to the Workflows page, select the Edit option available on the publisher workflow, and then run the publisher workflow.

  14. Now go to the Monitor > Execution Results > Workflow Execution page and check whether both the publisher workflow and the consumer workflow have executed. The publisher workflow is executed manually while the consumer workflow is Executed Via Trigger.

Publish and consume a document

Summary

In this example, we will do the following high-level tasks:

  1. Create a publisher FlowService, which publishes a document.
  2. Create a consumer FlowService, which logs data sent in the published document.
  3. Create a consumer workflow, which logs the same data sent in the published document.
  4. Run the publisher FlowService and check if both the consumers have executed successfully.

Basic Flow

  1. Log in to webMethods.io Integration and create a project, for example, Messaging_Ops. You can also select an existing project. Click Messaging > Topics.
  2. Create a new topic and name it as todays_quote. Save the topic.

  3. Create a document type, doc_quote from scratch, which we want to publish. To do that, in your project, go to Configurations > FlowService > Document Types and click Add Document Type > Build from scratch. Click Load JSON. Paste and load the JSON content.

  4. Create a publisher FlowService, publish_doc_quote, which will publish the doc_quote document to the topic. Type messaging and select the Messaging connector, publish action, the destination type as Topic, the destination as todays_quote, and the account as DefaultAccount.

  5. Click Define I/O and select the Add a new set option. Specify the Name as quote, the Type as Document Reference and Document reference as doc_quote. Click Done.

  6. Click the Edit Mapping icon and map the quote document reference from the input pipeline to the data field in the JMS message body. Save the publisher FlowService.

  7. Let us now create the consumer FlowService, consume_doc_quote. Create a consumer FlowService, click the Define I/O option and select the Messaging Service from the Specification Reference. Click Done.

  8. In order to get the fields of the published quote document, we need to first map the data to doc_quote in the transform pipeline step. To do that, add the Transform Pipeline step and click the Edit Mapping option. Add a document reference field in the pipeline output by clicking the + icon. In the Pipeline Output window as shown, provide the Name as doc_quote, Type as Document Reference, and Document reference as doc_quote.

  9. Map the data field under the JMSMessage body to the newly created doc_quote field. Close the pipeline view.

  10. Now let us add the log step, which will log the quote that was received. Click on the + icon and add the logCustomMessage step.

  11. Click on Edit mapping, double click on the message field and in the Set Value-message window, add the following custom message: Today’s quote is “%/doc_quote/content%“, by “%/doc_quote/author%. Also select the Perform pipeline variable substitution option. Click Save and then again click Save to save the FlowService.

  12. Create a subscriber, todays_quote_subscriber, for consuming the messages sent to the topic todays_quote. Go to Messaging > Subscribers > Add Subscriber and specify the fields as shown. Click Save.

  13. Create another subscriber, todays_quote_subscriber2, for consuming the messages sent to the topic, todays_quote. To do so, create a new workflow and name the workflow as consume_doc_quote_workflow. Click the Settings icon on New Message to add the messaging service trigger step.

  14. Type messaging and select the Messaging Service trigger. Click Next. In the Messaging Service window, specify the Subscriber Name as todays_quote_subscriber2, Destination Type as Topic, and the Destination as todays_quote. Click Save.

  15. To get the quote document payload, let us test the trigger. To test the trigger, open the publisher FlowService publish_doc_quote in a separate tab, and then click the Run icon. Add the input values as shown and then click Run.

  16. Go to the previous tab where the consume_doc_quote_workflow is open and click Test. The OUTPUT tab contains the document that was published in the earlier step. Click Done.

  17. As we want to log the message when consume_doc_quote_workflow is run, search for the logger connector and drag it to the canvas. Configure the logger connector by clicking on the Settings icon and click Next. Note that the quote document is available in the JMS message body data fields.

  18. Paste the following text in the log data box: Today’s quote is “{{$trigger.JMSMessage.body.data.content}}” by {{$trigger.JMSMessage.body.data.author}}. Click Next and then click Done.

  19. Connect the logger step to the stop step and then click Save to save the consumer workflow.

  20. Now run the publish_doc_quote flowservice to publish the document type doc_quote to the topic todays_quote. Go to the publish_doc_quote flowservice and run it by providing the following details as shown. This will publish the document to the topic.

  21. To see if the document has been consumed, go to the Monitor page and verify that the consumer FlowService consume_doc_quote and the consumer workflow have executed.

    As you can see, the message is logged.

  22. Click on the consumer workflow link and select the logger step to see the log message.