top of page
Search
  • Writer's pictureAirspot Tech

Subject reactive components

1. Definitions and introduction

Eventing systems play a role in today's software world, enabling organizations to build highly scalable, loosely coupled and event-driven architectures. These systems facilitate the seamless flow of events and messages between different components, services, and hardware, enjoying real-time communication and responsiveness to changing business needs.

Many frameworks support eventing systems, such as Apache Kafka, RabbitMQ, AWS EventBridge and Azure Event Grid. These tools provide robust event brokering, message routing and event management capabilities, making it easier for developers to build event-driven systems.


CloudEvents – a Cloud Native Computing Foundation (CNCF) project – is a specification for describing event data in a standard format, allowing interoperability and portability across different cloud platforms and event-driven systems. It provides a standardized way to represent events, including metadata and payload, using a structured JSON format. CloudEvents enables decoupled and flexible communication between event producers and consumers, supporting event-driven architectures and facilitating the integration of services and applications. Overall, CloudEvents provides a common language for events, easing to integrate and connect various components and systems in event-driven architectures.

Implementing a reactive component, like a reactive properties store within a CloudEvents eventing system, can be beneficial for handling state property changes and producing events. This component can act as a concrete implementation of the "subject" component in the observer design pattern.

CloudEvents has gained adoption across various organizations and frameworks. Some notable organizations that use CloudEvents include Google, Microsoft, IBM, Red Hat, VMware, SAP, and more. These organizations utilize CloudEvents in their cloud platforms, event-driven architectures and messaging systems, to facilitate interoperability and seamless event exchange between different services and systems.


As for frameworks, CloudEvents is supported by popular event-driven frameworks and technologies such as Apache Kafka, Apache Pulsar, NATS, Knative, KEDA, and many others. These frameworks provide native integration and support for CloudEvents, allowing developers to easily manage events.

2. Notable use cases for CloudEvents


Some of the notable use cases for CloudEvents include Serverless Computing, Event-driven Microservices, Multi-Cloud Environments, IoT/Edge Computing and Event Streaming.

A short description can explain each different approach.


Serverless Computing

CloudEvents is used in serverless architectures, where functions or services can produce and consume events in a consistent format across different serverless platforms.


Event-driven Microservices

CloudEvents is valuable in microservices architectures, enabling different services to communicate and react to events in a standardized way, promoting loose coupling and scalability.


Hybrid and Multi-Cloud Environments

CloudEvents facilitates event exchange between systems running in different cloud environments or on-premises, allowing for seamless integration and interoperability.


IoT and Edge Computing

CloudEvents can be utilized in IoT and edge computing scenarios to capture and propagate events generated by sensors, devices and edge nodes, enabling real-time processing and decision-making.


Event Streaming and Messaging Systems

CloudEvents can be used in event streaming and messaging platforms to standardize event formats, allowing for easy event processing, transformation and routing across different systems.

3. Example of CloudEvent

Implementing a reactive component like a reactive properties store within a CloudEvent eventing system can be beneficial for handling state property changes and producing corresponding events. This component can act as a concrete implementation of the "subject" component in the observer design pattern.

Let’s have a look at a very simplified example of a CloudEvent, thinking we have to interact with the Google Cloud Platform environment. In this example, the CloudEvent represents the event of a new object being created in a Google Cloud Storage bucket.

The type field indicates the specific type of the event, while the source field specifies the source of the event, which in this case is the bucket. The id field represents a unique identifier for the event and the time field indicates the timestamp of the event. The subject field provides the subject or identifier of the event, which is the path to the created object. The datacontenttype field specifies the content type of the event payload and the data field contains the actual data payload of the event.


{ "specversion": "1.0", "type": "com.google.cloud.storage.object.created", "source": "/projects/my-project/buckets/my-bucket", "id": "12345", "time": "2023-06-04T10:00:00Z", "subject": "objects/image.jpg", "datacontenttype": "application/json", "data": { "bucket": "my-bucket", "object": "objects/image.jpg", "size": 1024 } }


It’s time to give a deeper look at the subject field. In CloudEvents, the "subject" field represents the subject or the identifier of the event. It provides additional contextual information about the event, helping to identify the specific resource or entity that the event pertains to. The subject field can be used to specify the unique identifier of the resource being affected, such as an object ID, a user ID, a device ID or any other relevant identifier in the domain of the event. The subject field is optional in a CloudEvent and its usage depends on the specific event and the needs of the event producer and consumer. It can enable more granular event routing, filtering and processing by providing a specific identifier for the event's subject.


