Communication between models
In this microlearning, we'll explore the best practices for communication between two eMagiz models. Effective communication is crucial, and it's important to prioritize security, loose coupling, maintainability, and clarity. We'll discuss why using queues for inter-model communication is generally discouraged and why alternatives like web services and Event Streaming are preferred. By focusing on these key considerations, you'll be better equipped to design robust and maintainable integration solutions within eMagiz.
Should you have any questions, please get in touch with academy@emagiz.com.
1. Prerequisites
- Expert knowledge of the eMagiz platform
2. Key concepts
This microlearning focuses on communication between two eMagiz models. When communicating to any external party (from the view of a specific model), you should always consider the following:
- Security
- Loose coupling
- Maintainability
- Clarity
3. Communication between models
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.
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.
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.
Another practical reason for not wanting this is that we do not actively support this use case from eMagiz. This means that when we update our technical infrastructure, we will not consider this scenario. This could lead to additional work in the future and reduced stability of your solution.
From the technical point of view, the consequence of this construction is that both models need to know each other certificates and credentials, which are not considered secure. On top of that, because you, theoretically, can exchange data from any queue to any queue, you could create a situation in which updates in one model trigger changes in the other model (i.e., when using the same data model) that are unexpected (and frankly unwanted).
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:
- 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
- Using the Event Streaming functionality of eMagiz to write and read from topics.
Both alternatives have the benefit that the security can be tight and explicit (i.e., only model A can write/post data to model B). Furthermore, managing the solution becomes much easier as it uses the standard functionality within the platform. Therefore, we have no plans to support this approach in the product.
4. Key takeaways
- Consider the following when communication between two models
- Security
- Loose coupling
- Maintainability
- Clarity