liveBook · Manning

Polling publisher

As explained in Microservices Patterns, Second Edition

A messaging pattern in which a separate process periodically queries a database outbox for unsent messages and publishes them.

A polling publisher moves messages from a database outbox to a message broker. A separate MessageRelay periodically queries the outbox for unpublished messages, sends each to its destination channel, then deletes it from the outbox. section 8.3.8

Choose the pattern with its operating trade-offs in mind:

  • Polling is simple and works reasonably well at low scale, but frequent database queries can be expensive. section 8.3.8
  • With NoSQL, efficient polling depends on whether the database can query business entities with pending messages. Consider transaction-log tailing when polling is too costly or impractical. section 8.3.8
Figure 8.17 A service reliably publishes a message by inserting it into an OUTBOX table as part of the transaction that updates the database. The Message Relay reads the OUTBOX table and publishes the messages to a message broker.
ReliablePublication

The diagram shows the outbox-to-relay-to-broker flow. section 8.3.8

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains the relay’s query-publish-delete steps and trade-offs, but defers to transaction-log tailing for a more sophisticated alternative.
Examples
Uses a relational OUTBOX table queried by a MessageRelay, with messages sent to broker channels and then deleted.
What it assumes
Assumes familiarity with database outboxes, message relays, and message brokers; does not teach those concepts from zero.
What you can do after
Apply it by having a separate relay periodically query unpublished outbox messages, publish them, and remove them from the table.
How it connects
Connects to the transaction outbox, message brokers, and transaction-log tailing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.