Now what we propose is to give consistency to the subject field of a CloudEvent using a reactive property store. This means that the subject field becomes a component that can react to changes in its state and ensure the consistency of the events it generates.

In this scenario, the subject field can be treated as a reactive property that is stored and monitored in a reactive property store. Whenever there is a change in the state of the subject, such as a modification or an update, the reactive property store detects the change and triggers the generation of a new CloudEvent with the updated subject.

By utilizing a reactive property store, you can ensure that the subject field remains consistent and reflects the most up-to-date information about the component or entity it represents. This approach enables event-driven architectures to respond dynamically to changes in the system, ensuring that the events accurately represent the current state of the subject and enabling reactive workflows and processing based on those events.


By tracking changes in state properties and reacting to those changes, the reactive properties store can generate events that notify interested observers about the updates. This allows for a decoupled and reactive architecture where components can subscribe to specific state changes and react accordingly.


Using CloudEvent eventing along with a reactive properties store can enable event-driven communication and event sourcing, allowing for efficient handling of state changes and propagating relevant events throughout the system. This approach promotes loose coupling and scalability, as components only need to subscribe to the specific events they are interested in, reducing unnecessary dependencies and improving system responsiveness.

Overall, incorporating a reactive properties store within an eventing system can enhance the reactive nature of the architecture and enable efficient event-driven communication between components.

By giving the Subject concept a reactive nature, you can establish a decoupled and event-driven architecture. The Subject, as an event producer, plays a central role in emitting events and enabling communication between different components within the eventing system. It enables event-driven workflows, real-time updates and the ability to react to changes or triggers occurring within the system.

4. Reactive properties store within an eventing system

By implementing a reactive properties store within an eventing system, you can achieve a reactive architecture where components can dynamically observe and react to changes in specific state properties. This approach promotes loose coupling, scalability and responsiveness in the system, allowing for efficient event-driven communication and handling of state changes.

Let's dive into the implementation of a reactive properties store within an eventing system. In order to implement a full system, we must identify and develop five subsequent steps: store, observers, value updating, event production and behavior.


  1. Define the Reactive Properties Store

    • The reactive properties store is responsible for storing and managing state properties that need to be observed for changes.

    • It maintains a registry of properties and their corresponding values.

    • It provides methods to update the property values and trigger events when changes occur.


  1. Registering Observers

    • Components interested in specific state property changes can register themselves as observers with the reactive properties store.

    • Each observer specifies the property or properties it wants to observe and provides a callback function to be invoked when the property changes.


  1. Updating Property Values

    • When a state property is updated in the reactive properties store, it checks if there are any registered observers for that property.

    • If there are observers, the store compares the new property value with the previous value.

    • If the values differ, it triggers the corresponding callback functions for the registered observers, passing the updated property value and any additional relevant data.


  1. Event Production

    • The callback functions invoked for the observers can produce events based on the updated property value.

    • These events can be published to the Knative eventing system or any other event bus for further processing by interested components.


  1. Reactive Behavior

    • Components subscribing to the events produced by the reactive properties store can react accordingly.

    • They can perform actions based on the received events, such as updating their own state, triggering additional processes, or communicating with other components.


By implementing a reactive properties store within an eventing system, you can achieve a reactive architecture where components can dynamically observe and react to changes in specific state properties. This approach promotes loose coupling, scalability and responsiveness in the system, allowing for efficient event-driven communication and handling of state changes.

5. More capabilities

A few examples use cases that demonstrate the capabilities of a reactive properties store within an eventing system. Real-Time Monitoring, Order Processing, IoT Device Management and User Profile Updates.


  1. Real-Time Monitoring

The reactive properties store serves as a central hub for tracking the status and connectivity of devices. It facilitates communication between the devices and the observers responsible for their management and monitoring. By leveraging the changing properties, observers can take actions such as device control, generating reports on connectivity issues and initiating maintenance tasks, ensuring efficient and reliable device management.


  1. Order Processing

