Writing a spooler in an NServiceBus Handler

(Jatinder Brar) #1

I am looking to implement an emails spooler that processes one message at a time from a storage queue, with no retries (as a retry could result in the same email being sent out more than once) . Am I correct in assuming this is not an appropriate use case for an NServiceBus Handler? Reason for the question is that the message to process originates from an NserviceBus Handler, and if I can bypass the work of deploying additional infrastructure it saves me considerable effort. Thanks for any insight you may be able to share.

(Ramon Smits) #2

Why would that not be a good use case?

Just host the handler in its own endpoint, set the max concurrency to 1 to achieve sequential message processing

Also set immediate and delayed retries to 0. You can also set the transaction mode of the transport to None

By the way, most email providers have idempotent interfaces these days meaning you can easily send the same message more than once within a certain time window. Usually you have to provide an Identifier for the service to deduplicate. You can use the message identifier for this and retrieve this in your handler:

– Ramon