Changes for page eMagiz State Generation
Last modified by Erik Bakker on 2024/08/13 12:05
From version 11.1
edited by Carlijn Kokkeler
on 2023/07/07 13:57
on 2023/07/07 13:57
Change comment:
There is no comment for this version
Summary
-
Page properties (4 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,0 @@ 1 -eMagiz State Generation - Parent
-
... ... @@ -1,1 +1,0 @@ 1 -WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. CarlijnKokkeler1 +XWiki.marijn - Content
-
... ... @@ -1,95 +1,83 @@ 1 -{{container}}{{container layoutStyle="columns"}}((( 1 +{{html wiki="true"}} 2 +<div class="ez-academy"> 3 + <div class="ez-academy_body"> 4 +<div class="doc"> 5 + 6 + 7 + 8 += eMagiz Stateful = 9 + 2 2 In this fundamental, we'll take a look at the capability of eMagiz around storing a state of a data packet of message send across the platform. 3 3 4 4 Should you have any questions, please get in touch with academy@emagiz.com. 5 5 14 +* Last update: March 7th, 2022 15 +* Required reading time: 10 minutes 16 + 6 6 == 1. Prerequisites == 7 7 8 8 * Take a closer look at the Fundamentals for Messaging, API Gateway and Event Streaming 9 9 10 -== 2. Key Concepts ==21 +== 2. Key concepts == 11 11 12 - In this microlearning,theconceptofstategenerationwillbeexplained.23 +All concepts are discussed in the section below.. 13 13 14 -== 3. Definition == 15 15 16 -State generation concerns the generation of a stateful application or service. This means that, for the application or service to function, data is stored and past states are used to derive information. Such a state may e.g. be a temperature or heartrate measure. Stateful applications or services are opposed to stateless applications or services, which do not require data to function and merely represent the current state. 17 17 18 - Anexample of a stateful application, is an application that obtains temperature measures in a room and presents a timeline of the temperature measures.A thermostat produces the temperature inhis example, afterwhich the data needs tobe put into context, including the time at which a certain temperature was measured and the room in whichit was measured. Then, the data can be evaluated over time, and tested againstthe norm. This ensures thatreal time actions can be generated, e.g. afire alert can be generated when the temperature has risen by 25 degrees Celsiusin 1 minute.27 +== 3. Introducing Stateful == 19 19 20 - [[image:Main.Images.Fundamental.WebHome@fundamental-stateful-1.png]]29 +Within eMagiz there is a capability to store pieces of data of a specific object that is transit between systems. The basis idea of messages that are processed by eMagiz is that all of these are in transit. However, in certain cases it is very helpful to preserve a state of an object. That state can help to influence the next data packets that are passing through or trigger a certain action for another system. 21 21 22 - ==4.Benefits and Operations==31 +An example might be a situation where a sensor is submitting temperature data every 5 seconds on a data stream towards eMagiz. The interesting state of the machine where the sensor is attached to is the average temperature in the last hour. In this case the temperature that is send to the eMagiz should be used to update the state of the machine, and more specifically the average temperature. One needs a data stream from the sensor, a way to aggregate & average out all messages from the last hour, and a way to store the state. Once the temperature reaches a certain threshold, the data is submitted to a next system to raise an alert for a user. 23 23 24 - Benefitsofrealtimestate generation are,first ofall, thatdata canbeprovided immediatelyandisalways up-to-date.Secondly,it ispossible totake realtime action and takereal-time decisions.Lastly,thereisno need to storedataunnecessarily.33 +Another example might be a data stream that registers a click on a specific webpage. That data stream is connected to eMagiz, whereby the state of that specific webpage is updated with the number of clicks. Once the number of clicks in the last 30 minutes reaches for instance more than 50, a specific action might be triggered. If that page contains a product, the action might be to display the number of web users active on that product in order to influence the sales of that product. One needs a data stream, a way to count the number of click, and a way to store the state of that webpage. 25 25 26 - Stateful data can be generated through four main operations. First of all, through enriching data.This meansthat information should beadded to the data, so that it has more meaning. This can be achieved by storing states in a database. For example,when it is known that, if a person works from home,this is stored as A, and if aperson works in theoffice, thisis storedas B,the data can be enrichedwith ‘Home’and‘Office’. To ensure this, a database shouldbe presentstoring the connection between A and Home, and B and Office.35 +The example are purely illustrative to understand the concept. 27 27 28 - [[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-example-enrich.png]]37 +==== 3.1 State Store ==== 29 29 30 - Secondly,statefuldatacan be obtainedthroughaggregatingdata.Aggregationconcernsacomputationoverertainrangeof time,suchasanaverage,minimum ormaximum.For example,when thenumberofpeopleworkingfromhome,orworkingat the office isstored,theaverage number ofpeopleworking at homeoratthe officeuringthepast30 minutescan bedetermined.39 +The state store refers to the storage location of the states of the specific objects in the environment. That storage location is part of the eMagiz platform, and embedded in the eMagiz runtime for now. The user needs to define what objects and the attributes of that object are to be stored. Several different objects and states of the objects can be be defined & stored. A state store can be shared across multiple processes that are allowed to update the state of an object. 31 31 32 - [[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-example-aggregation.png]]41 +==== 3.2 State Operations ==== 33 33 34 - Thirdly, change detection can beapplied. This meansthat a changeinthe data can bedetected. For example, when the temperature at home risestomorethan 30 degrees, thiscan bedetected. It can then be definedthat,whenthetemperature at home ismore than 30degrees andtheheating ison, the heatingshouldbeturnedoff.In this example, thedata isenrichedwiththelaststateoftheairconditioning.43 +Once the state store is defined, one needs different operations in order to update the state effectively. 35 35 36 -[[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-example-change-detection.png]] 45 +* Retrieve - get the values of an object and the attributes 46 +* Aggregate - Increment a attribute in a state store to +1 47 +* Enrich - add new attribute of an object in the state store based on joining several streams 48 +* Transform - filter data or translate formats 49 +* Time-window - to aggregate data over time 37 37 38 - Lastly,duplicatedetectioncanbe applied, meaning that duplicatedata can be detected. For example, if the number of peopleworking from home isrecorded twice at a certain moment, this can be detected, and the data can be adapted accordingly.51 +==== 3.3 State Action & networks ==== 39 39 40 - [[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-example-duplicate-detection.png]]53 +Once the state store has values stored, certain triggers can be defined to cause action. For instance, when the temperature is higher than 20 in the example above. These actions can be defined/modeled by the eMagiz user inside flows, whereby the evaluation of state would send a data point to the system that manages the action. For instance, the support team that manages the server park and needs to verify of the airconditioning of the server room is working properly (case high temperature). 41 41 42 - ==5.StateGeneration in eMagiz==55 +One can imagine that a certain action would be to update the state of another object. Or that there are several other data streams are update several states. In that way, you can imagine a complete network of data that work intertwined for you to detect rolling reality of data that can be used for data analysis and real-time decision-making. 43 43 44 - StateGenerationcomponents can beusedinall eMagiz patterns. The enrich andaggregate functionalities are likely more fittingto Messaging and API Gateway as opposed to Event Streaming. For Event Streaming, the other two operations, change and duplicatedetection, are more relevant.57 +==== 3.4 Speed and throughput ==== 45 45 46 - A statecanmostlogicallybecreatedinacentralplacethroughwhich the dataflows. Theasonforthis,isthat sucha placehasalltherequiredinformationflowingthroughits processestogeneratestatefuldata.59 +Many organizations hold lots of data which can be leveraged for such use cases, and often include IoT like data. Therefore, the data is usually put on event streams that are geared towards speed and throughput. In eMagiz you will find these data points usually in topics that are processed by Event Processor flows. 47 47 48 - Thestate store is implemented inside the eMagiz runtime using the H2 database for now.For time related operations anothertechnologyisused (Esper), and the functionality is only available on Docker based runtimes (to be release end Q2 2022). You wilfind the specific Stateful componentsinside the Flow Designer as we use in eMagiz to model the flow. Aligned with the general concept of low-code developnment in eMagiz. For State store models, the current data modeling capabilities will be used.61 +==== 3.5 Pattern specifics ==== 49 49 50 - ==6.UseCases==63 +At first hand it looks as if these concepts would only apply to Event Streaming. But capturing & storing a state of an object would also be handy in other patterns such as Messaging. For instance, when the order of the messages being send matters, or when there is dependency between messages that is needed to determine when a message needs to be send in time. 51 51 52 - Inthefollowing, real-life implementations are given on how eMagizState Generation hasbeen realized through (i) enrichment, (ii) aggregation, (iii)changedetection, and (iv) duplicate detection.65 +==== 3.6 eMagiz specifics ==== 53 53 54 - ====6.1Enrich====67 +The state store is implemented inside the eMagiz runtime using the H2 database for now. For time related operations another technology is used (Esper), and the functionality is only available on Docker based runtimes (to be release end Q2 2022). You wil find the specific Stateful components inside the Flow Designer as we use in eMagiz to model the flow. Aligned with the general concept of low-code developnment in eMagiz. For State store models, the current data modeling capabilities will be used. 55 55 56 - CompanyA works with a backend system based on ID/Name combinations. These are different for each implementation, and can be retrieved through a unique API. A difficulty that arises, is that some APIs initially only return the IDs. To prevent multiplecallsto our backend system, the key/value pairs (ID/Name) need to be stored, such that thesecan be used in subsequent calls.69 +===== Practice ===== 57 57 58 - TheeMagizsolution for Company A can beviewedbelow.71 +== 4. Key takeaways == 59 59 60 -[[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-usecase-enrich.png]] 73 +* Stateful refers to the concept of storing a state of an object 74 +* Storing a state is different compared to data in transit which is often refered as stateless data (eMagiz doesn't store or update the data when sending across) 75 +* Stateful can be applied across all patterns in eMagiz and is embedded into the platform in such a way that it provided the same user experience 61 61 62 - ====6.2 Aggregation====77 +<p align="center">[[image:ffundamental-stateful-1.png||]]</p> 63 63 64 -Company B provides contracts and files for their customers. Their customers manually upload contracts (one by one) to their files, which may take some time. It is desired by Company B that their customers receive a push notification once their files have been uploaded successfully. However, they do not wish to spam their customers by sending a push notification after each file upload when they are uploading several files. So, the push notification should be retained for some time, and should be sent once it is (almost) certain that no additional file will be uploaded. 65 65 66 -In the figure below, the eMagiz solution for Company B can be viewed. 67 67 68 -[[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-usecase-aggregation.png]] 69 - 70 -==== 6.3 Change Detection ==== 71 - 72 -Company C tracks packages and parcels that have been ordered by their customers. When a package is not received within its expected timeframe, an exception occurs. It can happen that such an exception resolves itself, e.g. after rendering for some time, the package is not ‘stuck’ anymore, and is being processed. Before implementing state generation, such a change was never sent to the Alert Manager, because no new exception was triggered. As a result, the employees from Company C were still working under the assumption that the exception is valid, meaning that they could still be searching for a packet that had already been received. 73 - 74 -With state generation, changes in package statuses are sent to the Alert Manager, so that they are aware of any (resolved) exceptions. In the figure below, the eMagiz solution for Company C can be viewed. 75 - 76 -[[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-usecase-change-detection.png]] 77 - 78 -==== 6.4 Duplicate Detection ==== 79 - 80 -Company D is concerned with receiving meter readings. From an external system, new meter readings, or corrected meter readings are received. To protect underlying applications, it needs to be checked whether a duplicate between the external system and their own internal system exists. This can be achieved through a check for each type of meter reading. When a duplicate is found, the meter reading is marked, such that it can be checked later in the process. 81 -The eMagiz solution for Company D can be viewed below. 82 - 83 -[[image:Main.Images.Fundamental.WebHome@fundamental-stategeneration-usecase-duplicate-detection.png]] 84 - 85 -== 4. Key Takeaways == 86 - 87 -* State generation concerns the generation of a stateful application or service 88 - Stateful refers to the concept of storing a state of an object 89 -* Storing a state is different compared to data in transit which is often refered as stateless data (eMagiz doesn't store or update the data when sending across) 90 -* Stateful can be applied across all patterns in eMagiz and is embedded into the platform in such a way that it provided the same user experience 91 -* Stateful data can be generated through four main operations: enrich, aggregation, change detection, duplicate detection 92 - 93 93 == 5. Suggested Additional Readings == 94 94 95 95 N/A ... ... @@ -98,4 +98,8 @@ 98 98 99 99 N/A 100 100 101 -)))((({{toc/}}))){{/container}}{{/container}} 89 +</div> 90 +</div> 91 +</div> 92 + 93 +{{/html}}