Search code examples
c#azureazure-servicebus-queues

Should we use Azure Service Bus Queue built-in CorrelationId property or UserProperties?


We're developing a Web API application that will receive a correlation-id header (GUID) in the request and will trigger a backend process asynchronously by sending a message to an Azure Service Bus Queue. We'd like to pass this correlation-id around for end to end monitoring purposes.

Should we use the CorrelationId built-in property or add a CorrelationId user property to UserProperties dictionary of the Microsoft.Azure.ServiceBus.Message? What's the best practice?


Solution

  • The CorrelationId property is there for convenience just like the ContentType, To or ReplyTo properties. They are typically used for various message patterns and unlike other system properties can be used without any concerns.

    Short answer: use it rather than duplicating by introducing a custom property with identical intent.