예제 #1
0
        public virtual ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher)
        {
            var rabbitWatcher     = watcher ?? Global.DefaultWatcher;
            var connectionFactory = new RabbitMQ.Client.ConnectionFactory
            {
                HostName    = hostName,
                VirtualHost = virtualHost,
                UserName    = username,
                Password    = password
            };

            var durableConnection = new DurableConnection(new DefaultRetryPolicy(), rabbitWatcher, connectionFactory);
            var errorHandler      = new ConsumerErrorHandler(connectionFactory, Global.DefaultSerializer, rabbitWatcher);
            var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher);
            var consumerManager   = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer);

            var tunnel = new RabbitTunnel(consumerManager,
                                          rabbitWatcher,
                                          new DefaultRouteFinder(),
                                          durableConnection,
                                          Global.DefaultSerializer,
                                          Global.DefaultCorrelationIdGenerator,
                                          Global.DefaultPersistentMode);

            tunnel.AddSerializerObserver(errorHandler);
            tunnel.AddSerializerObserver(msgHandlerFactory);
            tunnel.AddSerializerObserver(consumerManager);
            return(tunnel);
        }
예제 #2
0
        private ITunnel Create(IDurableConnection durableConnection, IRabbitWatcher rabbitWatcher)
        {
            var errorHandler      = new ConsumerErrorHandler(durableConnection, Global.DefaultSerializer, rabbitWatcher);
            var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher);
            var consumerManager   = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer);

            var tunnel = new RabbitTunnel(consumerManager,
                                          rabbitWatcher,
                                          new DefaultRouteFinder(),
                                          durableConnection,
                                          Global.DefaultSerializer,
                                          Global.DefaultCorrelationIdGenerator,
                                          Global.DefaultPersistentMode);

            tunnel.AddSerializerObserver(errorHandler);
            tunnel.AddSerializerObserver(msgHandlerFactory);
            tunnel.AddSerializerObserver(consumerManager);
            return(tunnel);
        }