Example #1
0
        /// <summary>
        /// Main method ran when the program starts.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            ConfigureLogger();
            Log.Information("Starting MicroMonitor Authentication Token Creator");
            _receiver = RabbitMqReceiver.Create(StaticQueues.RequestAuth, ConsumerOnReceived);

            _receiver.Run();
            Log.Information("Setup done, waiting for messages.");
        }
Example #2
0
        /// <summary>
        /// Main method ran when executing the program.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            ConfigureLogger();
            Log.Information("Setting up MicroMonitor Authentication Token Provider");
            _authProducer = RabbitMqProducer.Create(string.Empty, StaticQueues.IsAuthenticatedReply);
            _authReceiver = RabbitMqReceiver.Create(StaticQueues.IsAuthenticated, IsAuthenticatedOnReceived);

            _authReceiver.Run();
            Log.Information("Setup complete, waiting for request.");
        }
Example #3
0
        /// <summary>
        /// Main method ran when executing the program.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            _authenticationFlow = new AuthenticationFlow(useAuthentication);
            CreateLogger(false);

            Log.Debug("Starting new Receiver for queue: {0}", StaticQueues.LoggingQueue);
            var rabbitMqReceiver = RabbitMqReceiver.Create(StaticQueues.LoggingQueue, ConsumerOnReceived);

            Log.Debug("Running RabbitMq Logger");
            rabbitMqReceiver.Run();
        }
Example #4
0
        static void Main()
        {
            Console.WriteLine("Invoicing Integration (Micro) Service Started");
            Console.WriteLine("------------------------------------------------------------");
            Console.WriteLine();
            RabbitMqReceiver client = new RabbitMqReceiver(exchange: "IntegrationR", queue: "Invoicing", routingKeys: new List <string>()
            {
                "Country.AUS", "Country.FRA"
            });

            client.ProcessMessages();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthenticationFlow"/> class.
        /// </summary>
        public AuthenticationFlow(bool useAuthentication)
        {
            if (!useAuthentication)
            {
                return;
            }

            _unprocessed         = new Dictionary <string, string>();
            _authenticatedTokens = new Dictionary <string, Service>();
            _authSender          = RabbitMqProducer.Create(StaticQueues.IsAuthenticated);
            var faker = new Faker();

            _replyReceiver = RabbitMqReceiver.Create(faker.Random.AlphaNumeric(15), ConsumerOnReceived, StaticQueues.IsAuthenticatedReply);

            _replyReceiver.Run();
        }
Example #6
0
        public void Start()
        {
            _assemblyResolver = new AssemblyResolver(_log);
            _assemblyResolver.Attach();

            _receiver = new RabbitMqReceiver <MessageBody>(
                _settingService.GetSettingValueByKey(Constant.SYSTEM_INFRASTRUCTURE_RABBITMQ_CONNECTIONSTRING),
                _consumerQueue, false, (ushort)_maxFetchCount);

            _receiver.SubscribeEvents(message => { _log.Info($"{_consumerQueue}:{message}"); });
            _receiver.Received += (model, ea) =>
            {
                Task.Run(() => Run(ea));
            };

            _receiver.Start();


            //Start heartbeat
            new Task(() =>
            {
                while (true)
                {
                    try
                    {
                        //cache 1 min then sleep 30 secs
                        _cacheManager.Set(HostInfo.MachineKey, new CacheEntity <int> {
                            CreateTimeUtc = DateTime.UtcNow, Value = 1
                        }, 1);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            _log.Error(ex.Message, ex);
                        }
                        catch { }//For Log exception, nothing to catch so that the log exception won't break the task logic.
                    }
                    finally
                    {
                        Thread.Sleep(1000 * 30);
                    }
                }
            }).Start();

            _log.Info("Service started");
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Test Client");
            Console.WriteLine("Waiting for services to start...\nPress enter when ready.");
            Console.ReadLine();

            authProducer = RabbitMqProducer.Create(StaticQueues.RequestAuth);

            authReceiver = RabbitMqReceiver.Create(APPLICATIONID, OnAuthReceived);

            var service = new Service {
                ApplicationId = APPLICATIONID, GroupId = GROUPID
            };

            var json = JsonConvert.SerializeObject(service);

            var encrypt = EncryptProvider.AESEncrypt(json, KEY, IV);

            authProducer.SendMessage(encrypt);
            Console.WriteLine("Waiting for response.");
        }
Example #8
0
 public ReceivedEventArgs(T val, BasicDeliverEventArgs deliverEventArgs, RabbitMqReceiver receiver)
 {
     Receiver         = receiver;
     Value            = val;
     DeliverEventArgs = deliverEventArgs;
 }