Example #1
0
        /// <summary>
        /// Send a message to broker
        /// if no message provided create a new empty one
        /// prepend the message with the MDP prologue
        /// </summary>
        /// <param name="mdpCommand">MDP command</param>
        /// <param name="data">data to be sent</param>
        /// <param name="message">the message to send</param>
        private void Send(MDPCommand mdpCommand, string data, NetMQMessage message)
        {
            // cmd, null, message      -> [REPLY],<null>,[client adr][e][reply]
            // cmd, string, null       -> [READY],[service name]
            // cmd, null, null         -> [HEARTBEAT]
            var msg = ReferenceEquals(message, null) ? new NetMQMessage() : message;

            // protocol envelope according to MDP
            // last frame is the data if available
            if (!ReferenceEquals(data, null))
            {
                // data could be multiple whitespaces or even empty(!)
                msg.Push(data);
            }
            // set MDP command                          ([client adr][e][reply] OR [service]) => [data]
            msg.Push(new[] { (byte)mdpCommand });       // [command][header][data]
            // set MDP Header
            msg.Push(m_mdpWorker);                      // [header][data]
            // set MDP empty frame as separator
            msg.Push(NetMQFrame.Empty);                 // [e][command][header][data]

            //Log ($"[WORKER] sending msg to broker / Command {mdpCommand}");

            m_worker.SendMultipartMessage(msg);
        }
Example #2
0
        /// <summary>
        ///     sends a message to a specific worker with a specific command
        ///     and add an option option
        /// </summary>
        private void WorkerSend (Worker worker, MDPCommand command, NetMQMessage message, string option = null)
        {
            var msg = message ?? new NetMQMessage ();

            // stack protocol envelope to start of message
            if (!ReferenceEquals (option, null))
                msg.Push (option);

            msg.Push (new[] { (byte) command });
            msg.Push (MDPConstants.MDP_WORKER_HEADER);
            // stack routing envelope
            var request = Wrap (worker.Identity, msg);

            DebugLog ($"Sending {request}");
            // send to worker
            Socket.SendMultipartMessage (request);
        }
Example #3
0
        /// <summary>
        ///     sends a message to a specific worker with a specific command
        ///     and add an option option
        /// </summary>
        private void WorkerSend(Worker worker, MDPCommand command, NetMQMessage message, string option = null)
        {
            var msg = message ?? new NetMQMessage();

            // stack protocol envelope to start of message
            if (!ReferenceEquals(option, null))
            {
                msg.Push(option);
            }

            msg.Push(new[] { (byte)command });
            msg.Push(MDPWorkerHeader);
            // stack routing envelope
            var request = Wrap(worker.Identity, msg);

            DebugLog(string.Format("Sending {0}", request));
            // send to worker
            Socket.SendMessage(request);
        }
Example #4
0
        /// <summary>
        ///     sends a message to a specific worker with a specific command 
        ///     and add an option option
        /// </summary>
        private void WorkerSend (Worker worker, MDPCommand command, NetMQMessage message, string option = null)
        {
            var msg = message ?? new NetMQMessage ();

            // stack protocol envelope to start of message
            if (!ReferenceEquals (option, null))
                msg.Push (option);

            msg.Push (new[] { (byte) command });
            msg.Push (MDPWorkerHeader);
            // stack routing envelope
            var request = Wrap (worker.Identity, msg);

            DebugLog (string.Format ("Sending {0}", request));
            // send to worker
            Socket.SendMessage (request);
        }
Example #5
0
        /// <summary>
        /// Send a message to broker
        /// if no message provided create a new empty one
        /// prepend the message with the MDP prologue
        /// </summary>
        /// <param name="mdpCommand">MDP command</param>
        /// <param name="data">data to be sent</param>
        /// <param name="message">the message to send</param>
        private void Send(MDPCommand mdpCommand, string data, NetMQMessage message)
        {
            // cmd, null, message      -> [REPLY],<null>,[client adr][e][reply]
            // cmd, string, null       -> [READY],[service name]
            // cmd, null, null         -> [HEARTBEAT]
            var msg = ReferenceEquals(message, null) ? new NetMQMessage() : message;
            // protocol envelope according to MDP
            // last frame is the data if available
            if (!ReferenceEquals(data, null))
            {
                // data could be multiple whitespaces or even empty(!)
                msg.Push(data);
            }
            // set MDP command                          ([client adr][e][reply] OR [service]) => [data]
            msg.Push(new[] { (byte)mdpCommand });     // [command][header][data]
            // set MDP Header
            msg.Push(m_mdpWorker);                     // [header][data]
            // set MDP empty frame as separator
            msg.Push(NetMQFrame.Empty);                // [e][command][header][data]

            Log(string.Format("[WORKER] sending {0} to broker / Command {1}", msg, mdpCommand));

            m_worker.SendMessage(msg);
        }
Example #6
0
        /// <summary>
        ///     sends a message to a specific worker with a specific command
        ///     and add an option option
        /// </summary>
        private void WorkerSend (Worker worker, MDPCommand command, NetMQMessage message, string option = null)
        {
            var msg = message ?? new NetMQMessage ();

            // stack protocol envelope to start of message
            if (!ReferenceEquals (option, null))
                msg.Push (option);

            msg.Push (new[] { (byte) command });
            msg.Push (MDPConstants.MDP_WORKER_HEADER);
            // stack routing envelope
            var request = Wrap (worker.Identity, msg);

            DebugLog ($"Sending {request}");
            // send to worker
            Socket.SendMultipartMessage (request);
        }