Tom Freudenberg
Tom Freudenberg

Reputation: 1367

RabbitMQ - Ruby - Bunny - Best practise to (re-)publish messages to next queue

we are checking RabbitMQ for some Workflow use case.

So far, we created a test environment with ruby which fits our needs and seems to work fine.

The question I have, in case of being Rabbit newbies, is about best / good practise.

Lets define 3 QUEUES (just for the example)

  1. Q_DECISION
  2. Q_RIGHT
  3. Q_LEFT

every producer will post message inside Q_DECISION

There is a worker running on that queue which check some content of the body. In case of decision, the message / task has to be moved to Q_LEFT or Q_RIGHT.

We are storing message specific information properties.headers, so we repeat them as well as the body.

So far no problem, question is now about republishing:

q_decision.subscribe(:block => true) do |delivery_info, properties, body|

  # ... more code here

  if (decision_left)

    q_left.publish(body, :headers => properties.headers, :persistent => true)

  end

end

If we do re-publishing like above, do we loose something from the previous message?

There are a lot of attributes defined / stored in delivery_info and properties as well.

Do we have to re-post them or only the self created headers and body?

Upvotes: 0

Views: 1215

Answers (1)

old_sound
old_sound

Reputation: 2313

Message body and message headers are two different things. I would assume bunny or any client library will create a new message with the body you are passing. This means you need to re-set the headers you want to pass to the next queue as well.

Upvotes: 1

Related Questions