Calling a Synchronous Queue from Mendix

Last modified by Erik Bakker on 2025/03/02 09:36

In this microlearning, we will integrate Mendix with eMagiz using the eMagiz Mendix module. Here, we will guide you through calling a synchronous queue from Mendix, which is essential for efficient data exchange between your systems.

Should you have any questions, please get in touch with academy@emagiz.com.

1. Prerequisites

  • Intermediate knowledge of the eMagiz platform
  • Access to a Mendix application (potentially via an external party)
  • Access to the Deploy phase of your eMagiz project
  • A connection between Mendix and eMagiz Designed, Created, and in the active release
  • Using the "eMagiz Connector" in the Mendix Marketplace.
  • Initial installation done.
  • Initial configuration done.

2. Key concepts

This microlearning centers around calling a synchronous queue from Mendix.

  • With eMagiz Connector, we mean a Mendix module developed and maintained by eMagiz that simplifies connecting a Mendix application to an eMagiz project for data traffic between both systems.

To call a synchronous queue from Mendix, you need the following:

  • The destination (i.e., the queue on which you want to place the data)
  • Execute microflow (the microflow that will process the data and send it to eMagiz)
  • The message's payload (either as a Mendix object or a string variable).
Warning

All changes in eMagiz need to be activated by adding the changes to the eMagiz release and activating said release. When setting up the initial connection, the Mendix system must be in the eMagiz release before connecting from Mendix to eMagiz with an activation key.

3. Calling a synchronous queue from Mendix

With the help of the Mendix module (called eMagiz Connector) created by the eMagiz team, you can easily connect between Mendix and eMagiz for data integration. This microlearning will focus on calling a synchronous queue from Mendix. For sending data from Mendix, we offer two options to send data:

  • Sending an object from Mendix to eMagiz.
  • Sending a string from Mendix to eMagiz.

Below, we will detail how to configure each option for sending data synchronously from Mendix.

3.1 Sending asynchronous messages with export mapping

To send data from Mendix, you must define several configuration options in the Mendix project. In this example, we will look at the configuration using the export and import mapping in Mendix. In the subsequent paragraph, we will look at configuring the functionality if you do not want to use the export and import mapping.

In eMagiz, you will see a flow in Create that you cannot edit, as the autogenerated functionality provided by eMagiz is all you need. Once done, add the flow to a release to make sure it is transported to Deploy and ready to be used in a Mendix application.

Information

The entry version must be altered when you change your system messages in Design.

In parallel, earlier or later, the Mendix application needs to be developed to handle sending messages to eMagiz. This is done by adding the following configuration to the existing "After Startup" microflow.

3.1.1 Startup action

In Mendix, you must add the "StartSyncMessageProducer" Java Action to the after startup flow. The most important configuration items here are the following.

intermediate-mendix-connectivity-start-a-synchronous-producer-in-mendix.png
  

  • The destination (i.e., the queue to which you want to send the messages). This can be supplied by the eMagiz developer or found under Deploy -> Mendix Connectors should you have access to the eMagiz model in question.
  • The export and import mapping (based on the system message definitions). These definitions can be determined by the eMagiz developer (and then shared with the Mendix developer) or determined by the Mendix developer (and then shared with the eMagiz developer).

3.1.2 Send action

On top of the start action, you must also configure a Send action and include this in the microflow responsible for sending data to eMagiz and receiving a response in return. In this case, you must take the "SendAndReceiveMessage" Java action. The most important configuration items here are the following.

intermediate-mendix-connectivity-send-synchronous-messages-from-mendix-java-action-config.png

  • The destination (i.e., the queue to which you want to send the messages). This can be supplied by the eMagiz developer or found under Deploy -> Mendix Connectors should you have access to the eMagiz model in question.
  • The export object (the root entity of the system message definition of the request). This definition can be determined by the eMagiz developer (and then shared with the Mendix developer) or determined by the Mendix developer (and then shared with the eMagiz developer).
  • The import object (the root entity of the system message definition of the response). This definition can be determined by the eMagiz developer (and then shared with the Mendix developer) or determined by the Mendix developer (and then shared with the eMagiz developer).
3.1.2.1 Retry behavior (Optional)

