Wiki source code of Calling a Synchronous Queue from Mendix
Last modified by Erik Bakker on 2025/03/02 09:36
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{container}}{{container layoutStyle="columns"}}((( | ||
2 | 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. | ||
3 | |||
4 | Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. | ||
5 | |||
6 | == 1. Prerequisites == | ||
7 | |||
8 | * Intermediate knowledge of the eMagiz platform | ||
9 | * Access to a Mendix application (potentially via an external party) | ||
10 | * Access to the Deploy phase of your eMagiz project | ||
11 | * A connection between Mendix and eMagiz Designed, Created, and in the active release | ||
12 | * Using the "eMagiz Connector" in the Mendix Marketplace. | ||
13 | * Initial [[installation>>doc:Main.eMagiz Academy.Microlearnings.Novice.Mendix Connectivity.novice-mendix-connectivity-install-emagiz-mendix-connector.WebHome||target="blank"]] done. | ||
14 | * Initial [[configuration>>doc:Main.eMagiz Academy.Microlearnings.Novice.Mendix Connectivity.novice-mendix-connectivity-configure-emagiz-mendix-connector.WebHome||target="blank"]] done. | ||
15 | |||
16 | == 2. Key concepts == | ||
17 | |||
18 | This microlearning centers around calling a synchronous queue from Mendix. | ||
19 | * 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. | ||
20 | |||
21 | To call a synchronous queue from Mendix, you need the following: | ||
22 | |||
23 | * The destination (i.e., the queue on which you want to place the data) | ||
24 | * Execute microflow (the microflow that will process the data and send it to eMagiz) | ||
25 | * The message's payload (either as a Mendix object or a string variable). | ||
26 | |||
27 | {{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**.{{/warning}} | ||
28 | |||
29 | == 3. Calling a synchronous queue from Mendix == | ||
30 | |||
31 | 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: | ||
32 | |||
33 | * Sending an object from Mendix to eMagiz. | ||
34 | * Sending a string from Mendix to eMagiz. | ||
35 | |||
36 | Below, we will detail how to configure each option for sending data synchronously from Mendix. | ||
37 | |||
38 | === 3.1 Sending asynchronous messages with export mapping === | ||
39 | |||
40 | 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. | ||
41 | |||
42 | 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. | ||
43 | |||
44 | {{info}}The entry version **must** be altered when you change your system messages in Design.{{/info}} | ||
45 | |||
46 | 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. | ||
47 | |||
48 | ==== 3.1.1 Startup action ==== | ||
49 | |||
50 | In Mendix, you must add the "StartSyncMessageProducer" Java Action to the after startup flow. The most important configuration items here are the following. | ||
51 | |||
52 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-start-a-synchronous-producer-in-mendix.png]] | ||
53 | |||
54 | * 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. | ||
55 | * 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). | ||
56 | |||
57 | ==== 3.1.2 Send action ==== | ||
58 | |||
59 | 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. | ||
60 | |||
61 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-send-synchronous-messages-from-mendix-java-action-config.png]] | ||
62 | |||
63 | * 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. | ||
64 | * 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). | ||
65 | * 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). | ||
66 | |||
67 | ===== 3.1.2.1 Retry behavior (Optional) ===== | ||
68 | |||
69 | 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. | ||
70 | |||
71 | You must create a Task Queue to configure retry behavior when sending a message. The [[Mendix Documentation>>https://docs.mendix.com/refguide/task-queue/#create-queue||target="blank"]] provides instructions on how to do this. | ||
72 | |||
73 | 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 | ||
74 | |||
75 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-task-queue-example-config.png]] | ||
76 | |||
77 | === 3.2 Sending asynchronous messages without export mapping === | ||
78 | |||
79 | 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. | ||
80 | |||
81 | 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. | ||
82 | |||
83 | {{info}}The version of your entry needs to be altered when you make changes to your system messages in Design.{{/info}} | ||
84 | |||
85 | 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. | ||
86 | |||
87 | ==== 3.2.1 Startup action ==== | ||
88 | In Mendix, you must add the "StartSyncStringProducer" Java Action to the after startup flow. The most important configuration items here are the following. | ||
89 | |||
90 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-start-a-synchronous-producer-in-mendix-string.png]] | ||
91 | |||
92 | * 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. | ||
93 | |||
94 | ==== 3.2.2 Send action ==== | ||
95 | |||
96 | 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. | ||
97 | |||
98 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-send-synchronous-messages-from-mendix-java-action-config-string.png]] | ||
99 | |||
100 | * 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. | ||
101 | * 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). | ||
102 | |||
103 | ===== 3.2.2.1 Retry behavior (Optional) ===== | ||
104 | |||
105 | 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. | ||
106 | |||
107 | You must create a Task Queue to configure retry behavior when sending a message. The [[Mendix Documentation>>https://docs.mendix.com/refguide/task-queue/#create-queue||target="blank"]] provides instructions on how to do this. | ||
108 | |||
109 | 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. | ||
110 | |||
111 | [[image:Main.Images.Microlearning.WebHome@intermediate-mendix-connectivity-task-queue-example-config.png]] | ||
112 | |||
113 | == 4. Key takeaways == | ||
114 | |||
115 | To call a synchronous queue from Mendix, you need the following: | ||
116 | |||
117 | * The destination (i.e., the queue from which you want to retrieve the information) | ||
118 | * Execute microflow (the microflow that will process the data that needs to be sent to eMagiz) | ||
119 | * Optionally, you can define an export and import mapping with the relevant options. | ||
120 | * Optionally, you can use the "task queue" functionality of Mendix to send messages via this task queue to eMagiz to safeguard against connection problems. | ||
121 | |||
122 | {{warning}} To make a connection in allowing data to travel between A and B, you need to [[install>>doc:Main.eMagiz Academy.Microlearnings.Novice.Mendix Connectivity.novice-mendix-connectivity-install-emagiz-mendix-connector.WebHome||target="blank"]] and do a basic [[configuration>>doc:Main.eMagiz Academy.Microlearnings.Novice.Mendix Connectivity.novice-mendix-connectivity-configure-emagiz-mendix-connector.WebHome||target="blank"]] before you can set up this specific communication.{{/warning}} | ||
123 | |||
124 | == 5. Suggested Additional Readings == | ||
125 | |||
126 | 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: | ||
127 | |||
128 | * [[Novice Level (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Novice.WebHome||target="blank"]] | ||
129 | ** [[Mendix Connectivity (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Mendix Connectivity.WebHome||target="blank"]] | ||
130 | * [[Mendix Connectivity (Search Results)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&l_space_facet=10&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22mendix+connectivity%22||target="blank"]] | ||
131 | |||
132 | )))((({{toc/}}))){{/container}}{{/container}} |