コード例 #1
0
ファイル: Retailer.cs プロジェクト: EsbenLaursen/B2BRetailer
        private static void HandleWarehouseReply(OrderReplyMessage replyMessage)
        {
            if (replyMessage.ItemsInStock > 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(string.Format("Answer from warehouse: \n" +
                                                "Warehouse id: {0} " +
                                                "Items in stock: {1} " +
                                                "Days for delivery: {2} " +
                                                "Shipping charge: {3}", replyMessage.WarehouseId, replyMessage.ItemsInStock,
                                                replyMessage.DaysForDelivery, replyMessage.ShippingCharge));
                if (outstandingOrders.Contains(replyMessage.CustomerId))
                {
                    bus.Publish <OrderReplyMessage>(replyMessage, replyMessage.CustomerId + "");
                    outstandingOrders.Remove(replyMessage.CustomerId);
                }
            }
            else if (replyMessage.DaysForDelivery == 2)
            {
                if (replyMessage.ItemsInStock == 0)
                {
                    Console.WriteLine("No product in stock in local warehouse - Publishing to all warehouses");

                    OrderBroadcastRequestMessage e = new OrderBroadcastRequestMessage();
                    e.CustomerId = replyMessage.CustomerId;
                    e.OrderId    = replyMessage.OrderId;
                    e.ProductId  = replyMessage.ProductId;
                    bus.Publish <OrderBroadcastRequestMessage>(e);
                }
            }
        }
コード例 #2
0
ファイル: Broker.cs プロジェクト: Karath/SystemSynopsisLoan
        private void HandleOrderRequest(CustomerOrderRequestMessage request)
        {
            int SSN = request.SSN;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Request received from customer " + SSN);
            Console.WriteLine("Trying to send the request to a bank.");
            Console.ResetColor();

            OrderBroadcastRequestMessage requestMessage =
                MessageTransformers.EnrichOrderRequestMessage(creditScore, historyLength, loanAmount, loanterm, replyQueueName);

            //outstandingOrderRequests.TryAdd(orderId, requestMessage);
            //customerIdsForOutstandingOrderRequests.TryAdd(orderId, customerId);
            //OrderRequestMessageToLocalWarehouse requestMessage = new OrderRequestMessageToLocalWarehouse
            //{
            //    ProductId = request.ProductId,
            //    CustomerId = request.CustomerId,
            //    Country = request.Country,
            //    OrderId = ++orderId,
            //    ReplyTo = replyQueueName

            //};

            // Uses Topic Based Routing to send the request to a local warehouse. The topic
            // is requestMessage.Country.
            bus.Publish <OrderBroadcastRequestMessage>(requestMessage);
        }
コード例 #3
0
ファイル: Retailer.cs プロジェクト: MrMusn/SystemIntegration
        private void HandleOrderReplyMessage(OrderReplyMessage message)
        {
            Console.WriteLine("Reply received");

            if (message.ItemsInStock > 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Reply received from warehouse" + message.WarehouseId);
                Console.WriteLine("Order Id: " + message.OrderId);
                Console.WriteLine("Items in stock: " + message.ItemsInStock);
                Console.WriteLine("Days for delivery: " + message.DaysForDelivery);
                Console.WriteLine("Shipping charge: " + message.ShippingCharge);
                Console.ResetColor();

                // Uses Topic Based Routing to send the reply to a customer.
                // The topic ís the customerId from the reply message.
                bus.Publish <OrderReplyMessage>(message, message.CustomerId.ToString());
            }
            else if (message.DaysForDelivery == 2)
            {
                // Publish the message again to all warehouses, if the reply
                // was from a local warehouse (DaysForDelivery = 2) with no
                // items in stock.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Publishing to all warehouses");
                Console.ResetColor();

                OrderBroadcastRequestMessage broadcastRequestMessage = new OrderBroadcastRequestMessage
                {
                    OrderId    = message.OrderId,
                    ProductId  = message.ProductId,
                    CustomerId = message.CustomerId,
                    ReplyTo    = replyQueueName,
                    Country    = ""
                };

                bus.Publish <EnvelopeRequestMessage>(wrapper.WrapMessage(broadcastRequestMessage));
            }
        }