Changes for page Communication between models
Last modified by Erik Bakker on 2026/01/02 10:29
From version 26.1
edited by Erik Bakker
on 2026/01/02 10:29
on 2026/01/02 10:29
Change comment:
There is no comment for this version
To version 5.1
edited by Erik Bakker
on 2022/06/13 09:39
on 2022/06/13 09:39
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Communicationbetween models1 + XPath Advanced - Default language
-
... ... @@ -1,1 +1,0 @@ 1 -en - Content
-
... ... @@ -1,88 +1,93 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - In thismicrolearningexplainsaboutsharingdata across systemsin amulti-modelenvironment usingeventstreamingand webservices. Itdiscussestheprocesses,bestpractices,andconsiderationsfor implementing theseconcepts.Take alooktogainadeeperunderstanding ofhow communicationbetweensystemsindifferentmodels canbe achieved effectively.2 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we also looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [microlearning](crashcourse-platform-create-transformation-xpath-basic.md). In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [microlearning](intermediate-create-your-transformations-xpath-intermediate.md) if you need a refresher on that. In this microlearning, we will build upon that knowledge and look at some concrete, practical examples that could be useful in your project. 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 6 +* Last update: October 25th, 2021 7 +* Required reading time: 6 minutes 8 + 6 6 == 1. Prerequisites == 7 7 8 -* Expert knowledge of the eMagiz platform 9 -* Fundamental [[eMagiz Multi-model>>doc:Main.eMagiz Academy.Fundamentals.fundamental-emagiz-multi-model-explained.WebHome||target="blank"]] 10 -* Fundamental [[eMagiz Event Streaming>>doc:Main.eMagiz Academy.Fundamentals.fundamental-event-streaming-introduction||target="blank"]] 11 -* Fundamental [[eMagiz API Gateway>>doc:Main.eMagiz Academy.Fundamentals.fundamental-api-gateway-introduction||target="blank"]] 12 -* Fundamental [[eMagiz Messaging>>doc:Main.eMagiz Academy.Fundamentals.fundamental-messaging-introduction||target="blank"]] 11 +* Advanced knowledge of the eMagiz platform 12 +* [[XPath Basic>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]] 13 +* [[XPath Intermediate>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] 13 13 15 + 14 14 == 2. Key concepts == 15 15 16 -* Model - the integration model of a client that runs on a specific cloud slot of eMagiz 17 -* Multi-model - several integration models of a single client 18 +This microlearning focuses on more complex XPath operations. 18 18 19 -When selecting a method to communicate between models always consider the following concepts: 20 -* Security 21 -* Loose coupling 22 -* Maintainability 23 -* Clarity 20 +With XPath Advanced, we mean learning that XPath options are complex but could benefit you in your daily work. 24 24 25 - == 3. Main Multi-ModelIntegrationPatterns==22 +Some of the more complex XPath options are: 26 26 27 -Most users would think that communication via queues to connect two separate eMagiz models is a bright idea. However, this is something that we do not encourage. We discourage this for several practical and technical reasons alike. 24 +* dateTime calculation 25 +* Filter list 26 +* XPath on JSON 27 +* SpEL notation for XPath 28 28 29 -When looking at the practical side of things getting it configured correctly is time-consuming and an error-prone action (as is evident by the question). Furthermore, it can lead to unexpected situations where you make a typo to listen to a queue on which no messages are provided. This queue will, however, be registered on the JMS level (when you activate the flow in question with the custom configuration), which can lead to confusing queue statistics and even more troublesome false-positive alerting based on missing queue metrics or missing consumers. 30 30 31 -On top of that, when you allow one model to write and read from queues registered in another model, maintaining both models will become very complex. This holds for the ones working on the project at the moment but also for those working on it at a later stage and does that need to provide (incidental) support on the environments. 32 32 33 - Anotherpracticalreason for notwanting thisis that wedo not actively support this use case from eMagiz. This means that when we update our technical infrastructure, we will not considerthis scenario. This could lead to additional work in the future and reduced stability of your solution.31 +== 3. XPath Advanced == 34 34 35 - Fromthetechnical point of view,theconsequenceofthis constructionisthatbothmodels need to know each othercertificatesandcredentials,whicharenotconsideredsecure.On topofthat,becauseyou,theoretically,canexchangedatafromanyqueuetoany queue, you couldcreateasituationin which updatesinonemodeltriggerchangesin theothermodel(i.e., whenusingthe same datamodel)thatareunexpected(and franklyunwanted).33 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we also looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]]. In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] if you need a refresher on that. In this microlearning, we will build upon that knowledge and look at some concrete, practical examples that could be useful in your project. 36 36 37 -At the moment, the two most frequently used ways to provide communication between systems in a multi-model environment are event streaming and web services. This microlearning will discuss the processes of sharing data across systems in a multi-model environment using these concepts, including best practices. 38 -In the figure below, both processes are illustrated. The process at the top illustrates event streaming, and the process at the bottom illustrates web services. Model A and model B are two different models, where a system in model B should have access to the same data as the system in model A. For example, the systems in both models should be the same. 35 +Some of the more complex XPath options are: 39 39 40 -[[image:Main.Images.Fundamental.WebHome@fundamental-multi-model-best-practice--event-streaming-and-webservices.png]] 37 +* dateTime calculation 38 +* Filter list 39 +* XPath on JSON 40 +* SpEL notation for XPath 41 41 42 -=== 3.1 EventStreaming===42 +=== 3.1 dateTime calculation === 43 43 44 -To understand the following section, it is necessary to have some background information about event streaming, which can be found [[here>>doc:Main.eMagiz Academy.Fundamentals.fundamental-event-streaming-introduction||target="blank"]]. 45 -The first option is to decide the alignment of the data models between both models. Whenever data from the first model is transferred to the second model, and the topic is considered input for other systems and integrations in that other model, the data needs to be transformed to the common data model of that second model. This way, the topic can be exposed to any system and pattern in the second model. The picture below denotes this situation. These are the specific considerations when implementing this approach: 44 +Sometimes we see that a dateTime calculation is needed within a transformation to determine a specific action. As these calculations are not natively supported within the eMagiz platform, you need to use XPath's functionality to calculate the new valid date (or dateTime). 46 46 47 -* Leverage the credentials of the first eMagiz model in the second model 48 -* Create transparent systems with clear names and ensure to align the message type names 46 +The XPath standard offers several functions to calculate with dateTime values. The two most used options are dayTimeDuration and yearMonthDuration. With the help of the dayTimeDuration, you can add, subtract, multiple, or divide seconds, minutes, hours, and days regarding the original value. The yearMonthDuration works similarly but then for months and years. An example of such an XPath is: <xsl:value-of xmlns:xs="http://www.w3.org/2001/XMLSchema" select="CDM:StartDate + xs:dayTimeDuration('P1D') * xs:yearMonthDuration('P1M')"/>. In this example, XPath adds one day and subtracts one month from the input date. Note that making this work requires the additional namespace to be defined. Therefore you need a custom snippet within your transformation or a custom transformation to make this work. Furthermore, note that the P1D and P1M could also be filled with the help of parameters to make them dynamic in nature. 49 49 50 - It is necessary totransformtopics to allow communication betweensystems in different models using event streaming. This is because it is impossibleto retrieve data from a topic that existsin one modelthroughadifferentmodel.So,systems in model B cannotimmediately access the topic present in model A. The topic needs to be transformed to ensure that systemsinmodel B can use the data on the topic in model A. By changingthetopic, all systems in model B can access the transformed topic.48 +Some examples that we saw during the years: 51 51 52 -To ensure that the topic from model A can be transformed, model B needs credentials from model A. So, to allow for this pattern, credentials must be shared between models. 50 +* https://my.emagiz.com/p/question/172825635700358186 51 +* https://my.emagiz.com/p/question/172825635700352588 53 53 54 - Anadvantage of this pattern is that there is no dependency across models.If the systemin modelA breaks down,thesystem in model B can still work.A disadvantage of this pattern is that there may be struggles with thesetupsince no direct accessibility can be achieved. Moreover, as mentioned above, credentials have to be shared, which may threaten security.53 +=== 3.2 Filter list === 55 55 56 - ===3.2Webservices ===55 +Sometimes you have a large message which contains a certain list within it. However, logic dictates that you can only send the message if at least one entry in the list for which attribute A is filled and attribute B equals type C. To make that happen in XPath, we first need to navigate to the list within the message. As we previously learned, there are two options to do so. One is to use // to navigate to the entity somewhere in the tree directly. The other is to start at the root and walk the tree from there. In this example, we use the latter. That results in the following XPath example: /root/list[attributeB = 'type C']/attributeA !=''. With this XPath, you filter the list on the specified check and subsequently check whether one of those entries that remains has an attributeA which is filled in. 57 57 58 -Web services can also be used to communicate between systems in different models. This means that model A has a web service in place, and model B has a web service in place, between which data can be exchanged. 59 -An advantage of this pattern is that it is easy to keep an overview. Setting it up does not involve many unclarities. A disadvantage is that there is much dependency across models. If the web service in model A crashes, the system in model B cannot receive data anymore. 57 +=== 3.3 XPath on JSON === 60 60 61 - ===3.3NamingConventions===59 +With the release of build number .50, we expanded our offering on JSON messages to resemble much of the functionality we previously offered for XML messages. As a result, you can use XPath expressions on JSON messages within the following components (related to XPath): 62 62 63 -For clarity purposes, it is advised to give the systems that are the same across models the same name and the name of the other model in which the system is present. So, as illustrated in the figure, the system names in model A and B are partly the same (‘SYS’) and indicate which model also holds the system (model B in model A, model A in model B). This way, it remains clear which models have the same systems, and systems can be found more easily. 61 +* XPath header enricher 62 +* XPath transformer 63 +* XPath router 64 64 65 - ==4.Keytakeaways==65 +To activate the functionality, simply link the JSON source factory support object to one of these components to achieve the desired result. For more information, check out: https://emagiz.github.io/docs/release-notes/build50. 66 66 67 -* Event streaming and webervices are mainly used to communicate between systems across models. 68 -* To allow communication between systems in different models using event streaming, it is needed to transform topics. 69 -* Communication between systems in different models can also directly be achieved using web services. 70 -* For clarity purposes, it is advised to give the systems that are the same across models the same name, as well as the name of the other model in which the system is present. 71 -* Both patterns have their advantages and disadvantages. 67 +=== 3.4 SpEL notation for XPath === 72 72 73 -* Consider the following when communication between two models 74 -** Security 75 -** Loose coupling 76 -** Maintainability 77 -** Clarity 69 +Sometimes you want to perform an XPath operation but store the header via a standard message header enricher component. As a result, you need a valid SpEL expression to help you in this cause. To do so, you need to know the correct notation for an XPath expression when using the SpEL language. An example of the correct notation is: #xpath(payload,'/root/entity/attribute') 78 78 79 -== 5.SuggestedAdditional Readings==71 +== 4. Assignment == 80 80 81 -* [[Fundamentals (Navigation)>>doc:Main.eMagiz Academy.Fundamentals.WebHome||target="blank"]] 82 -** [[eMagiz Security Guide (Explanation)>>doc:Main.eMagiz Academy.Fundamentals.fundamental-emagiz-security-guide||target="blank"]] 83 -** [[Multi-Model Explained (Explanation)>>doc:Main.eMagiz Academy.Fundamentals.fundamental-emagiz-multi-model-explained.WebHome||target="blank"]] 84 -* [[Advanced (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.WebHome||target="blank"]] 85 -** [[Solution Architecture (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.Solution Architecture.WebHome||target="blank"]] 86 -*** [[Checklist for Splitting Models (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.Solution Architecture.Checklist for Splitting Models.WebHome||target="blank"]] 87 -* [[Communication between models (Search Result)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=communication+between+models||target="blank"]] 88 -)))((({{toc/}}))){{/container}}{{/container}} 73 +Check out which of the XPaths we have discussed today can be found within your project. 74 +This assignment can be completed within the (Academy) project you created/used in the previous assignment. 75 + 76 +== 5. Key takeaways == 77 + 78 +Some of the more complex XPath options are: 79 + 80 +* dateTime calculation 81 +* Filter list 82 +* XPath on JSON 83 +* SpEL notation for XPath 84 + 85 +== 6. Suggested Additional Readings == 86 + 87 +If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following link: 88 + 89 +* https://www.w3schools.com/xml/xpath_intro.asp 90 + 91 +== 7. Silent demonstration video == 92 + 93 +As this is more of theoretical microlearning, there is no video accompanying the microlearning.)))((({{toc/}}))){{/container}}{{/container}}