arcus-azure/arcus.messaging

ServiceBusMessageBuilder should be more tolerant for unspecified arguments

fgheysels opened this issue · 2 comments

The ServiceBusMessageBuilder type has methods like:
WithOperationId
WithTransactionId
etc...

These methods throw an exception if you pass in an empty or null operationId, transactionId, etc...
This means that the caller needs to check upfront if he can call that message, which makes the calling code much more bloated.
It would mean that you cannot write code like this:

image

because, whenever one of the id's is not available, it will throw.

Next to that, it will also result in exceptions being thrown and messages that cannot be sent, just for this.
Logging is great, but if you run into a situation where you would normally add an operation-id, and that id is missing for some reason or another, we should not cause that a message cannot be sent. Businesses rely on messaging, so we should not throw there.

When the operationId, parentId, ... is not there, we should just not add that information in the application-properties of the message. I think it is also the power of such a builder pattern, that it takes care of those things.

See also how the extension method (that should become obsolete) is called in the service-to-service POC:

image

Ok, great! Will indeed be an improvement here.