Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Majordomo Pattern , Implementation of New Async method for post processing after message received #12

Open
KamranShahid opened this issue Oct 15, 2019 · 0 comments

Comments

@KamranShahid
Copy link

KamranShahid commented Oct 15, 2019

In MDPBroker.cs of MajordomoPattern implementation i feel there is delay in responding to message after it recieved at broker.

So i am creating a async version of one method. Please comment if there is anything wrong in it as per pattern implementation

private void ProcessReceivedMessageAsync(object sender, NetMQSocketEventArgs e)
        {
            try
            {
                var msg = e.Socket.ReceiveMultipartMessage();
                Debug.WriteLine($"Received: {msg}");
                var senderFrame = msg.Pop();               // [e][protocol header][service or command][data]
                var empty = msg.Pop();                     // [protocol header][service or command][data]
                var headerFrame = msg.Pop();               // [service or command][data]
                var header = headerFrame.ConvertToString();

                switch (header)
                {
                    case MDPConstants.MDP_CLIENT_HEADER:
                        {
                            Task.Factory.StartNew(() => ProcessClientMessage(senderFrame, msg), TaskCreationOptions.LongRunning);
                        }
                        break;
                    case MDPConstants.MDP_WORKER_HEADER:
                        ProcessWorkerMessage(senderFrame, msg);
                        break;
                    default:
                        Debug.WriteLine("ERROR - message with invalid protocol header!");
                        break;
                }
            }
            catch (Exception ex)
            {

                Logger.Fatal(ex.Message, ex);
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant