예제 #1
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            try
            {
                _manager.Start();
                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    if (msg.Data == "ping?")
                    {
                        Thread.Sleep(5000);
                        _manager.Send(FromStitchMessage.Respond(msg, "pong!"));
                    }
                    else
                    {
                        _manager.SendLogs(new[] { "Unknown data " + msg.Data });
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            try
            {
                _manager.Start();
                string groupName = _manager.CrossStitchParameters.ApplicationGroupName;

                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    // When we receive a message "B", log it
                    if (msg.Data == "A")
                    {
                        _manager.Send(FromStitchMessage.Respond(msg, "B"));
                    }

                    // Else, log that we've gotten something unexpected
                    else
                    {
                        _manager.SendLogs(new[] { "Unknown data " + msg.Data });
                    }
                }
            }
            catch (Exception e)
            {
                _manager.SendLogs(new[] { e.ToString() });
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            _manager.ReceiveHeartbeats = true;
            try
            {
                _manager.Start();
                string groupName = _manager.CrossStitchParameters.ApplicationGroupName;

                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    // When we receive a heartbeat, broadcast a message to all stitches in the application group
                    if (msg.IsHeartbeatMessage())
                    {
                        _manager.SyncHeartbeat(msg.Id);
                        _manager.Send(FromStitchMessage.ToGroupData(groupName, "A"));
                    }

                    // When we receive a message "B", log it
                    else if (msg.Data == "B")
                    {
                        _manager.SendLogs(new[] { "Received B" });
                    }

                    // Else, log that we've gotten something unexpected
                    else
                    {
                        _manager.SendLogs(new[] { "Unknown data " + msg.Data });
                    }
                }
            }
            catch (Exception e)
            {
                _manager.SendLogs(new[] { e.ToString() });
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            try
            {
                _manager = new StitchMessageManager(args);
                _manager.ReceiveHeartbeats  = true;
                _manager.ReceiveExitMessage = true;
                _manager.Start();

                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    if (msg.IsExitMessage())
                    {
                        //Log("Got EXIT message from manager");
                        Environment.Exit(0);
                    }
                    if (msg.IsHeartbeatMessage())
                    {
                        Log($"Got HEARTBEAT message from manager");
                        _manager.SyncHeartbeat(msg.Id);
                        _manager.SendLogs(_manager.CrossStitchParameters.ToString());
                    }
                    else
                    {
                        // TODO: Real processing.
                        Log($"Message received {msg.ChannelName}, {msg.Id}");
                        _manager.AckMessage(msg.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
            Log("Stopped");
        }
예제 #5
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            _manager.ReceiveHeartbeats  = true;
            _manager.ReceiveExitMessage = true;
            try
            {
                _manager.Start();
                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    if (msg.IsExitMessage())
                    {
                        return;
                    }
                    else if (msg.IsHeartbeatMessage())
                    {
                        _manager.SyncHeartbeat(msg.Id);
                        _manager.SendLogs(_manager.CrossStitchArguments.Select(kvp => kvp.Key + "=" + kvp.Value).ToArray());
                    }
                    else
                    {
                        // TODO: Real processing.
                        Log($"Message received {msg.ChannelName}, {msg.Id}");
                        _manager.AckMessage(msg.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
            Log("Stopped");
        }
예제 #6
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            try
            {
                _manager.Start();
                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    Log($"Message received {msg.ChannelName}, {msg.Id}");
                    _manager.AckMessage(msg.Id);
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
            Log("Stopped");
        }
예제 #7
0
        static void Main(string[] args)
        {
            _manager = new StitchMessageManager(args);
            try
            {
                _manager.Start();
                Thread.Sleep(5000);

                // Start the chain by sending a ping to the entire group
                string groupName = _manager.CrossStitchArguments[Arguments.Application];
                _manager.Send(FromStitchMessage.ToGroupData(groupName, "ping?"));

                while (true)
                {
                    var msg = _manager.GetNextMessage();
                    if (msg == null)
                    {
                        continue;
                    }

                    if (msg.Data == "pong!")
                    {
                        Thread.Sleep(5000);
                        _manager.Send(FromStitchMessage.Respond(msg, "ping?"));
                    }
                    else
                    {
                        _manager.SendLogs(new[] { "Unknown data " + msg.Data });
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
        }