## 5 Proposed Implementation for Parametric Event Transformation
Moreover, the REST Controller can forward and receive messages from Kafka through the respective producers and consumers implemented in the IoT Gateway. The relative path of the REST Controller endpoint, i.e., the URI, is \"sensor-telemetry-events\". This exposed resource receives the JSON POST request and validates the body of the request, i.e., the data, ensuring the validity of the data and providing a fast-fail logic to the clients. The data must be in JSON format with a predefined schema known to all involved components (i.e., IoT Gateway, Event Engine). The data are then transformed into a Kafka message and forwarded by the Kafka producer of the IoT Gateway to the \"sensor-telemetry-event\" topic. At this point, the data are valid, have a specific schema, and have been forwarded to the appropriate Kafka topic. Therefore, we are now talking about an IoT Event that carries measurements of the greenhouse accompanied by metadata helpful for their subsequent processing. The events, i.e., the messages forwarded and received to and from Kafka, may have a specific schema. However, the schema can support polymorphic data, thus allowing events destined for a purpose to be differentiated. In a complex and interconnected ecosystem, flexibility must be provided so that the requirements of one another do not bind each component. However, simultaneously, the validity and correctness of the data exchanged are ensured. Furthermore, the IoT Gateway does not necessarily know what constitutes correct information. It can verify the data, but their correctness is checked and managed by the Event Engine. The IoT Gateway acts as middleware to establish two-way communication with the IoT devices in the physical environment, i.e., the greenhouse and its peripheral structures. Finally, at this point, the raw data of the greenhouse are in the topic \"sensor-telemetry-event\" as IoT Event and can be consumed by the various components, most notably the Event Engine. Up to this point, implementation is common and invariant for each presented scenario. It describes how conditions of the physical world, in our case air temperature, are measured, transformed, and sent from IoT Physical to Kafka to be made available by all components of the application architecture as events with the least possible semantics, i.e., as IoT Events. Next, we detail our contribution, which is parametric Complex Event Processing through a simple microservice. More specifically, the microservice implements the Event Engine, which has parametric Complex Event Processing at its very core. Multiple microservices, as a whole, could also constitute the Event Engine. Technically, the Complex Event Processing implementations are based on the Kafka Streams \"client\" library [44], which offers a standardized and structured way to create stream processing applications. In addition, through the Object-Oriented paradigm offered by Java, CEP can be extended in terms of the functionality it offers following the standards delivered by the Kafka Streams library and without sacrificing the advantages of Kafka as a technology. Event Engine's communication with Kafka is bidirectional and continuous. We could ping-pong where the Event Engine receives and sends messages continuously until it completes predetermined processing. Event Engine's implementation may consist of one or more event streaming applications. This approach aims to isolate the complexity at the implementation level and emphasize what input or inputs we want and what output or outputs we wish to receive. Conceptually, we apprehend it as a virtual synthetic functional interface with a detailed definition. This enables the various components and the user to produce and consume meaningful events, directly or indirectly, ignoring how they are created. Furthermore, each event streaming application can be parametric. Different instantiations can arise simultaneously and in parallel depending on the parameters. In the following sections, some examples are presented.