I have following (simplified) setup
Consumer (single threaded, streamingConnection is singleton)
val streamingConnection by instance<StreamingConnection>()
streamingConnection.subscribe(Topics.OUTPUT_ORDER, OrderHandler())
streamingConnection.subscribe(Topics.OUTPUT_TRANSACTION, TransactionHandler())
Producer (single threaded, streamingConnection is singleton)
- Publishes message to Topics.OUTPUT_ORDER
- Publishes message to Topics.OUTPUT_TRANSACTION
Is nats streaming garantees, that consumer receives and handles messages in the same order? I have order id in transaction payload and I must know the id before transaction processing.
From nats java library description:
The new version minimizes threads. Only one thread is used for all callbacks, by relying on a dispatcher in the underlying NATS connection.
If there is only one thread, Topics.OUTPUT_TRANSACTION processing on consumer will be blocked until Topics.OUTPUT_ORDER onMessage() handler finishes. Am I right?