Exemplo n.º 1
0
        public static void Configure()
        {
            CheckinResults = new List <CheckResultadosModel>();

            BusControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri(_configuration["BusMensage:host"]), h =>
                {
                    h.Username(_configuration["BusMensage:user"]);
                    h.Password(_configuration["BusMensage:password"]);
                });

                #region ...

                cfg.ReceiveEndpoint(host, e => { /*e.Consumer<CheckEnventoSuscriptores>();*/ });

                //cfg.ConfigureSend(x => x.UseSendExecute(context =>
                //{
                //    context.Headers.Set("prueba", "prueba_q");
                //}));

                #endregion
            });

            BusControl.Start();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            try
            {
                var options = new ImagingOptions();

                Container = IocConfig.RegisterDependencies(options);
                LogConfig.RegisterLogs();

                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    Log.Error("Invalid parameters");

                    // Values are available here
                    if (options.Verbose)
                    {
                        Log.Information($"Queue Name: {options.QueueName}");
                        Log.Information($"Usage: {Environment.NewLine}{options.GetUsage()}");
                    }

                    return;
                }

                Log.Information($"Starting Imaging Worker with options {args}");

                Log.Information("Creating bus");
                BusControl = Container.Resolve <IBusControl>();

                Log.Information("Starting bus");
                BusHandle = BusControl.Start();

                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
            }
            catch (Exception ex1)
            {
                Log.Fatal(ex1, "Imaging Worker Error");
                Console.ReadLine();
            }
            finally
            {
                if (BusHandle != null)
                {
                    try
                    {
                        Log.Information("Stopping bus");
                        BusHandle.Stop();
                    }
                    catch (Exception ex2)
                    {
                        Log.Warning(ex2, "Error while stopping bus");
                    }
                }
            }
        }
 public void Start()
 {
     InitializeBusUsingRabbitMq();
     BusControl.Start();
 }