4 ArchitecturePubSub
Ralph Schaer edited this page 2026-10-30 16:08:52 +01:00

Publish/Subscribe Architecture

The broker side handles topic subscriptions, publications, and event delivery.

Current broker functionality includes:

  • subscription routing in a single shared scope
  • server-side topic listeners through @WampListener
  • server-side publication through WampPublisher
  • publisher identification and publisher exclusion
  • subscriber include/exclude filtering
  • pattern-based subscriptions
  • event retention and per-subscription history through EventStore
  • subscription/session meta APIs and revocation support

Listener methods can subscribe to one or more topics and can opt into non-exact matching through the annotation match policy.

flowchart TD
    Client[Client PUBLISH] --> Inbound[clientInboundChannel]
    Publisher[WampPublisher] --> BrokerChannel[brokerChannel]
    Inbound --> Broker[PubSubMessageHandler]
    BrokerChannel --> Broker
    Broker --> Authorize[Validate topic and authorize]
    Authorize --> Match[SubscriptionRegistry matching and shard selection]
    Match --> Store[EventStore history]
    Match --> Filter[Recipient filtering]
    Filter --> Outbound[EVENT through clientOutboundChannel]
    Match --> Local[Annotated Java listeners]
    Authorize --> Retain[EventStore retention when requested]

SUBSCRIBE and UNSUBSCRIBE update the registry and generate lifecycle events. The registry combines remote subscribers and local annotated listeners. Publications use exact, prefix, or wildcard matching; recipient filters apply to remote sessions. Server publication excludes local listeners by default unless exclude_me is false.

The default MemoryEventStore retains only server-originated messages and keeps unbounded per-subscription history in memory. See PubSub for store customization and MetaAPIs for history queries.