Exemplo n.º 1
0
        public RabbitAdvancedBus(
            ConnectionFactoryWrapper connectionFactory,
            ConsumerFactory consumerFactory,
            IPublisher publisher,
            ConnectionConfiguration connectionConfiguration)
        {
            Preconditions.CheckNotNull(connectionFactory, "connectionFactory");
            Preconditions.CheckNotNull(consumerFactory, "consumerFactory");
            Preconditions.CheckNotNull(publisher, "publisher");
            Preconditions.CheckNotNull(connectionConfiguration, "connectionConfiguration");

            this._consumerFactory         = consumerFactory;
            this._publisher               = publisher;
            this._connectionConfiguration = connectionConfiguration;

            this._connection = new PersistentConnection(connectionFactory);

            EventBus.Instance.Subscribe <ConnectionCreatedEvent>(e => this.OnConnected());
            EventBus.Instance.Subscribe <ConnectionDisconnectedEvent>(e => this.OnDisconnected());
            EventBus.Instance.Subscribe <ReturnedMessageEvent>(this.OnMessageReturned);
            EventBus.Instance.Subscribe <ConfirmedMessageEvent>(this.OnMessageConfirmed);
            EventBus.Instance.Subscribe <ConfirmedMessageTimeOutEvent>(this.OnMessageConfirmedTimeout);

            PersistentChannelFactory persistentChannelFactory = new PersistentChannelFactory(connectionConfiguration);

            this._clientCommandDispatcher = new ClientCommandDispatcherSingleton(this._connection, persistentChannelFactory);
        }
        public ClientCommandDispatcherSingleton(
            PersistentConnection connection,
            PersistentChannelFactory persistentChannelFactory)
        {
            Preconditions.CheckNotNull(connection, "connection");
            Preconditions.CheckNotNull(persistentChannelFactory, "persistentChannelFactory");

            this._persistentChannel = persistentChannelFactory.CreatePersistentChannel(connection);

            this.StartDispatcherThread();
        }