I don't see the difference between the Inbox pattern and the Outbox pattern.
the Inbox pattern saves messages in a database. The Outbox pattern too, so what is the difference?
Actually it's very good question.
There are some differences which we should take consider. For first we got 3 approaches to delivery messages:
Outbox pattern and inbox pattern descirbes "at least once" strategy. Let's have a look for real live example when You got API-one, message broker and API-two, so two microservices with message broker.
What is a problem here? If entity will be saved to DB and for some reason after that BUT BEFORE send event your api will die, API-two will be not informed about that operation, and Your data will be inconsistent.
Outbox pattern:
Inbox pattern
In inbox pattern situation is little bit different but very similar
To sum up - Outbox pattern - You store events into DB of API-one Inbox patter - You store events into DB of API-two
Main difference is that Outbox is for OUTCOME and Income is for processing incoming messages
Indeed, the essence of these patterns is the same. They both solve the problem of data inconsistency resulting from message send/receive errors. But they solve different halves of the problem and live on opposite sides of the message flow.
Inbox guarantees that a message will be received at least once - i.e., there will never be a situation where some work was scheduled but never performed.
Outbox guarantees that a message will be sent at least once - i.e., there will never be a situation where some work was performed but nobody was acknowledged about this.
Both of these patterns use a table in the DB in a similar way - as an intermediate buffer for messages (inbox for incoming, and outbox for outgoing), from which messages are then read out by a separate worker and processed. But they use it for different purposes.
BTW, these patterns can be used together - the same worker reads a message from the inbox, executes business logic with it, and writes a new message to the outbox.
A good article on this topic: Microservices 101: Transactional Outbox and Inbox