When an error occurs during message sending with the eMagiz Connector, no retry behavior is implemented by default. Depending on the application's structure and error-handling configuration, this could potentially lead to data loss. This problem can be mitigated by executing the send Java action in a Task Queue. This Task Queue can be configured with retry behavior to maximize the chance of delivery.

You must create a Task Queue to configure retry behavior when sending a message. The Mendix Documentation provides instructions on how to do this.

After creating the Task Queue, open the Java action in your microflow, which you are using to send messages. A checkbox at the bottom of this screen says, “Execute this Java action in a Task Queue.” Enable this checkbox and select the Task Queue you just created. After selecting the Task Queue, the option to configure retry behavior will be shown. Depending on your use case, you can choose a fixed delay or an exponential back-off. The difference between these options can be found on Mendix's previously mentioned documentation page

intermediate-mendix-connectivity-task-queue-example-config.png

3.2 Sending asynchronous messages without export mapping

We just saw the example when working with the export mapping. Now, we turn our attention to an instance without that mapping. In these cases, the string is just passed to the execute microflow, and you can determine in Mendix yourself what to do with it.

In eMagiz, you will see a flow in Create that you cannot edit, as the autogenerated functionality provided by eMagiz is all you need. Once done, add the flow to a release to make sure it is transported to Deploy and ready to be used in a Mendix application.

Information

The version of your entry needs to be altered when you make changes to your system messages in Design.

In parallel, earlier or later, the Mendix application needs to be developed to handle sending messages to eMagiz. This is done by adding the following configuration to the existing "After Startup" microflow.

3.2.1 Startup action

In Mendix, you must add the "StartSyncStringProducer" Java Action to the after startup flow. The most important configuration items here are the following.

intermediate-mendix-connectivity-start-a-synchronous-producer-in-mendix-string.png
  

  • The destination (i.e., the queue from which you want to consume the request messages). This can be supplied by the eMagiz developer or found under Deploy -> Mendix Connectors should you have access to the eMagiz model in question.

3.2.2 Send action

On top of the start action, you must also configure a Send action and include this in the microflow responsible for sending data to eMagiz and receiving a response in return. In this case, you must take the "SendAndReceiveString" Java action. The most important configuration items here are the following.

intermediate-mendix-connectivity-send-synchronous-messages-from-mendix-java-action-config-string.png

  • The destination (i.e., the queue to which you want to send the messages). This can be supplied by the eMagiz developer or found under Deploy -> Mendix Connectors should you have access to the eMagiz model in question.
  • The export object (the string payload you want to send to eMagiz). This definition can be determined by the eMagiz developer (and then shared with the Mendix developer) or determined by the Mendix developer (and then shared with the eMagiz developer).
3.2.2.1 Retry behavior (Optional)

When an error occurs during message sending with the eMagiz Connector, no retry behavior is implemented by default. Depending on the application's structure and error-handling configuration, this could potentially lead to data loss. This problem can be mitigated by executing the send Java action in a Task Queue. This Task Queue can be configured with retry behavior to maximize the chance of delivery.

You must create a Task Queue to configure retry behavior when sending a message. The Mendix Documentation provides instructions on how to do this.

After creating the Task Queue, open the Java action in your microflow, which you are using to send messages. A checkbox at the bottom of this screen says, “Execute this Java action in a Task Queue.” Enable this checkbox and select the Task Queue you just created. After selecting the Task Queue, the option to configure retry behavior will be shown. Depending on your use case, you can choose a fixed delay or an exponential back-off. The difference between these options can be found on Mendix's previously mentioned documentation page.

intermediate-mendix-connectivity-task-queue-example-config.png

4. Key takeaways

To call a synchronous queue from Mendix, you need the following:

  • The destination (i.e., the queue from which you want to retrieve the information)
  • Execute microflow (the microflow that will process the data that needs to be sent to eMagiz)
  • Optionally, you can define an export and import mapping with the relevant options.
  • Optionally, you can use the "task queue" functionality of Mendix to send messages via this task queue to eMagiz to safeguard against connection problems.
Warning

 To make a connection in allowing data to travel between A and B, you need to install and do a basic configuration before you can set up this specific communication.

5. Suggested Additional Readings

If you are interested in this topic and want more information, please read the release notes provided by eMagiz that accompany the eMagiz Mendix Connector version you have selected. Furthermore, check out these links: