public void ShouldCallExchangeDeclarePubSubTypeIsSubscribeAndExchangeBindingShouldDeclare()
        {
            const string queueName = "abc";
            _endpoint = new QueueEndpoint()
            {
                Name = "testendpoint",
                PubSubType = PubSubType.Subscribe,
                Subscription = new SubscriptionConfiguration()
                {
                    ExchangeBindings = new ExchangeBindingCollection()
                }
            };
            _endpoint.Subscription.ExchangeBindings.Add(
                new ExchangeBinding()
                {
                    Name = "e1",
                    RoutingKey = "rk",
                    Type = ExchangeType.Direct,
                    DeclareExchange = true
                });
            _channel.Stub(x => x.QueueDeclare()).Return(new QueueDeclareOk(queueName, 1, 1));
            var configurator = new ChannelConfigurator();
            configurator.ConfigureQueue(_endpoint, _channel);

            var binding = _endpoint.Subscription.ExchangeBindings[0];
            _channel.AssertWasCalled(x => x.ExchangeDeclare(
                binding.Name,
                "direct"));
        }
        public void ShouldCallQueueDeclareAndQueueBindWhenPubSubTypeIsSubscribe()
        {
            const string queueName = "abc";
            _endpoint = new QueueEndpoint()
            {
                Name = "testendpoint",
                PubSubType = PubSubType.Subscribe,
                Subscription = new SubscriptionConfiguration()
                {
                    ExchangeBindings = new ExchangeBindingCollection()
                }
            };
            _endpoint.Subscription.ExchangeBindings.Add(
                new ExchangeBinding()
                    {
                        Name = "e1",
                        RoutingKey = "rk"
                    });
            _channel.Stub(x => x.QueueDeclare()).Return(new QueueDeclareOk(queueName, 1, 1));
            var configurator = new ChannelConfigurator();
            configurator.ConfigureQueue(_endpoint, _channel);

            _channel.AssertWasCalled(x => x.QueueDeclare());
            _channel.AssertWasCalled(x => x.QueueBind(
                queueName,
                _endpoint.Subscription.ExchangeBindings[0].Name,
                _endpoint.Subscription.ExchangeBindings[0].RoutingKey));
        }
Beispiel #3
0
        public StateMachineInstanceConnectionConfigurator <T> UsingInstance(T instance)
        {
            var instanceConfigurator = new StateMachineInstanceConnectionConfiguratorImpl <T>(instance);

            _configurator = instanceConfigurator;

            return(instanceConfigurator);
        }
 public void Setup()
 {
     MessageData = Encoding.UTF8.GetBytes("hej");
     ChannelConfigurator = new ChannelConfigurator();
     Exchange = null;
     MessageProperties = new MessageProperties() { MessageId = MessageId };
     _message = new ReceivedMessage(MessageData, GetExchangeName(), MessageProperties);
 }
Beispiel #5
0
        /// <summary>
        /// Consumes the message on a SelectiveConsumerChannel given the specified delegate
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="selectiveConsumer"></param>
        /// <returns></returns>
        public static ConsumerConfigurator <TChannel> UsingSelectiveConsumer <TChannel>(
            this ChannelConfigurator <TChannel> configurator, SelectiveConsumer <TChannel> selectiveConsumer)
        {
            var consumerConfigurator = new SelectiveConsumerConfigurator <TChannel>(selectiveConsumer);

            configurator.AddConfigurator(consumerConfigurator);

            return(consumerConfigurator);
        }
Beispiel #6
0
        /// <summary>
        /// Specifies an interval at which the consumer should be called with a collection
        /// of messages received during that period.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="interval">The time period of each interval</param>
        /// <returns></returns>
        public static IntervalConfigurator <TChannel> BufferFor <TChannel>(
            this ChannelConfigurator <TChannel> configurator, TimeSpan interval)
        {
            var intervalConfigurator = new IntervalConfiguratorImpl <TChannel>(interval);

            configurator.AddConfigurator(intervalConfigurator);

            return(intervalConfigurator);
        }