The reactive properties store acts as a central hub for maintaining the state properties of orders. Observers, responsible for different stages of the order processing workflow, consume the events triggered by the reactive properties store to update the database, send notifications to customers and initiate the shipping process. This ensures accurate order tracking, effective communication with customers and timely order fulfillment.


  1. IoT Device Management

The reactive properties store tracks the status and connectivity of devices, enabling effective device management and monitoring. Observers, responsible for device management, utilize the events triggered by the reactive properties store to take actions such as device control, generating reports on connectivity issues and initiating maintenance tasks. This behavior ensures efficient operation, troubleshooting and maintenance of devices in various applications and environments.


  1. User Profile Update

The reactive properties store tracks changes to user profile attributes. Observers, dependent on user profile information, consume the events triggered by the reactive properties store to update their internal records, synchronize data with other services and initiate personalized actions. This approach ensures accurate user information, data consistency and personalized experiences across various components and services.


In each of these use cases, the reactive properties store acts as a central component that tracks changes in specific properties and triggers events to inform other components. The observers can react to these events, enabling a decoupled and reactive architecture. By leveraging an eventing system and the reactive properties store, you can build robust and responsive systems that adapt to changing conditions and enable efficient event-driven communication between components.

6. Redis improvement

An even more technological implementation can be achieved on Google Cloud using the Redis store.

Redis is a popular in-memory data structure store that can be used in combination with Google Cloud Platform (GCP), to implement a reactive properties store component. The next table summarizes an overview of how Redis can be leveraged within GCP (For more information, please consider visiting the Redis project page).

By utilizing Redis on GCP, you can effectively store and manage reactive properties in an efficient and scalable manner. Redis' in-memory storage capabilities and Pub/Sub messaging functionality enable real-time updates and event-driven communication within the reactive properties store. This approach allows observers to seamlessly subscribe to property changes and react accordingly, creating a responsive and decoupled architecture.


PointDescriptionSetting up Redis on GCP- Provision a Redis instance using Google Cloud Memorystore service. - Choose the appropriate configuration, such as instance size and replication options, based on performance and scalability requirements.Storing Reactive Properties- Store each reactive property as a key-value pair in Redis. - Use Redis commands to set and update property values. - Example: Use SET command to set initial property value and SET command with NX option to update the property if it doesn't already exist.Subscribing to Redis Pub/Sub- Redis Pub/Sub allows subscribing to channels and receiving real-time notifications for events. - Observers interested in specific properties can subscribe to corresponding Redis channels. - Use the Redis SUBSCRIBE command to subscribe to a channel and receive updates when property values change.Publishing Property Updates- Reactive properties store can publish property updates to the corresponding Redis channel. - Use the Redis PUBLISH command to send the updated property value to subscribed observers. - The published message should include information about the property name and its updated value.Reactive Behavior- Observers subscribed to Redis channels receive property update messages in real-time. - Observers can react to changes by performing necessary actions based on updated property values. - Example actions: Triggering a workflow, updating a database, or sending notifications to other components.



7. Firestore improvement

An alternative can be Firestore, a fully managed NoSQL document database provided by Google Cloud Platform (GCP). By utilizing Firestore on GCP, you can create a scalable and responsive reactive properties store. Firestore's real-time updates and event listeners enable seamless tracking of property changes, allowing observers to react in real-time. This approach provides a reliable and scalable foundation for implementing a reactive architecture that can respond to changes in the state of the reactive properties.

8. Conclusions

Developers are visionaries who gaze into the horizon and shape the trajectory of technology. As we peer into the future, it is clear that reactive programming and components will continue to gain prominence.

The future will be driven by dynamic, adaptable, and responsive technologies. Futurists must champion the adoption of reactive paradigms, recognizing their potential to revolutionize industries across domains. By embracing the power of reactive programming, we can unlock new frontiers of innovation, build robust and intelligent systems and pave the way for a future where technology seamlessly integrates into our daily lives, driving progress and transforming societies.


9 views0 comments

Recent Posts

See All

Pattern Recognition with Event Sourcing

1. Definition and purpose An approach to analyzing event sequences is pattern recognition. By analyzing sequences of events, patterns and trends can be identified. Understanding the underlying behavio

Serverless Container Glue App Ecosystem

The concept of "serverless container" combines the benefits of serverless computing and containerization technology. It refers to a deployment model where containers package and run applications, and

Comentarios


bottom of page