docs.particular.net icon indicating copy to clipboard operation
docs.particular.net copied to clipboard

Feedback: 'Batched message dispatch'

Open shirin-monzavi opened this issue 2 years ago • 1 comments

Feedback for 'Batched message dispatch' https://docs.particular.net/nservicebus/messaging/batched-dispatch

Location in GitHub: https://github.com/Particular/docs.particular.net/blob/master/nservicebus/messaging/batched-dispatch.md

Dear sir/ madam I have read your article with a huge amount of effort as a result I think that I got it so I edit it like the following I hope other readers read it better.

What? Starting from Versions 6, all outgoing operations (e.g. commands, responses, events) are bundled together and are handed to the transport only after the message handling pipeline has completed (the transactional session offers similar behavior for outgoing message operations when the session is committed).

Note: This feature is in Nservicebus but in the transaction receive only mode it can been seen effectively.

Note: Command and events are asynchronous but responses are synchronous.

Problem: 1. How can we avoid back and forth trips during outgoing operations in order to increase performance? 2. Imagine during business operation in a handler some messages should be sent what if during business operation will face an error in this case some of messages are sent but our business operation because of some reasons is rolled back. How can we handle it?

Solution: Sends and Publishes are batched feature which is belong to NServicebus.

• Business data operations will be committed to storage before outgoing operations are dispatched. This ensures no outgoing messages are sent in case an exception occurs - during or after the business data operations are committed.

• Allows transports to improve performance by batching outgoing operations. Since transports get access to all outgoing messages as a group they can optimize communication with the underlying queuing infrastructure to minimize round trips.

shirin-monzavi avatar Jul 12 '23 13:07 shirin-monzavi

@shirin-monzavi If you want to send messages immediately you can use immediate dispatch:

  • https://docs.particular.net/nservicebus/messaging/send-a-message#dispatching-a-message-immediately

I think your question is related on to how reply/respond a logical failure, you can use Reply with the ReplyOption set to use immediate dispatch:

  • https://docs.particular.net/nservicebus/messaging/reply-to-a-message

ramonsmits avatar Aug 14 '23 16:08 ramonsmits