Time Travel with a Message Queue

I was discussing the usages of message queues with some colleagues and surprised them with temporal coupling.

Message Queues perform buffers between applications so that they can process data at different rates. It also protects from outages allowing each side to be restarted or upgraded independently.

However most modern message queues have additional options such as the ability to send a message to the future! The message is sent hidden for a time period. The trick to to send a command that will rollback the operation you are just starting. If your process stops normally then this message can be deleted before it is read. If the process dies then the message will appear and can be used to clean up. This is like having a finally block that will survive a process restart!

Another trick is to send messages that are deleted after a given time. I have used this to have a log available that starts logging 5 minutes ago. This means that when a problem occurs you can capture the last 5 mins of events leading up to it. This can prove invaluable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s