Example #1
0
        public async Task Handle(CreateInvoiceProposals message, IMessageHandlerContext context)
        {
            Console.WriteLine($"BillingRun {message.BillingRunId} created.");
            Data.Invoices     = new List <Invoice>();
            Data.BillingRunId = message.BillingRunId;
            message.Customers.ForEach(c =>
            {
                Data.Invoices.Add(new Invoice()
                {
                    CustomerId = c, Status = InvoiceStatus.Waiting
                });
            });

            await TrySendNextBatch(context);
        }
Example #2
0
        static async Task MainAsync()
        {
            var numberOfInvoices = 150;

            Console.Title = "Client";
            Console.WriteLine($"Press a key to start a batch of {numberOfInvoices} customers.");
            Console.ReadKey();

            var endpointConfiguration = new EndpointConfiguration("Client");

            endpointConfiguration.ApplyCommonConfiguration();
            endpointConfiguration.SendOnly();

            // Routing
            var transport = endpointConfiguration.UseTransport <LearningTransport>();

            transport.Routing().RouteToEndpoint(typeof(CreateInvoiceProposals).Assembly, "InvoiceProcessing");

            // Start endpoint
            var sendOnlyEndpoint = await Endpoint.Start(endpointConfiguration);

            var customerIds = new List <Guid>();

            for (int i = 0; i < numberOfInvoices; i++)
            {
                customerIds.Add(Guid.NewGuid());
            }

            var msg = new CreateInvoiceProposals();

            msg.BillingRunId = Guid.NewGuid();
            msg.Customers    = customerIds;

            await sendOnlyEndpoint.Send(msg);

            await sendOnlyEndpoint.Stop();

            Console.WriteLine("Send out batch, press any key to quit...");
            Console.ReadKey();
        }