Beispiel #7
0
        public static ChannelConfigurator <TChannel> Where <TChannel>(this ChannelConfigurator <TChannel> configurator,
                                                                      Filter <TChannel> filter)
        {
            var filterConfigurator = new FilterConfiguratorImpl <TChannel>(filter);

            configurator.AddConfigurator(filterConfigurator);

            return(filterConfigurator);
        }
        public static SynchronizedChannelConfigurator <TChannel> OnSynchronizationContext <TChannel>(
            this ChannelConfigurator <TChannel> configurator, SynchronizationContext synchronizationContext)
        {
            var synchronizedConfigurator = new SynchronizedChannelConfiguratorImpl <TChannel>(synchronizationContext);

            configurator.AddConfigurator(synchronizedConfigurator);

            return(synchronizedConfigurator);
        }
Beispiel #9
0
        public StateMachineConnectionConfigurator <T, TKey, TBinding> BindUsing <TBinding, TKey>()
            where TBinding : StateMachineBinding <T, TKey>
        {
            var configurator = new StateMachineConnectionConfiguratorImpl <T, TKey, TBinding>();

            _configurator = configurator;

            return(configurator);
        }
Beispiel #10
0
        /// <summary>
        /// Consumes the message on a ConsumerChannel, given the specified delegate
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="consumer"></param>
        /// <returns></returns>
        public static ConsumerConfigurator <TChannel> UsingConsumer <TChannel>(
            this ChannelConfigurator <TChannel> configurator, Consumer <TChannel> consumer)
        {
            var consumerConfigurator = new ConsumerConfiguratorImpl <TChannel>(consumer);

            configurator.AddConfigurator(consumerConfigurator);

            return(consumerConfigurator);
        }
        public static InstanceConfigurator <TChannel> UsingInstance <TChannel>(
            this ChannelConfigurator <TChannel> configurator)
        {
            var instanceConfigurator = new InstanceConfiguratorImpl <TChannel>();

            configurator.AddConfigurator(instanceConfigurator);

            return(instanceConfigurator);
        }
Beispiel #12
0
        public static IBus AddRabbitExchange(this IBus bus, Action <ChannelConfigurator> configurate)
        {
            var channels          = Assimilate.GetInstanceOf <IChannelIndex>();
            var connectionManager = Assimilate.GetInstanceOf <IConnectionManager>();
            var configurator      = new ChannelConfigurator();

            configurate(configurator);
            var channelDefinition = configurator.ChannelDefinition;

            channelDefinition.CreateOnBroker(connectionManager);
            channels.AddDefinition(channelDefinition);
            return(bus);
        }
Beispiel #13
0
        public static IBus AddRabbitExchange( this IBus bus, Action<ChannelConfigurator> configurate )
        {
            var channels = Assimilate.GetInstanceOf<IChannelIndex>();
            var connectionManager = Assimilate.GetInstanceOf<IConnectionManager>();
            var configurator = new ChannelConfigurator();

            configurate( configurator );
            var channelDefinition = configurator.ChannelDefinition;

            channelDefinition.CreateOnBroker( connectionManager );
            channels.AddDefinition( channelDefinition );
            return bus;
        }
Beispiel #14
0
 public void Setup()
 {
     MessageData = Encoding.UTF8.GetBytes("hej");
     ChannelConfigurator = new ChannelConfigurator();
     Exchange = null;
     MessageProperties = new MessageProperties() { MessageId = MessageId };
 }
Beispiel #15
0
 public void SetChannelConfigurator(ChannelConfigurator <IDictionary <TKey, TChannel> > configurator)
 {
     _configurator = configurator;
 }
Beispiel #16
0
 public void RegisterChannelConfigurator(ChannelConfigurator configurator)
 {
     _configurators.Add(configurator);
 }
Beispiel #17
0
 protected void InternalSetup()
 {
     MessageData = Encoding.UTF8.GetBytes("hej");
     ChannelConfigurator = MockRepository.GenerateStub<ChannelConfigurator>();
 }
