I am trying to understand Rabbitmq and how I can accomplish sequential message processing in certain circumstances only. For example if I have 2 queues. One for pricing an order and one for sending out an invoice. Sometimes these queues would get messages and be processed independently, but other times they are dependent as a process would need to wait for the pricing to be completed before the invoice could be sent. How can this be accomplished if at all? I have looked at RPC and Reply-to as possible answers but I am not sure.

  • Good question that I'd like to see an answer to - in the hopes of getting an answer I submitted an edit to widen the scope from rabbitmq only to message queuing systems in general (as IMO this is more a matter of the architecture of a message-queuing application and any proper answer would apply to (nearly) all message queueing systems, modulo details).
    – davidbak
    Commented Jul 14, 2022 at 20:05
  • I highly doubt this is possible to do in the message queue itself. You need logic to determine what type of request it is, and then if this request needs to wait for the pricing, it needs to stay somewhere. I'd implement this logic in an application and not the message broker. Commented Jul 16, 2022 at 8:47
  • @AlexBrohshtut yes one possible solution is to have the application send the price message and wait for pricing completion but how to accomplish even this?
    – beater
    Commented Jul 16, 2022 at 13:07
  • Let's say you have init service, pricing service and invoice service. Init service decides whether the current order can be processed simultaneously or invoice after pricing. If it can be done simultaneously - it sends 2 messages to queue - invoice and pricing. If the order needs to be processed in a sequence, then init service sends pricing message to queue, and the pricing service, which processed the message - sends another message (invoice) to the queue. Commented Jul 16, 2022 at 14:07
  • If I understand, that would require pricing service to know about invoice service and require the message originally sent pricing service to contain extra processing data to instruct it to next send a message to invoice or not. That's not acceptable.
    – beater
    Commented Jul 16, 2022 at 15:47

1 Answer 1


"Sometimes" and "other times" - who decides this, based on which information? That's the entity that should initiate the correct message routing, in one case by sending parallel messages to pricing and invoicing, in the other case by instructing the pricing process to send its results to invoicing to achieve the correct sequencing.

Use the information you have, don't try to look for a solution that depends on some unspecified magic.

  • pricing should not know about invoicing and create an unnecessary dependency. I queue, 1 function. Yes the "who decides entity" knows the flow but it still comes down to how do you wait for a response form pricing before sending to invoice.
    – beater
    Commented Jul 25, 2022 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.