Azure service bus unique sessions for unique clients' messages & how to make non-brokered connections?

433 Views Asked by At

I'm planning to opt for Azure service bus queue standard tier as I need to create a session enabled queue so that 1000s of my users can initiate a session (using a dynamic session guid generated on button click) & receive message in queue against that session id i.e. message meant for them only (one client doesn't receive message meant for other client, yet ensuring that all users can receive their messages in parallel to other users):

  1. Can a single session enabled service bus queue handle this scenario where each user connects (on button click) to bus using session filter (using a dynamic session guid) & receives response against that session id such that a user only receives his/her message and each user can receive his/her message in parallel while other users are also receiving messages at same time?

  2. How can I make Non-Brokered connections to this session enabled service bus queue so that I do not hit 1000 brokered connections limit? Is the following code (both sender & receiver) making non brokered connections?

Sample Sender

1. In the following code, is sender making non-brokered connection while sending message?

2. If not, what is the correct code to initiate non-brokered connection?

QueueClient responseClient = MessagingFactory.CreateFromConnectionString("Endpoint=sb://XXXXXX").CreateQueueClient("ResponseQueue");

BrokeredMessage response = new BrokeredMessage();
response.SessionId = "XYZ";
response.MessageId = "XYZ";

responseClient.Send(response);

Sample Receiver

1. In the following code, is receiver making non-brokered connection while receiving message?

2. If not, what is the correct code to initiate non-brokered connection?

3. Shall I set time to TimeSpan (0, 0, 0) to make it a non brokered connection?

QueueClient responseClient = MessagingFactory.CreateFromConnectionString("Endpoint=sb://XXXXXX").CreateQueueClient("ResponseQueue");

MessageSession receiver = responseClient.AcceptMessageSession("XYZ");
BrokeredMessage receivedMessage = receiver.Receive(new TimeSpan(0, 0, 20));

if (receivedMessage != null)
{
                Console.WriteLine(receivedMessage.MessageId + " " + receivedMessage.SessionId);
                receivedMessage.Complete();
}
0

There are 0 best solutions below