In the older service bus package (Microsoft.Azure.ServiceBus), we could grab the message from an Event (https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-end-to-end-tracing?tabs=net-standard-sdk)
For example, we could listen for Event named Microsoft.Azure.ServiceBus.Send.Start and as part of the payload, there would be a List of Messages being sent.
How can we do the same with the new package (Azure.Messaging.ServiceBus)? I looked at this link but couldn't find anything: https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-end-to-end-tracing?tabs=net-standard-sdk-2
For additional context, I am trying to get the message before it is sent and add some values to the User Properties (or with the new package, it would be Application properties)
Some sample of our code with the old package as an example/for additional context:
const string SERVICE_BUS_STOP_PROCESSING_EVENT = "Microsoft.Azure.ServiceBus.Process.Start";
const string SERVICE_BUS_START_SENDING_EVENT = "Microsoft.Azure.ServiceBus.Send.Start";
public void OnNext(KeyValuePair<string, object> value)
{
switch (value.Key)
{
case SERVICE_BUS_STOP_PROCESSING_EVENT:
{
var payload = new EventPayload();
try
{
// As part of the payload the Messages would be in the form of Message[] or List<Message>
var message = payload.FetchPayloadProperty<Message>(value.Key, "Message", value.Value);
// Our logic for adding user properties to the message
}
catch (Exception e)
{
// ...
}
}
break;
case SERVICE_BUS_START_SENDING_EVENT:
{
var payload = new EventPayload();
messageArray = payload.FetchPayloadProperty<Message[]>(value.Key, "Messages", value.Value);
// Our logic for adding user properties to the message
}
break;
}
}
Thank you!