0

We are running Rebus as a backbone for our batch system. We have several queues (i.e. message types) which can be handled by several workers. Each worker can only handle one message type. So for example for message_1 we have 2 workers (worker1 and worker2) which can handle this message. Currently the first worker which is free handle will handle the message. This is the default behavior and working good.

My query is if I can setup Rebus in any way so that if the message contains a worker id (for example for worker 2) only that worker should be able to process that message. If no worker id is in the message, then default behavior (see above) should prevail.

jopa
  • 145
  • 1
  • 9

1 Answers1

1

There's no way (at least not at the moment) to achieve the thing you're describing here.

If you have special requirements for certain message types (or certain message instances), I suggest you forward those messages to one or more special endpoints that can handle those kinds of messages.

The forwarding can be done based on headers and can thus be set up to work in a generic fashion without necessarily being able to deserialize the message contents.

If you tell me more about what problem it is you're trying to solve, maybe we can figure out a more elegant solution (or at least one that can be solved more elegantly with Rebus).

mookid8000
  • 18,258
  • 2
  • 39
  • 63
  • do you mean bus.Advanced.Routing.ForwardCurrentMessage method with custom header (not specified in Rebus.Shared.Headers)? – user1121956 Oct 06 '14 at 11:47
  • yes, that's definitely an option, although that does result in deserializing the message - if you're interested in doing routing without deserializing, I suggest you take a look at using `MsmqMessageQueue` directly – mookid8000 Oct 06 '14 at 12:25
  • but I am becoming more and more interested in learning about what kind of problem it is you're trying to solve :) – mookid8000 Oct 06 '14 at 12:25
  • I'm not orginal OP but I'm wondering what do you mean by using MsmqMessageQueue directly - do you mean to not create bus instance at all and use MsmqMessageQueue independently like HTTP gateway does? :) – user1121956 Oct 06 '14 at 13:13
  • 1
    that is exactly what I mean, yes - you can even make your router transport-agnostic if you let it do its work on [`IDuplexTransport`](https://github.com/rebus-org/Rebus/blob/master/src/Rebus/IDuplexTransport.cs) alone – mookid8000 Oct 06 '14 at 15:00
  • I am not OP either but we work together :) The problem we are looking at different ways to handle is affinity. A certain worker can cache quite heavily and we can reduce workload by a lot. But we are looking for a way forward without a distributed cache. In akka for example there is ConsistentHashingPool and ConsistentHashingGroup. But we realize that of course this requires push instead of pull – Jon Oct 07 '14 at 07:48