/// <summary>
        /// Handles the specified subscription command line options.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        public static void Handle(SubscriptionOptions options)
        {
            if (options.IsVerbose)
            {
                Debug.Listeners.Add(new ColoredConsoleTraceListener());
            }

            OutputWriter = !string.IsNullOrWhiteSpace(options.OutputFileName)
                               ? new StreamWriter(options.OutputFileName)
                               : Console.Out;

            var description = new MessageBusDescription
                                  {
                                      ConnectionString = options.ConnectionString, 
                                      Factory =
                                          DependencyResolver.Resolve<IMessageBusFactory>(
                                              options.Factory), 
                                      StorageConnectionString = options.StorageConnectionString
                                  };
            var bus = new MessageBus(description);
            bus.RegisterHandlerAsync(options.Entity, options.Name, OnMessageArrived).Wait();

            Debug.Print("This is a debug print.");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            Console.WriteLine("Closing message bus...");
            bus.CloseAsync().ContinueWith(t => Console.WriteLine("Message bus is closed.")).Wait();
        }
Пример #2
0
        /// <summary>
        /// Handles the specified subscription command line options.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        public static void Handle(SubscriptionOptions options)
        {
            if (options.IsVerbose)
            {
                Debug.Listeners.Add(new ColoredConsoleTraceListener());
            }

            OutputWriter = !string.IsNullOrWhiteSpace(options.OutputFileName)
                               ? new StreamWriter(options.OutputFileName)
                               : Console.Out;

            var description = new MessageBusDescription
            {
                ConnectionString = options.ConnectionString,
                Factory          =
                    DependencyResolver.Resolve <IMessageBusFactory>(
                        options.Factory),
                StorageConnectionString = options.StorageConnectionString
            };
            var bus = new MessageBus(description);

            bus.RegisterHandlerAsync(options.Entity, options.Name, OnMessageArrived).Wait();

            Debug.Print("This is a debug print.");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            Console.WriteLine("Closing message bus...");
            bus.CloseAsync().ContinueWith(t => Console.WriteLine("Message bus is closed.")).Wait();
        }