Question

From a sender/receiver perspective there's something between them called the BUS that handles the messages, releases our sender thread, and sends the message whenever the receiver is available, and retries if the receiver is not available.

Just want to understand where does this magic "BUS" lives behind the scenes? In the sender machine? Is it just an output queue in the sender machine?

If it is just an output queue in the sender, how does it retry if the sender is offline?

Was it helpful?

Solution 2

In the case of MSMQ transport, Bus.Send is always a local action. Message is stored in a local outgoing queue. MSMQ takes care of the reliable transfer between the PCs.

This concept is called store and forward.

If there's a problem with the local outgoing queue (eg queue is full), NServiceBus will throw an exception and it's up to the sending code to retry again.

NServiceBus retries come in at the receiving end, ie. after the message has been successfully received by the recipient.

The bus abstracts the entire end to end communication between sender and receiver.

It all starts with

Bus.Send<MyMessage>()

and ends, often on another PC, with

MyHandler : IHandleMessages<MyMessage>

OTHER TIPS

So, basically, where does "the Bus" live? That makes the assumption that there's just one "the Bus" which isn't necessarily accurate.

Think of "the Bus" like your Ethernet card. You don't say "where does the Ethernet live?"

In reality, since you're asking about NServiceBus, "the Bus" is the abstraction over many components including message handlers, message serializers (usually XML or JSON), an underlying message transport (MSMQ, RabbitMQ, ActiveMQ, SQL Server, Azure, or others) which is itself of course an abstraction over TCP, etc. The framework runs on both the sending and receiving side of any message that is sent or published in order to give you the features like automatic retries, etc.

The question is very broad so it's impossible to answer fully in a consise manner, luckily somebody (disclaimer: that somebody is me) already wrote a book about that. Not surprisingly, I highly recommend it. ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top