protected override void OnApplyConfiguration(System.ServiceModel.Channels.Binding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            RabbitMQBinding rabbind = binding as RabbitMQBinding;

            if (rabbind == null)
            {
                throw new ArgumentException(
                          string.Format("Invalid type for binding. Expected {0}, Passed: {1}",
                                        typeof(RabbitMQBinding).AssemblyQualifiedName,
                                        binding.GetType().AssemblyQualifiedName));
            }

            rabbind.AutoBindExchange   = AutoBindExchange;
            rabbind.BrokerProtocol     = Protocol;
            rabbind.ExactlyOnce        = ExactlyOnce;
            rabbind.OneWayOnly         = OneWayOnly;
            rabbind.PersistentDelivery = PersistentDelivery;
            rabbind.ReplyToExchange    = ReplyToExchange == null ? null : new Uri(ReplyToExchange);
            rabbind.ReplyToQueue       = ReplyToQueue;
            rabbind.TTL             = TTL;
            rabbind.AutoDelete      = AutoDelete;
            rabbind.ApplicationId   = ApplicationId;
            rabbind.MessageFormat   = MessageFormat;
            rabbind.HeaderNamespace = HeaderNamespace;
            rabbind.Immediate       = Immediate;
            rabbind.Mandatory       = Mandatory;

            ApplyQuotas(rabbind.ReaderQuotas);
        }
예제 #2
0
        public void TestInitialize()
        {
            _ev = new ManualResetEvent(false);

            const string clientAddress = "amqp://localhost/amq.direct?routingKey=NoSuchRoute";

            _binding = new RabbitMQBinding
                {
                    OneWayOnly = true,
                    ApplicationId = "MyApp",
                    Mandatory = true
                };

            _channelFactory = _binding.BuildChannelFactory<IOutputChannel>(this);

            _channelFactory.Open();

            _outputChannel = _channelFactory.CreateChannel(new EndpointAddress(clientAddress)) as RabbitMQTransportOutputChannel;

            _outputChannel.Open();
        }
        protected override void InitializeFrom(System.ServiceModel.Channels.Binding binding)
        {
            base.InitializeFrom(binding);
            RabbitMQBinding rabbind = binding as RabbitMQBinding;

            if (rabbind != null)
            {
                ExactlyOnce        = rabbind.ExactlyOnce;
                TTL                = rabbind.TTL;
                ReplyToExchange    = rabbind.ReplyToQueue;
                AutoBindExchange   = rabbind.AutoBindExchange;
                PersistentDelivery = rabbind.PersistentDelivery;
                OneWayOnly         = rabbind.OneWayOnly;
                ReplyToQueue       = rabbind.ReplyToQueue;
                ApplicationId      = rabbind.ApplicationId;
                HeaderNamespace    = rabbind.HeaderNamespace;
                MessageFormat      = rabbind.MessageFormat;
                Immediate          = rabbind.Immediate;
                Mandatory          = rabbind.Mandatory;
                ReadQuotas(rabbind.ReaderQuotas);
            }
        }
        public void TestInitialize()
        {
            _host = new ServiceHost(new OneWayService(_processorFake, _errorProcessorFake));

            const string serviceAddress = "amqp://localhost/myQueue?routingKey=OneWayService";
            const string serviceAddress2 = "amqp://localhost/myQueue?routingKey=OneWayService2";

            var binding = new RabbitMQBinding
            {
                AutoBindExchange = "amq.direct",
                // If not null, queue will be automatically binded to the exchange using provided routingKey (if any)
                ExactlyOnce = false, // Non-transactional consumption,
                OneWayOnly = true, // Use False only if calback communication required
                //TTL = 1000, // Message time to leave in miliseconds
                //PersistentDelivery = true // If true, every message will be written to disk on rabbitMQ broker side before dispatching to the destination(s)
            };

            _host.AddServiceEndpoint(typeof(IOneWayService), binding, serviceAddress);

            _host.AddServiceEndpoint(typeof(IOneWayService2), binding, serviceAddress2);

            _host.Open();

            const string clientAddress = "amqp://localhost/amq.direct?routingKey=OneWayService";

            _channelFactory = new ChannelFactory<IOneWayService>(new RabbitMQBinding
            {
                OneWayOnly = true
            }, clientAddress);

            _channelFactory.Open();
        }