GetQueue() public method

public GetQueue ( string queue ) : IQueue
queue string
return IQueue
コード例 #1
0
ファイル: Client.cs プロジェクト: mokhan/ping.pong
        static void run()
        {
            var builder = new ContainerBuilder();
            var registry = new AutofacDependencyRegistryBuilder(builder).build();
            Resolve.initialize_with(registry);
            builder.Register(x => registry).As<DependencyRegistry>().SingletonScoped();

            //needs startups
            builder.Register<StartServiceBus>().As<NeedStartup>();

            // infrastructure

            var manager = new QueueManager(new IPEndPoint(IPAddress.Loopback, 2201), "client.esent");
            manager.CreateQueues("client");
            builder.Register(x => new RhinoPublisher("server", 2200, manager)).As<ServiceBus>().SingletonScoped();
            builder.Register(x => new RhinoReceiver(manager.GetQueue("client"), x.Resolve<CommandProcessor>())).As<RhinoReceiver>().As<Receiver>().SingletonScoped();


            // commanding
            //builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
            builder.Register<SynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();

            builder.Register<RequestHandler>().As<Handler>();

            Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
            Resolve.the<CommandProcessor>().run();
            "started".log();
        }
コード例 #2
0
        public void Start()
        {
            shouldContinue = true;

            var port = endpoint.Port;
            if (port == -1)
                port = 2200;
            queueManager = new QueueManager(new IPEndPoint(IPAddress.Any, port), path);
            queueManager.CreateQueues(queueName);

            queue = queueManager.GetQueue(queueName);

            timeout = new TimeoutAction(queue);
            logger.DebugFormat("Starting {0} threads to handle messages on {1}, number of retries: {2}",
                threadCount, endpoint, numberOfRetries);
            for (var i = 0; i < threadCount; i++)
            {
                threads[i] = new Thread(ReceiveMessage)
                {
                    Name = "Rhino Service Bus Worker Thread #" + i,
                    IsBackground = true
                };
                threads[i].Start();
            }
            haveStarted = true;
            var started = Started;
            if (started != null)
                started();
        }