Transactional messaging Flashcards

1
Q

Transactional messaging

A

Transactional outbox (application publish events)
Transaction log tailing
Polling publisher

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Transactional outbox: context

A

A service typically need to atomically update the database and publish messages/events. For example, perhaps it uses the Saga pattern. In order to be reliable, each step of a saga must atomically update the database and publish messages/events. Alternatively, it might use the Domain event pattern, perhaps to implement CQRS. In either case, it is not viable to use a distributed transaction that spans the database and the message broker to atomically update the database and publish messages/events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Transactional outbox: problem

A

How to reliably/atomically update the database and publish messages/events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Transactional outbox: forces

A

2PC is not an option

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Transactional outbox: solution

A

The application that uses a relational database inserts messages/events into an outbox table (e.g. MESSAGE) as part of the local transaction. An application that uses a NoSQL database appends the messages/events to attribute of the record (e.g. document or item) being updated. A separate Message Relay process publishes the events inserted into database to a message broker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Transactional outbox: result benefits

A

High level domain events

No 2PC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Transactional outbox: result drawback

A

Potentially error prone since the developer might forget to publish the message/event after updating the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Transactional outbox: issues

A

The Message Relay might publish a message more than once. It might, for example, crash after publishing a message but before recording the fact that it has done so. When it restarts, it will then publish the message again. As a result, a message consumer must be idempotent, perhaps by tracking the IDs of the messages that it has already processed. Fortunately, since Message Consumers usually need to be idempotent (because a message broker can deliver messages more than once) this is typically not a problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Transactional outbox: related

A

The Saga and Domain event patterns create the need for this pattern.
The Event sourcing is an alternative solution
There are two patterns for implementing the message relay:
* The Transaction log tailing pattern
* The Polling publisher pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Transactional log tailing: context

A

You have applied the Application events pattern. In order to be reliable, each step of a saga must atomically update the database and publish messages/events. It is not viable to use a distributed transaction that spans the database and the message broker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Transactional log tailing: problem

A

How to publish messages/events into the outbox in the database to the message broker?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Transactional log tailing: solution

A

Tail the database transaction log and publish each message/event inserted into the outbox to the message broker.

The mechanism for trailing the transaction log depends on the database:

MySQL binlog
Postgres WAL
AWS DynamoDB table streams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Transactional log tailing: example

A

Eventuate Local implements transaction log tailing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Transactional log tailing: result benefits

A

No 2PC

Guaranteed to be accurate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Transactional log tailing: result drawback

A

Relatively obscure although becoming increasing common
Requires database specific solutions
Tricky to avoid duplicate publishing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Transactional log tailing: related

A

The Application events pattern creates the need for this pattern.
The Polling publisher is an alternative solution

17
Q

Polling publisher: context

A

You have published messages/events using the Application events pattern.

18
Q

Polling publisher: problem

A

How to publish messages/events into the outbox in the database to the message broker?

19
Q

Polling publisher: solution

A

Publish messages by polling the outbox in the database.

20
Q

Polling publisher: example

A

Eventuate Local supports polling.

21
Q

Polling publisher: result benefits

A

Works with any SQL database

22
Q

Polling publisher: result drawbacks

A

Tricky to publish events in order

Not all NoSQL databases support this pattern

23
Q

Polling publisher: related

A

The Transactional outbox creates the need for this pattern

The Transaction log tailing pattern is an alternative solution