1
votes

I'm trying to use the request reply pattern as described in the microsoft docs (https://docs.microsoft.com/en-us/azure/service-bus-messaging/message-sessions#request-response-pattern)

"Multiple applications can send their requests to a single request queue, with a specific header parameter set to uniquely identify the sender application. The receiver application can process the requests coming in the queue and send replies on the session enabled queue, setting the session ID to the unique identifier the sender had sent on the request message. The application that sent the request can then receive messages on the specific session ID and correctly process the replies."

As I understand it, it should be possible to send a message from multiple applications, have the receiver handle the message and send a response that will only be picked up by the initial sender.

Maybe I'm wrong, but a bit like this.

enter image description here

This doesn't seem to be documented (only using sessions for ordered message handling) and I have no luck finding how to implement this.

Does anybody have an idea/experience with this?

I am using .net core 3.1 with the microsoft azure servicebus package (4.1.2)

1

1 Answers

0
votes

Ok, it took some time figuring out but I think I was able to achieve the setup from the diagram.

Here is the process as it may help others:

I have one normal queue (PostNL queue) and one shared 'applications' queue that is sessions enabled

  • An application (e.g App1) sends a message to the PostNL queue using a QueueClient and setting a unique SessionId
  • The receiver handles the incoming messages through QueueClient.RegisterMessageHandler
  • The receiver processes the message and sends a reply to the applications queue using QueueClient.SendAsync (the replymessage has the SessionId set to UniqueSessionId)
  • The sender uses a session = SessionClient.AcceptMessageSessionAsync("UniqueSessionId")
  • The sender can start receiving messages in this session using session.ReceiveAsync (all the other applications listening on the applications queue will not compete for these reply messages as long as they use other session Ids)