Wiki source code of Asynchronous Routing

Last modified by Danniar Firdausy on 2024/09/04 09:01

Hide last authors
Erik Bakker 16.1 1 {{container}}{{container layoutStyle="columns"}}(((
Danniar Firdausy 37.6 2 In this microlearning, we will dive into the essentials of asynchronous routing and its importance in managing message distribution within the five-layer messaging model. We will cover the key concepts, including how to route messages efficiently and manage output control.
eMagiz 1.1 3
Danniar Firdausy 37.6 4 If you have any questions along the way, feel free to reach out to us at [[academy@emagiz.com>>mailto:academy@emagiz.com]].
eMagiz 1.1 5
6 == 1. Prerequisites ==
7
8 * Basic knowledge of the eMagiz platform
9
10 == 2. Key concepts ==
11
12 This microlearning centers around asynchronous routing for messaging flows in eMagiz.
Danniar Firdausy 37.6 13 * With asynchronous routing we mean: The process that routes messages that it receives to the correct outbound queue based on some metadata.
eMagiz 1.1 14
15 == 3. Asynchronous routing ==
16
Danniar Firdausy 37.6 17 Asynchronous routing plays a crucial role in the distribution of messages it receives to one or more offramps. In eMagiz, the asynchronous routing has three relevant parts:
eMagiz 1.1 18
Danniar Firdausy 37.6 19 * All asynchronous onramps that send data to the routing.
20 * Based on a decision made within the routing the message is routed to one or more offramp queues.
21 * Each offramp queue will receive data based on the decision unless you add another filter before the messages are sent to the offramp queue.
eMagiz 1.1 22
23 === 3.1 Make a decision ===
24
25 In asynchronous routing, you can build your decision model on which the routing needs to make the decision.
26
Danniar Firdausy 37.12 27 The best practice for setting up your asynchronous routing process is to use one SpEL expression that determines to which offramp queues a messages needs to be routed. The SpEL expression looks as follows:
Carlijn Kokkeler 35.1 28
Danniar Firdausy 37.9 29 {{code language="xml"}}
Danniar Firdausy 37.10 30
Danniar Firdausy 37.8 31 headers.{technicalnameofproject}\_targetSystem.split(',').![#this.trim()+#root.headers.{technicalnameofproject}_messageType]
Danniar Firdausy 37.11 32
Carlijn Kokkeler 35.1 33 {{/code}}
eMagiz 1.1 34
35 This SpEL expression does the following things:
36
Erik Bakker 20.1 37 * It looks for the header called {technicalnameofproject}\_targetSystem and will split each entry based on the separator (a comma)
38 * It will trim the result of this split and combine it the value in the header called {technicalnameofproject}\_messageType
39 * For every unique combination it will search to a pre-configured list to see to which channel the message should be sent
eMagiz 1.1 40
41 In the standard router component this will look as follows:
42
Erik Bakker 16.1 43 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-asynchronous-routing--routing-decision.png]]
eMagiz 1.1 44
45 In this simple case, we only have one channel as a result because all routings start simple.
46 The moment you add new offramps to your project you need to add the new entry(s) to this list.
47 Doing so is easy when you are in Start Editing Mode. Simply open the router component and select the button New Mapping
48
Erik Bakker 16.1 49 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-asynchronous-routing--new-value-mapping.png]]
eMagiz 1.1 50
51 In here you fill in the correct unique combination of a target system and the message type and select the channel you want to route the message to.
52 When you are satisfied you can press Save and the new entry will be registered in eMagiz.
53
54 Don't forget to make a new version and deploy it to actualize your changes.
55
56 === 3.2 Control output ===
57
Erik Bakker 23.1 58 As the asynchronous routing plays a role in routing messages between all asynchronous flows in the messaging solution you can imagine that making changes does not need to happen lightly. The other aspect is that when multiple projects are being built at the same time the asynchronous routing will house a multitude of changes that need to go to Acceptance or Production at the same time.
eMagiz 1.1 59
Erik Bakker 22.1 60 One control mechanism we consider a best practice to guard yourself against those risks is to add a filter before data is placed on the offramp queue.
61 By doing this consistently you can control when a specific offramp can receive data on any environment. In other words, when a certain system is not ready yet to receive data on Acceptance or Production but is ready on Test you can control this behavior with this solution.
eMagiz 1.1 62
63 Below you see how this will look on flow level.
64
Erik Bakker 16.1 65 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-asynchronous-routing--filter-construction.png]]
eMagiz 1.1 66
67 When we zoom in on the filter component we see a simple SpEL expression that checks the value of a certain property.
68 When the value of the property is true the message can pass. If the value of the property is any other value the message will be halted.
69 The best practice would be to work with false to get clarity on what the intended use of the property value is.
70
Erik Bakker 16.1 71 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-asynchronous-routing--filter-configuration.png]]
eMagiz 1.1 72
73 === 3.4 Step by step guide ===
74
75 Furthermore, as a best practice, we give you a short guide that you can add to your asynchronous routing as annotations
76 to ensure that you always know what you need to do to make this a reality.
77
78 Steps to follow when adding an integration to the routing Part I:
79
Erik Bakker 21.1 80 * Add a header in the onramp named {technicalnameofproject}\_targetSystem (if this is not done yet)
81 * Fill this header with a value that should be defined as a property (naming convention = systemname.messagetype.targetsystems)
82 * This property should be created in Test, Accp, and Prod and filled with all target systems for a certain message type (notation = systemname1,systemname2,systemname3)
83 * In the routing a standard router should be used as the first building block after receiving the input.
eMagiz 1.1 84
85 Part II
86
Erik Bakker 21.1 87 * In this standard router a SpelExpression has to be defined **once** that concatenates the following headers: {technicalnameofproject}\_targetSystem and {technicalnameofproject}\_messageType.
88 * For every unique combination there is a value that should be specified alongside the channel on which to put the message (this should be a channel that ultimately leads to the correct offramp queue)
89 * For every channel that leads to a JMS outbound channel adapter a filter needs to be added to make sure that each output option can be turned on or off easily. This to prevent that messages are sent to a system that does not expect them then
90 * This filter should look like this: '${routing.monitor.detorem.enabled}' == 'true'. The naming convention of said property is routing.targetsystem.messagetype.enabled.
eMagiz 1.1 91
92 === 3.5 The result ===
93
94 The result of setting up your asynchronous routing in this manner
95 is that you have one single point of entry, one single piece of decision logic, and a way to control the output per specific output channel.
96
Erik Bakker 16.1 97 [[image:Main.Images.Microlearning.WebHome@crashcourse-messaging-asynchronous-routing--simple-asynchronous-routing-example.png]]
eMagiz 1.1 98
99
Eva Torken 37.1 100 == 4. Key takeaways ==
eMagiz 1.1 101
Danniar Firdausy 37.15 102 * Centralize Decision Making: Use a single component to determine how messages are routed to different channels.
103 * Output Control: Implement filters to manage when data is sent to each queue, ensuring messages are only routed when appropriate.
104 * Documentation: Use the annotations within your asynchronous routing setup to document and maintain clarity of the configuration.
eMagiz 1.1 105
Eva Torken 37.1 106 == 5. Suggested Additional Readings ==
eMagiz 1.1 107
Danniar Firdausy 37.5 108 If you are interested in this topic and want more information on it please read the help text provided by eMagiz and read the following link:
eMagiz 1.1 109
Danniar Firdausy 37.2 110 * [[Store (Menu)>>doc:Main.eMagiz Store.WebHome||target="blank"]]
111 ** [[Accelerators (Navigation)>>doc:Main.eMagiz Store.Accelerators.WebHome||target="blank"]]
112 *** [[Routing - SpEL (Store Item)>>doc:Main.eMagiz Store.Accelerators.Routing - SpEL.WebHome||target="blank"]]
Danniar Firdausy 37.3 113 * [[Intermediate Level (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.WebHome||target="blank"]]
114 ** [[Data traffic routing (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Data traffic routing.WebHome||target="blank"]]
Danniar Firdausy 38.2 115 *** [[Implementation of routing decisions (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Data traffic routing.intermediate-data-traffic-routing-implementation-of-routing-decisions||target="blank"]]
Danniar Firdausy 37.3 116 *** [[Synchronous routing (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Data traffic routing.intermediate-data-traffic-routing-synchronous-routing||target="blank"]]
117 * [[Asynchronous Routing (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=%22asynchronous+routing%22||target="blank"]]
Erik Bakker 16.1 118 )))((({{toc/}}))){{/container}}{{/container}}