Event Subscription Sequence Diagram¶
Introduction¶
This document provides a detailed sequence diagram for the event subscription process in Mongoose server. Event subscription is the process by which event processors register their interest in receiving events from specific event sources.
Components Involved¶
The following components are involved in the event subscription process:
- EventProcessor - The component that wants to receive events
- ComposingEventProcessorAgent - Manages event processors and their subscriptions
- EventFlowManager - Coordinates the event flow between sources and processors
- EventSource - The source of events
- EventQueueToEventProcessor - Consumes events from queues and forwards them to processors
Sequence Diagram¶
┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│EventProcessor │ │ComposingEvent │ │EventFlow │ │EventSource │ │EventQueueTo │
│ │ │ProcessorAgent │ │Manager │ │ │ │EventProcessor │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │ │ │
│ subscribe(key) │ │ │ │
│───────────────────>│ │ │ │
│ │ │ │ │
│ │ getMappingAgent() │ │ │
│ │───────────────────>│ │ │
│ │ │ │ │
│ │ │ create queue │ │
│ │ │──────────────────┐ │ │
│ │ │ │ │ │
│ │ │<─────────────────┘ │ │
│ │ │ │ │
│ │ │ create │ │
│ │ │ EventQueueToEventProcessor │
│ │ │────────────────────────────────────────>│
│ │ │ │ │
│ │<───────────────────│ │ │
│ │ │ │ │
│ │ store mapping │ │ │
│ │──────────────────┐ │ │ │
│ │ │ │ │ │
│ │<─────────────────┘ │ │ │
│ │ │ │ │
│ │ registerProcessor() │ │
│ │────────────────────────────────────────>│ │
│ │ │ │ │
│ │ subscribe(key) │ │ │
│ │───────────────────>│ │ │
│ │ │ │ │
│ │ │ subscribe(key) │ │
│ │ │───────────────────>│ │
│ │ │ │ │
│ │ │ store subscription│ │
│ │ │ │──────────────────┐ │
│ │ │ │ │ │
│ │ │ │<─────────────────┘ │
│ │ │ │ │
│ │ │<───────────────────│ │
│ │ │ │ │
│ │<───────────────────│ │ │
│ │ │ │ │
│<───────────────────│ │ │ │
│ │ │ │ │
Sequence Description¶
-
EventProcessor initiates subscription: The EventProcessor calls
subscribe(subscriptionKey)
on the ComposingEventProcessorAgent to express interest in events from a specific source. -
ComposingEventProcessorAgent gets mapping agent: The ComposingEventProcessorAgent calls
getMappingAgent(subscriptionKey, this)
on the EventFlowManager to get or create an EventQueueToEventProcessor for the subscription. -
EventFlowManager creates queue and mapping agent: The EventFlowManager creates a queue for the subscription if one doesn't exist. It creates an EventQueueToEventProcessor that will consume events from the queue and forward them to processors. It returns the EventQueueToEventProcessor to the ComposingEventProcessorAgent.
-
ComposingEventProcessorAgent stores mapping: The ComposingEventProcessorAgent stores the mapping between the subscription key and the EventQueueToEventProcessor.
-
ComposingEventProcessorAgent registers processor: The ComposingEventProcessorAgent calls
registerProcessor(eventProcessor)
on the EventQueueToEventProcessor to register the EventProcessor as a listener. -
ComposingEventProcessorAgent subscribes to event source: The ComposingEventProcessorAgent calls
subscribe(subscriptionKey)
on the EventFlowManager to subscribe to the event source. -
EventFlowManager subscribes to event source: The EventFlowManager calls
subscribe(subscriptionKey)
on the EventSource to subscribe to events. -
EventSource stores subscription: The EventSource stores the subscription information.
-
Subscription complete: The subscription process is complete, and the EventProcessor will now receive events from the EventSource.
Conclusion¶
The event subscription process in Mongoose server involves multiple components working together to establish a connection between event sources and event processors. The sequence diagram illustrates the flow of method calls and the responsibilities of each component in the subscription process.