Changes for page Communication between models
Last modified by Erik Bakker on 2024/09/05 14:00
From version 21.1
edited by Carlijn Kokkeler
on 2024/09/03 11:49
on 2024/09/03 11:49
Change comment:
There is no comment for this version
To version 14.1
edited by Erik Bakker
on 2022/07/28 10:28
on 2022/07/28 10:28
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. CarlijnKokkeler1 +XWiki.ebakker - Content
-
... ... @@ -1,5 +1,5 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - Whenyour integrationlandscapegrows throughtime, youmight decidetosplitfunctionalbusinessprocessesintomultipleeMagizmodels.In thosecases, thequestion ofconnectingthesemodelseasily,stable,andsecurelycould arise.This microlearning willfocusonthatquestion and provideananswerbasedonourvisionandbestpractices whendealingwiththeplatform.2 +In a low-code platform like eMagiz, you want to prevent using custom scripting as much as possible. However, sometimes in practice, you encounter situations that cannot be realized with the standard toolbox provided within the platform. As a result, we offer the option to use a Groovy script in these situations to achieve the desired solution. In this microlearning, we will look at where you can use a Groovy script and discuss the key considerations when implementing a Groovy script within your model. 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 ... ... @@ -9,43 +9,72 @@ 9 9 10 10 == 2. Key concepts == 11 11 12 -This microlearning focuses on communicationbetweentwoeMagizmodels.Whencommunicatingto any externalparty(fromtheviewofa specificmodel),youshould alwaysconsiderthe following:12 +This microlearning focuses on groovy scripts. A groovy script is a piece of code written in the groovy language that allows you to extend the platform's functionality beyond the mere use of the components supplied via the flow designer. 13 13 14 -* Security 15 -* Loose coupling 16 -* Maintainability 17 -* Clarity 14 +* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 15 +* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 16 +* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 17 +* Groovy scripts should be well documented as they are though to read for most of our community members 18 +* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 18 18 19 -== 3. Communicationbetweenmodels==20 +== 3. Groovy script == 20 20 21 - Mostuserswould thinkthatcommunicationviaqueues to connecttwo separateeMagizmodelsis a brightidea.However,thisis somethingthatwedonot encourage.We discouragethisforseveralpracticaland technical reasonsalike.22 +In a low-code platform like eMagiz, you want to prevent using custom scripting as much as possible. However, sometimes in practice, you encounter situations that cannot be realized with the standard toolbox provided within the platform. As a result, we offer the option to use a Groovy script in these situations to achieve the desired solution. In this microlearning, we will look at where you can use a Groovy script and discuss the key considerations when implementing a Groovy script within your model. 22 22 23 - Whenlooking 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 tolisten to a queue on which nomessages are provided. This queue will, however, be registered onhe JMS level (when youactivate the flow inquestionwith the custom configuration), which can leadto confusing queuestatistics and even more troublesome false-positive alerting based on missing queue metrics or missing consumers.24 +=== 3.1 Implementation in Create === 24 24 25 -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. 26 +To implement a groovy script in Create, you first need to consider what your Groovy script should do. Then, within the flow designer, there are five components available that can handle a Groovy script. 27 + 28 +* In case you want the Groovy script to filter out messages, you should implement the Groovy script in a "standard filter" component. 29 +* If you want your Groovy script to always transform your message from a certain format into another format, you should consider using a "standard transformer" component. 30 +* The "standard service activator" is your friend if you need an optional output. So, for example, when you want to do some transformation and check whether a message can continue, you can use the "standard service activator" and have an optional output. 31 +* When you want to split your message based on a Groovy script, you should use the "standard splitter." 32 +* If you want to route messages based on a Groovy script, you should use the "standard router." 26 26 27 - Another practicalreasonfor not wantinghisisthatwe donotactivelysupport this usecase fromeMagiz.Thismeans that whenweupdate our technicalinfrastructure, we willnot considerthisscenario. Thiscould leadtoadditional workin thefutureandeducedstability ofyoursolution.34 +{{warning}}Note that in practice, we mainly see use cases for the "standard service activator" and the "standard transformation." {{/warning}} 28 28 29 - Fromthetechnical point of view, the consequence of thisconstruction is that both models need to know each othercertificates and credentials, which arenot considered secure.On top of that, because you, theoretically, can exchangedata from any queueto any queue, you couldcreateasituation in which updates inone modeltriggerchanges in theother model (i.e., when usingthe same data model) that areunexpected (and frankly unwanted).36 +[[image:Main.Images.Microlearning.WebHome@expert-data-handling-groovy-script-available-components.png]] 30 30 31 -We advise using functionality that makes it explicit that both models function independently of each other. From eMagiz, we consider two valid alternatives for this: 32 -- Using a web service as a communication layer between the two models. This web service can be REST or SOAP and has been implemented before 33 -- Using the Event Streaming functionality of eMagiz to write and read from topics. 38 +Regardless of the component you choose, you always need to select the "Groovy script" option and reference the Groovy resource available on the flow level you want to use within the component. 34 34 35 - Bothalternatives have the benefit that theecuritycan betightand explicit (i.e.,onlymodel A can write/postto model B). Furthermore, managingthe solution becomesmuch easierasit uses the standard functionality within theplatform. Therefore, we have noplans to supportthis approach inthe product.40 +[[image:Main.Images.Microlearning.WebHome@expert-data-handling-groovy-script-groovy-configuration.png]] 36 36 37 - ==4.Key takeaways==42 +{{info}}As you can see in the help text when selecting the "resource" attribute, you need to make sure that the Groovy script is uploaded within the context of your flow.{{/info}} 38 38 39 -* Consider the following when communication between two models 40 -** Security 41 -** Loose coupling 42 -** Maintainability 43 -** Clarity 44 +After you have the component in such a way that the correct Groovy script is called, you are done with the component's configuration and can test the flow using flow testing. 44 44 45 -== 5.SuggestedAdditional Readings ==46 +=== 3.2 Key considerations === 46 46 47 -** [[Fundamentals (Navigation)>>doc:Main.eMagiz Academy.Fundamentals.WebHome||target="blank"]] 48 -*** [[eMagiz Security Guide (Explanation)>>doc:Main.eMagiz Academy.Fundamentals.fundamental-emagiz-security-guide||target="blank"]] 49 -*** [[Multi-Model Explained (Explanation)>>doc:Main.eMagiz Academy.Fundamentals.fundamental-emagiz-multi-model-explained.WebHome||target="blank"]] 50 -* [[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"]] 51 -)))((({{toc/}}))){{/container}}{{/container}} 48 +* To make some groovy scripts work, you need to upload (third-party) Java libraries that are not packaged on default by eMagiz 49 +* To make some groovy scripts work, you need to reference Java libraries via a standard header enricher or as a dummy variable 50 +* The store consists of several groovy scripts that might be of use to you 51 +* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 52 +* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 53 +* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 54 +* Groovy scripts should be well documented as they are though to read for most of our community members 55 +* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 56 + 57 +== 4. Assignment == 58 + 59 +Try to implement a component that references a Groovy script and see whether the flow can be tested. 60 +This assignment can be completed with the help of the (Academy) project you created/used in the previous assignment. 61 + 62 +== 5. Key takeaways == 63 + 64 +* To make some groovy scripts work, you need to upload (third-party) Java libraries that are not packaged on default by eMagiz 65 +* To make some groovy scripts work, you need to reference Java libraries via a standard header enricher or as a dummy variable 66 +* The store consists of several groovy scripts that might be of use to you 67 +* Groovy scripts should be viewed as an extension that can be used in fringe cases, not as a standard best practice 68 +* When a groovy script becomes so complex that you are programming, you should consider alternatives to the solution 69 +* Groovy scripts can be used in a filter, transformation, and as part of a standard executor 70 +* Groovy scripts should be well documented as they are though to read for most of our community members 71 +* There is no guarantee from eMagiz that Groovy scripts within models keep working in newer versions of the platform 72 + 73 +== 6. Suggested Additional Readings == 74 + 75 +If you are interested in this topic and want more information, please read the help text provided by eMagiz and read the following link: 76 +* https://www.tutorialspoint.com/groovy/index.htm 77 + 78 +== 7. Silent demonstration video == 79 + 80 +As this is more of theoretical microlearning, there is no video accompanying the microlearning.)))((({{toc/}}))){{/container}}{{/container}}