Search code examples
c#.netmsmq

Msmq what is the right way of implementation of users


So, this is not the right title probably, i was not sure how to put it and how to explain in, lets try !

i have a system that manage more then 720,000 users, i did not use queue until now and i want to start using it, lets give an example os a class that hold a user

[Serializable]
    public class UserName
    {
        public string UserNameName { get; set; }
        public string TheResonILikeTo { get; set; }
    }

so, if i want to put a message inside my queue its simple

public static void Createandsendmessageclass()
        {
            //From Windows Service, use this code
            MessageQueue messageQueue = null;
            if (MessageQueue.Exists(@".\Private$\SomeTestName"))
            {
                messageQueue = new MessageQueue(@".\Private$\SomeTestName");
                messageQueue.Label = "Testing Queue";
            }
            else
            {
                // Create the Queue
                MessageQueue.Create(@".\Private$\SomeTestName");
                messageQueue = new MessageQueue(@".\Private$\SomeTestName");
                messageQueue.Label = "Newly Created Queue";
            }
            UserName user = new UserName();
            user.UserNameName = "Alon";
            user.TheResonILikeTo = "Fuc??";
            messageQueue.Send(user);
        }

until here all is great and smooth. nothing to worry about.

But, lets say i have 720,000 users that has messages with different name,

  • Alon
  • Erez *Ylan

and so on..

should i put a different queue for each user, or can i ask the system to give me only messages for user "alon" by usernamename?

another question, how can i tell my code to keep getting messages? running in a while loop?

thanks everyone ! good day


Solution

  • Most important thing to remember is that MSMQ is a network protocol, not a database. It isn't appropriate for a system designed to store messages for 720,000 users. All your data for users should be stored in a database.