Reputation: 1660
I am trying to rewrite my Server/Client(TCP based connection) program to make it use the Azure Server Bus Queue instead, but I can't figure out how to "organize" Queues and Messages from/to different clients in a way to stop them being read by each other.
Let me start with this scenario: 1 - A client connect to the queue and put in let us say -log in message (Username/Password) into the LOG-IN queue.
2 - Server reading messages found that one of the clients is trying to log in, it reads the message, check the provided details and put results in LOG-IN-RESULT queue.
3 - The client the suppose to read from the LOG-IN-RESULT, but how to guarantee that it is reading its result not another client's?
Sorry for the lack of code, the question is purely about the structure/principal I guess.
Thanks
Upvotes: 1
Views: 182
Reputation: 25050
First of all, I cannot say your queue-based system is suitable for logon scenario. But in your case, I think three options are possible based on Azure.
1. Use Subscription query (not recommended)
Azure Service Bus has Topics and Subscriptions capability. you can create query to receive exact same Guid. I did not test performance in this case, but it is capable as below.
namespaceManager.CreateSubscription("LoginTopic", "LOG-IN-RESULT", new SqlFilter("RequestGuid = '3872-ACD3-38FB-2311-2002'"));
For more information about Subscription, please read this documentation: link
2. Use Azure Storage Table
Azure Table gives query capability so you can use it instantly as below Odata query.
https://myaccount.table.core.windows.net/LoginTable(PartitionKey='LOG-IN-RESULT',RowKey='3872ACD338FB23112002')
For more information about Azure Table, please refer this link.
3. Use Azure Sql or other rdbms.
I think you already know. Just Insert and Select.
Upvotes: 1
Reputation: 731
You can implement an unique identifier for a user who is trying to log in (suppose it is a cookie containing Guid identifier, assigned when user requests a page), let's name it UserId. You can then save the identifier as a part of message id. Then, the client application will only try to read only the messages, which ids contain the specified UserId.
Upvotes: 0