What is the difference between SQS vs RabbitMQ vs Memphis?
Avatar Idan Asulin
Apr 16, 2023
14 15 16
What is the difference between RabbitMQ vs ZeroMQ vs Memphis?
Avatar Idan Asulin
Apr 16, 2023
10 11 12
What is the difference between Kafka vs ZeroMQ vs Memphis?
Avatar Yaniv Ben Hemo
Apr 16, 2023
2 3 4
What is the difference between Azure Event Hub vs Kafka vs Memphis?
Avatar Idan Asulin
Apr 16, 2023
5 6 7
How does ActiveMQ vs RabbitMQ vs Kafka vs Memphis work?
Avatar Idan Asulin
Apr 16, 2023
7 8 9
What is ActiveMQ vs IBM MQ vs Memphis?
Avatar Yaniv Ben Hemo
Apr 16, 2023
3 4 5
What is IBM MQ?
Avatar Yaniv Ben Hemo
Apr 16, 2023
4 5 6
What is an mq server?
Avatar Idan Asulin
Apr 16, 2023
3 4 5
How does mq messaging take place?
Avatar Idan Asulin
Apr 16, 2023
2 3 4
How does Kafka delayed message work?
1 2 3

You can delay messages in Kafka by delaying their production or delaying their processing after they are consumed. 

In itself, Kafka doesn’t support delayed messages.
Delayed messages are when a message broker keeps messages for a set amount of time (the delay) after the messages have been produced to the broker.
The broker will send the messages to the consumers only after the delay has elapsed.

To delay messages in Kafka at their production, use a job scheduler to produce the messages after the delay.
Using a job scheduler is safer than delaying inside your codebase.
Your code could stop running because of an error.
But a scheduler is perfect for its job of executing jobs at its timing.
After the scheduler produces to Kafka, consumers will poll from Kafka immediately.
The net effect is the delay was respected. 

To delay messages in Kafka at their consumption, introduce timestamps in the message body.
Add the delay to the current time and save the sum (the future timestamp) inside the message.
Produce the message and the consumer will poll it from Kakfa immediately.
However, the trick is in the consumer using the message.
Configure the consumer code to only use up the message contents after the timestamp that was set inside the message. 

In summary, while Kafka doesn’t natively delay messages, you can delay messages while using it.
Produce the message after the delay or process a consumed message after the delay has elapsed.
Either way, you would have delayed messages in Kafka.