You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem we're facing is the need to provide client applications with a way to monitor and react to internal worker events within the KafkaFlow framework. Currently, some consumers using asynchronous processing require knowledge of when a worker is stopping or has stopped to initiate important application shutdown processes, such as disposing of objects or storing state information in a database. However, the existing framework lacks a standardized way to expose these worker events to the client application, resulting in a potential complexity in managing these events. This problem can lead to message loss in cases where the application is terminated without proper cleanup.
Describe the solution you'd like
We advocate the incorporation of the Observer pattern within the KafkaFlow infrastructure. This will facilitate clients to keep tabs on KafkaFlow subjects and be alerted when specific intrinsic framework activities transpire.
Observer Pattern Implementation:
ISubject & ISubjectObserver Interfaces: These form the core of the Observer pattern. ISubject lets observers subscribe to it, and ISubjectObserver defines how an observer reacts when notified.
Subject<TSubject, TArg> Class: An abstract implementation which provides methods for subscription (Subscribe) and notification (NotifyAsync). This class is enhanced with a log handler to report potential issues during the notification process.
VoidObject: A placeholder type used in contexts where an argument type needs to be provided, but the actual value is irrelevant. This ensures type safety while conveying that the object should be disregarded.
Example Usage:
Here's a rudimentary example of using WorkerStoppedSubject:
varworkerStoppedSubject=new WorkerStoppedSubject(logHandlerInstance);
workerStoppedSubject.Subscribe(new YourObserverImplementation());// Elsewhere in your code, when a worker stops:await workerStoppedSubject.NotifyAsync(VoidObject.Value);
The text was updated successfully, but these errors were encountered:
Is your request related to a problem you have?
The problem we're facing is the need to provide client applications with a way to monitor and react to internal worker events within the KafkaFlow framework. Currently, some consumers using asynchronous processing require knowledge of when a worker is stopping or has stopped to initiate important application shutdown processes, such as disposing of objects or storing state information in a database. However, the existing framework lacks a standardized way to expose these worker events to the client application, resulting in a potential complexity in managing these events. This problem can lead to message loss in cases where the application is terminated without proper cleanup.
Describe the solution you'd like
We advocate the incorporation of the Observer pattern within the KafkaFlow infrastructure. This will facilitate clients to keep tabs on KafkaFlow subjects and be alerted when specific intrinsic framework activities transpire.
Observer Pattern Implementation:
ISubject & ISubjectObserver Interfaces: These form the core of the Observer pattern.
ISubject
lets observers subscribe to it, andISubjectObserver
defines how an observer reacts when notified.Subject<TSubject, TArg> Class: An abstract implementation which provides methods for subscription (
Subscribe
) and notification (NotifyAsync
). This class is enhanced with a log handler to report potential issues during the notification process.VoidObject: A placeholder type used in contexts where an argument type needs to be provided, but the actual value is irrelevant. This ensures type safety while conveying that the object should be disregarded.
Example Usage:
Here's a rudimentary example of using
WorkerStoppedSubject
:The text was updated successfully, but these errors were encountered: