English 中文(简体)
Messaging pattern question
原标题:

Process A is calculating values for objects a1, a2, a3 etc. and is sending results to the middleware queue (RabbitMQ). Consumers read the queue and process these results further. Periodically process A has to send a snapshot of these values, so consumers could do some other calculations. Values for these objects might change independently. The queue might look like this a1, a1, a2, a1, a2, a2, a3... Consumers process each item in the queue. The snapshot has to contain all objects and consumers will process this message for all objects in one go.

So the requirement is to have a queue like this: a1, a1, a3, a2, a2, [snapshot, a1, a2, a3], a3, a1 ... The problem is that these items are of different types: one type for objects like a1, a2 and other for a snapshot. This means that they should be processed in a diferent queues, but in that case there is a race condition: consumers might process objects before processing a snapshot.

Is there any pattern to solve this (quite common) problem? We are using RabbitMQ for message queueing.

最佳回答

Use a single queue per consumer and a content-type prefix to indicate the type of message being delivered. In think there may be a type attribute in AMQP messages, but I ve never used it, so I don t know if it s applicable to this problem.

问题回答

暂无回答




相关问题
Why use AMQP/ZeroMQ/RabbitMQ

as opposed to writing your own library. We re working on a project here that will be a self-dividing server pool, if one section grows too heavy, the manager would divide it and put it on another ...

Objective-C/Cocoa threads and messaging conundrum

I have a problem that has been plaguing me for awhile now, I have come up with a solution which I will detail below, and although it seems to be working well I m not super enthusiastic about it from a ...

Browsers and Windows Messaging

I was asking myself how the browsers are working. How does the browser tell to the OS to change the mouse pointer from arrow to hand(IDC_HAND) for example. In desktop application I know that are used ...

Persistable and Repeatable Commands

Imagine that we have stuff we want done in the system and sometimes exceptions are raised while doing it. We want to give the end users a report of those errors so they have an opportunity to fix the ...

热门标签