Beispiel #18
0
 public void SetChannelConfigurator(ChannelConfigurator <TChannel> configurator)
 {
     _configurator = configurator;
 }
 public void ShouldThrowExceptionIfPubSubTypeIsSubscribeAndNoSubscriptionConfigExists()
 {
     const string queueName = "abc";
     var expectedResult = new QueueDeclareOk(queueName, 1, 1);
     _endpoint = new QueueEndpoint()
     {
         Name = "testendpoint",
         Exchange = new ExchangeConfiguration() { Name = "ex1" },
         PubSubType = PubSubType.Subscribe,
         RoutingKey = queueName,
         Subscription = null
     };
     var configurator = new ChannelConfigurator();
     configurator.ConfigureQueue(_endpoint, _channel);
 }
        public void ShouldNotCallQueueDeclareAndQueueBindWhenPubSubTypeIsPublish()
        {
            const string queueName = "abc";
            _endpoint = new QueueEndpoint()
            {
                Name = "testendpoint",
                Exchange = new ExchangeConfiguration() { Name = "ex1" },
                Subscription = new SubscriptionConfiguration() { QueueName = "asdf" },
                PubSubType = PubSubType.Publish
            };
            _channel.Stub(x => x.QueueDeclare()).Return(new QueueDeclareOk(queueName, 1, 1));
            var configurator = new ChannelConfigurator();
            configurator.ConfigureQueue(_endpoint, _channel);

            _channel.AssertWasNotCalled(x => x.QueueDeclare());
            _channel.AssertWasNotCalled(x => x.QueueBind(_endpoint.Subscription.QueueName, _endpoint.Exchange.Name, ""));
        }
 public void ShouldNotCallExchangeDeclareIfExchangesNameIsEmpty()
 {
     _endpoint = new QueueEndpoint()
     {
         Name = "testendpoint",
         Exchange = new ExchangeConfiguration() { Name = string.Empty, Type = ExchangeType.Fanout},
         PubSubType = PubSubType.Publish,
         RoutingKey = "asdf",
         Subscription = null
     };
     var configurator = new ChannelConfigurator();
     configurator.ConfigureQueue(_endpoint, _channel);
     _channel.AssertWasNotCalled(x => x.ExchangeDeclare(_endpoint.Exchange.Name, _endpoint.Exchange.Type.ToString().ToLower()));
 }
        public void ShouldCallQueueDeclareWithParametersWhenPubSubTypeIsSubscribeAndRoutingKeyIsSet()
        {
            const string queueName = "abc";
            var expectedResult = new QueueDeclareOk(queueName, 1, 1);
            _endpoint = new QueueEndpoint()
            {
                Name = "testendpoint",
                Exchange = new ExchangeConfiguration() { Name = "ex1" },
                PubSubType = PubSubType.Subscribe,
                RoutingKey = queueName,
                Subscription = new SubscriptionConfiguration() { QueueName = "abckduf", NoAck = false }
            };
            _endpoint.Subscription.ExchangeBindings.Add(new ExchangeBinding() { Name = "e1" });
            _channel
                .Stub(x => x.QueueDeclare())
                .Return(new QueueDeclareOk(queueName, 1, 1));
            _channel
                .Stub(x => x.QueueDeclare(_endpoint.Subscription.QueueName, _endpoint.Subscription.NoAck, false, false, null))
                .Return(expectedResult);
            var configurator = new ChannelConfigurator();
            configurator.ConfigureQueue(_endpoint, _channel);

            _channel.AssertWasCalled(x => x.QueueDeclare(_endpoint.Subscription.QueueName, _endpoint.Subscription.Durable, false, false, null));
            _channel.AssertWasCalled(x => x.QueueBind(expectedResult, _endpoint.Subscription.ExchangeBindings[0].Name, ""));
        }
Beispiel #23
0
 public void SetChannelConfigurator(ChannelConfigurator <ICollection <TChannel> > configurator)
 {
     _configurator = configurator;
 }