Beispiel #1
0
        //protected override Task ExecuteAsync(CancellationToken stoppingToken)
        public void DoWork()
        {
            //stoppingToken.ThrowIfCancellationRequested();

            //Server Spin Up
            var serverSpinUpConsumer = new AsyncEventingBasicConsumer(serverSpinUpChannel);

            serverSpinUpConsumer.Received += (model, ea) =>
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Server Spin Up Message Received");
                var body = ea.Body;
                MQSpinUpServerMessage serverSpinUpMessage = MQSpinUpServerMessage.Deserialize(body.ToArray());
                HandleServerSpinUpMessage(
                    serverSpinUpMessage.CustomerGUID,
                    serverSpinUpMessage.WorldServerID,
                    serverSpinUpMessage.ZoneInstanceID,
                    serverSpinUpMessage.MapName,
                    serverSpinUpMessage.Port);

                return(Task.CompletedTask);
            };

            serverSpinUpConsumer.Shutdown          += OnServerSpinUpConsumerShutdown;
            serverSpinUpConsumer.Registered        += OnServerSpinUpConsumerRegistered;
            serverSpinUpConsumer.Unregistered      += OnServerSpinUpConsumerUnregistered;
            serverSpinUpConsumer.ConsumerCancelled += OnServerSpinUpConsumerConsumerCancelled;

            serverSpinUpChannel.BasicConsume(queue: serverSpinUpQueueNameGUID.ToString(),
                                             autoAck: true,
                                             consumer: serverSpinUpConsumer);

            //Server Shut Down
            var serverShutDownConsumer = new AsyncEventingBasicConsumer(serverShutDownChannel);

            serverShutDownConsumer.Received += (model, ea) =>
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Message Received");
                var body = ea.Body;
                MQShutDownServerMessage serverShutDownMessage = MQShutDownServerMessage.Deserialize(body.ToArray());
                HandleServerShutDownMessage(
                    serverShutDownMessage.CustomerGUID,
                    serverShutDownMessage.ZoneInstanceID
                    );

                return(Task.CompletedTask);
            };

            serverShutDownConsumer.Shutdown          += OnServerShutDownConsumerShutdown;
            serverShutDownConsumer.Registered        += OnServerShutDownConsumerRegistered;
            serverShutDownConsumer.Unregistered      += OnServerShutDownConsumerUnregistered;
            serverShutDownConsumer.ConsumerCancelled += OnServerShutDownConsumerConsumerCancelled;

            serverShutDownChannel.BasicConsume(queue: serverShutDownQueueNameGUID.ToString(),
                                               autoAck: true,
                                               consumer: serverShutDownConsumer);

            //return Task.CompletedTask;
        }
Beispiel #2
0
        //protected override Task ExecuteAsync(CancellationToken stoppingToken)
        public void DoWork()
        {
            //This will be null if there was a problem with initialization in the constructor
            if (_OWSInstanceLauncherOptions == null)
            {
                return;
            }

            //Server Spin Up
            var serverSpinUpConsumer = new AsyncEventingBasicConsumer(serverSpinUpChannel);

            serverSpinUpConsumer.Received += (model, ea) =>
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Server Spin Up Message Received");
                var body = ea.Body;
                MQSpinUpServerMessage serverSpinUpMessage = MQSpinUpServerMessage.Deserialize(body.ToArray());
                HandleServerSpinUpMessage(
                    serverSpinUpMessage.CustomerGUID,
                    serverSpinUpMessage.WorldServerID,
                    serverSpinUpMessage.ZoneInstanceID,
                    serverSpinUpMessage.MapName,
                    serverSpinUpMessage.Port);

                return(Task.CompletedTask);
            };

            serverSpinUpConsumer.Shutdown          += OnServerSpinUpConsumerShutdown;
            serverSpinUpConsumer.Registered        += OnServerSpinUpConsumerRegistered;
            serverSpinUpConsumer.Unregistered      += OnServerSpinUpConsumerUnregistered;
            serverSpinUpConsumer.ConsumerCancelled += OnServerSpinUpConsumerConsumerCancelled;

            serverSpinUpChannel.BasicConsume(queue: serverSpinUpQueueNameGUID.ToString(),
                                             autoAck: true,
                                             consumer: serverSpinUpConsumer);

            //Server Shut Down
            var serverShutDownConsumer = new AsyncEventingBasicConsumer(serverShutDownChannel);

            serverShutDownConsumer.Received += (model, ea) =>
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Message Received");
                var body = ea.Body;
                MQShutDownServerMessage serverShutDownMessage = MQShutDownServerMessage.Deserialize(body.ToArray());
                HandleServerShutDownMessage(
                    serverShutDownMessage.CustomerGUID,
                    serverShutDownMessage.ZoneInstanceID
                    );

                return(Task.CompletedTask);
            };

            serverShutDownConsumer.Shutdown          += OnServerShutDownConsumerShutdown;
            serverShutDownConsumer.Registered        += OnServerShutDownConsumerRegistered;
            serverShutDownConsumer.Unregistered      += OnServerShutDownConsumerUnregistered;
            serverShutDownConsumer.ConsumerCancelled += OnServerShutDownConsumerConsumerCancelled;

            serverShutDownChannel.BasicConsume(queue: serverShutDownQueueNameGUID.ToString(),
                                               autoAck: true,
                                               consumer: serverShutDownConsumer);

            //return Task.CompletedTask;
        }