Skip to content

Event Processing Sequence Diagram

Introduction

This document provides a detailed sequence diagram for the event processing flow in Mongoose server. Event processing is the sequence of operations that occur when an event is generated by an event source and processed by event processors.

Components Involved

The following components are involved in the event processing flow:

  1. EventSource - The source of events
  2. EventToQueuePublisher - Publishes events to queues
  3. EventQueueToEventProcessorAgent - Consumes events from queues
  4. EventToInvokeStrategy - Determines how to invoke callbacks on processors
  5. EventProcessor - Processes events according to business logic

Sequence Diagram

┌───────────────┐    ┌───────────────┐    ┌───────────────┐    ┌───────────────┐    ┌───────────────┐
│EventSource    │    │EventToQueue   │    │EventQueueTo   │    │EventToInvoke  │    │EventProcessor │
│               │    │Publisher      │    │EventProcessor │    │Strategy       │    │               │
└───────┬───────┘    └───────┬───────┘    └───────┬───────┘    └───────┬───────┘    └───────┬───────┘
        │                    │                    │                    │                    │
        │  generate event    │                    │                    │                    │
        │──────────────────┐ │                    │                    │                    │
        │                  │ │                    │                    │                    │
        │<─────────────────┘ │                    │                    │                    │
        │                    │                    │                    │                    │
        │  publish(event)    │                    │                    │                    │
        │───────────────────>│                    │                    │                    │
        │                    │                    │                    │                    │
        │                    │  map event         │                    │                    │
        │                    │──────────────────┐ │                    │                    │
        │                    │                  │ │                    │                    │
        │                    │<─────────────────┘ │                    │                    │
        │                    │                    │                    │                    │
        │                    │  dispatch(event)   │                    │                    │
        │                    │──────────────────┐ │                    │                    │
        │                    │                  │ │                    │                    │
        │                    │<─────────────────┘ │                    │                    │
        │                    │                    │                    │                    │
        │                    │  write to queues   │                    │                    │
        │                    │──────────────────┐ │                    │                    │
        │                    │                  │ │                    │                    │
        │                    │<─────────────────┘ │                    │                    │
        │                    │                    │                    │                    │
        │                    │                    │  doWork()          │                    │
        │                    │                    │──────────────────┐ │                    │
        │                    │                    │                  │ │                    │
        │                    │                    │<─────────────────┘ │                    │
        │                    │                    │                    │                    │
        │                    │                    │  poll event        │                    │
        │                    │                    │──────────────────┐ │                    │
        │                    │                    │                  │ │                    │
        │                    │                    │<─────────────────┘ │                    │
        │                    │                    │                    │                    │
        │                    │                    │  processEvent()    │                    │
        │                    │                    │───────────────────>│                    │
        │                    │                    │                    │                    │
        │                    │                    │                    │  for each processor│
        │                    │                    │                    │──────────────────┐ │
        │                    │                    │                    │                  │ │
        │                    │                    │                    │<─────────────────┘ │
        │                    │                    │                    │                    │
        │                    │                    │                    │  onEvent(event)    │
        │                    │                    │                    │───────────────────>│
        │                    │                    │                    │                    │
        │                    │                    │                    │                    │  process event
        │                    │                    │                    │                    │──────────────────┐
        │                    │                    │                    │                    │                  │
        │                    │                    │                    │                    │<─────────────────┘
        │                    │                    │                    │                    │
        │                    │                    │                    │<───────────────────│
        │                    │                    │                    │                    │
        │                    │                    │<───────────────────│                    │
        │                    │                    │                    │                    │
        │                    │                    │                    │                    │

Sequence Description

  1. EventSource generates event: An EventSource generates an event, which could be from an external system, a timer, or another internal component.

  2. EventSource publishes event: The EventSource calls publish(event) on the EventToQueuePublisher to publish the event.

  3. EventToQueuePublisher maps event: The EventToQueuePublisher applies any configured data mapping to the event.

  4. EventToQueuePublisher dispatches event: The EventToQueuePublisher calls its internal dispatch(event) method to prepare for writing to queues.

  5. EventToQueuePublisher writes to queues: The EventToQueuePublisher writes the event to all target queues that have subscribed to this event source.

  6. EventQueueToEventProcessorAgent does work: The EventQueueToEventProcessorAgent's doWork() method is called by the agent runner.

  7. EventQueueToEventProcessorAgent polls event: The EventQueueToEventProcessorAgent polls an event from its input queue.

  8. EventQueueToEventProcessorAgent processes event: The EventQueueToEventProcessorAgent calls processEvent(event) on the EventToInvokeStrategy.

  9. EventToInvokeStrategy invokes processors: The EventToInvokeStrategy iterates through all registered processors.

  10. EventToInvokeStrategy calls onEvent: For each processor, the EventToInvokeStrategy calls onEvent(event) to deliver the event.

  11. EventProcessor processes event: The EventProcessor processes the event according to its business logic. It may update internal state, generate new events, or perform other actions.

  12. Processing complete: The event processing is complete, and control returns up the call stack.

Conclusion

The event processing flow in Mongoose server involves multiple components working together to deliver events from sources to processors. The sequence diagram illustrates the flow of method calls and the responsibilities of each component in the processing flow. This architecture allows for efficient and flexible event processing with clear separation of concerns.