Beispiel #1
0
        public void Run()
        {
            Text.PrintLine("Will start receiving messages from '{0}'", InputQueue);

            if (DefaultOutputQueue != null)
            {
                Text.PrintLine("(will provide '{0}' as the default queue to forward messages to)", DefaultOutputQueue);
            }

            Text.PrintLine();

            while (true)
            {
                using (var transactionContext = new DefaultTransactionContextScope())
                {
                    var transportMessage = _transport.Receive(AmbientTransactionContext.Current, new CancellationTokenSource().Token).Result;

                    if (transportMessage == null)
                    {
                        break;
                    }

                    try
                    {
                        HandleMessage(transportMessage, AmbientTransactionContext.Current);

                        transactionContext.Complete().Wait();
                    }
                    catch (Exception exception)
                    {
                        Text.PrintLine("Failed: {0}", exception.Message);
                    }
                }

                Text.PrintLine("No more messages");
            }
        }