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

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            });

            var coreBus    = RabbitMqBusFactory.CreateCoreBusWithReceiveEndpoint();
            var coreRpcBus = RabbitMqBusFactory.CreateCoreRpcEndpoint();

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

                await RabbitQueuePublisher.SendToFrameworkQueue(new StringIntRequestModel
                {
                    IntValue = 13, StringValue = "FrameworkCall"
                });

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

                Console.WriteLine($"int: {response.IntValue}, string: {response.StringValue}, time: {response.DateTime}");
            });
        }