Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });

            var frameworkBus = RabbitMqBusFactory.CreateFrameworkBusWithReceiveEndpoint();

            Task.Factory.StartNew(async() =>
            {
                await frameworkBus.StartAsync();

                await RabbitQueuePublisher.SendToCoreQueue(new StringIntRequestModel
                {
                    IntValue    = 17,
                    StringValue = "CoreCall"
                });

                var response = await RabbitRpcPublisher.SendToCoreRpcQueue(new StringIntRequestModel
                {
                    IntValue = 13, StringValue = "FromFrameworkRpcCall"
                });

                Console.WriteLine($"int: {response.IntValue}, string: {response.StringValue}, time: {response.DateTime}");
            });
        }
Example #2
0
        public IBusControl CreateBus(IBusServiceConfigurator busServiceConfigurator, string serviceName)
        {
            return(RabbitMqBusFactory.Create(configurator =>
            {
                configurator.Host(_hostSettings);

                LogContext.Info?.Log("Configuring Host: {Host}", _hostSettings.ToDescription());

                var serviceConfigurator = new RabbitMqServiceConfigurator(configurator);

                busServiceConfigurator.Configure(serviceConfigurator);
            }));
        }
        /// <summary>
        /// Add a RabbitMQ bus
        /// </summary>
        /// <param name="configurator">The registration configurator</param>
        /// <param name="configure">The configure callback method</param>
        /// <typeparam name="TContainerContext"></typeparam>
        public static void AddRabbitMqBus <TContainerContext>(this IRegistrationConfigurator <TContainerContext> configurator,
                                                              Action <TContainerContext, IRabbitMqBusFactoryConfigurator> configure)
        {
            IBusControl BusFactory(TContainerContext context)
            {
                return(RabbitMqBusFactory.Create(cfg =>
                {
                    configure(context, cfg);
                }));
            }

            configurator.AddBus(BusFactory);
        }
Example #4
0
        public IBusControl CreateBus(IBusServiceConfigurator busServiceConfigurator, string serviceName)
        {
            return(RabbitMqBusFactory.Create(configurator =>
            {
                var host = configurator.Host(_hostSettings);

                if (_log.IsInfoEnabled)
                {
                    _log.Info($"Configuring Host: {_hostSettings.ToDebugString()}");
                }

                var serviceConfigurator = new RabbitMqServiceConfigurator(configurator, host);

                busServiceConfigurator.Configure(serviceConfigurator);
            }));
        }
Example #5
0
        static void Main(string[] args)
        {
            var bus = RabbitMqBusFactory.Create(configurator =>
            {
                var host = configurator.Host(new Uri("rabbitmq://rabbitmq"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                configurator.ReceiveEndpoint(host, "example.com.mytopic", endpointConfigurator =>
                {
                    endpointConfigurator.Consumer(() => new ErrorConsumer());
                });
            });

            bus.Start();

            bus.Publish <IMessage>(new
            {
                Text = "this is a message"
            });
        }
Example #6
0
 /// <summary>
 /// Select RabbitMQ as the transport for the service bus
 /// </summary>
 public static IBusControl CreateUsingRabbitMq(this IBusFactorySelector selector, Action <IRabbitMqBusFactoryConfigurator> configure)
 {
     return(RabbitMqBusFactory.Create(configure));
 }