Ejemplo n.º 1
0
 internal virtual AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                 IOutboundChannel outboundChannel,
                                                 IFallbackStrategy fallbackStrategy)
 {
     Message.Acknowledge(inboundChannel);
     return this;
 }
Ejemplo n.º 2
0
        void IChannelManagement.DeleteChannel(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            IOutboundChannel chan = null;

            foreach (IOutboundChannel ch in _target.OutboundChannels)
            {
                if (ch.ID == id)
                {
                    chan = ch;
                    break;
                }
            }

            if (chan != null)
            {
                if (chan.SubscribedClients > 0)
                {
                    throw new InvalidOperationException(
                              "Unable to delete channels to which there are still subscribed clients");
                }
                chan.Stop();
                _target.OutboundChannels.Remove(chan);
            }
            else
            {
                throw new LogbusException(string.Format("Channel {0} not found", id));
            }
        }
Ejemplo n.º 3
0
 internal override AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                  IOutboundChannel outboundChannel,
                                                  IFallbackStrategy fallbackStrategy)
 {
     Message.Requeue(inboundChannel);
     return(this);
 }
Ejemplo n.º 4
0
 internal override AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                  IOutboundChannel outboundChannel,
                                                  IFallbackStrategy fallbackStrategy)
 {
     fallbackStrategy.Apply(outboundChannel, Message);
     return(base.Reply(inboundChannel, outboundChannel, fallbackStrategy));
 }
        internal virtual IOutboundChannel CreateIOutboundChannel()
        {
            // TODO: creare l'istanza di una classe concreta appropriata.
            IOutboundChannel target = ((IOutboundChannelFactory) new SimpleOutChannelFactory()).CreateChannel("dummy", "Channel for tests", new TrueFilter());

            return(target);
        }
        public void StartTest()
        {
            IOutboundChannel target = CreateIOutboundChannel(); // TODO: Eseguire l'inizializzazione a un valore appropriato

            target.Start();
            Assert.Inconclusive("Impossibile verificare un metodo che non restituisce valori.");
        }
Ejemplo n.º 7
0
 internal virtual AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                 IOutboundChannel outboundChannel,
                                                 IFallbackStrategy fallbackStrategy)
 {
     Message.Acknowledge(inboundChannel);
     return(this);
 }
Ejemplo n.º 8
0
        ChannelInformation IChannelManagement.GetChannelInformation(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            IOutboundChannel chan = null;

            foreach (IOutboundChannel ch in _target.OutboundChannels)
            {
                if (ch.ID == id)
                {
                    chan = ch;
                    break;
                }
            }

            if (chan == null)
            {
                return(null);              //Really?
            }
            return(new ChannelInformation
            {
                clients = chan.SubscribedClients.ToString(),
                coalescenceWindow = (long)chan.CoalescenceWindowMillis,
                description = chan.Description,
                filter = chan.Filter as FilterBase,
                id = chan.ID,
                title = chan.Name
            });
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of ClientSubscriptionEventArgs
 /// </summary>
 /// <param name="channel">Channel to which the client is subscribing</param>
 /// <param name="transport">Transport chosen by client</param>
 /// <param name="instructions">Instructions provided by client to the transport</param>
 protected ClientSubscriptionEventArgs(IOutboundChannel channel, string transport,
                                       IEnumerable <KeyValuePair <string, string> > instructions)
 {
     Channel                = channel;
     ChosenTransport        = transport;
     TransportConfiguration = instructions;
 }
Ejemplo n.º 10
0
 internal override AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                  IOutboundChannel outboundChannel,
                                                  IFallbackStrategy fallbackStrategy)
 {
     Message.Requeue(inboundChannel);
     return this;
 }
Ejemplo n.º 11
0
 public FakeConsumerBase(IInboundChannel inboundChannel,
                         IOutboundChannel outboundChannel,
                         Queue queue,
                         IConsumedMessageBuilder builder,
                         ConsumingConfiguration configuration)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
 }
Ejemplo n.º 12
0
 /// <remarks/>
 public OutChannelCreationEventArgs(IOutboundChannel channel)
 {
     if (channel == null)
     {
         throw new ArgumentNullException("channel");
     }
     Channel = channel;
 }
        public void UnsubscribeClientTest()
        {
            IOutboundChannel target   = CreateIOutboundChannel(); // TODO: Eseguire l'inizializzazione a un valore appropriato
            string           clientId = string.Empty;             // TODO: Eseguire l'inizializzazione a un valore appropriato

            target.UnsubscribeClient(clientId);
            Assert.Inconclusive("Impossibile verificare un metodo che non restituisce valori.");
        }
        public void SubscribedClientsTest()
        {
            IOutboundChannel target = CreateIOutboundChannel(); // TODO: Eseguire l'inizializzazione a un valore appropriato
            int actual;

            actual = target.SubscribedClients;
            Assert.Inconclusive("Verificare la correttezza del metodo di test.");
        }
        public void TransportFactoryHelperTest()
        {
            IOutboundChannel        target   = CreateIOutboundChannel(); // TODO: Eseguire l'inizializzazione a un valore appropriato
            ITransportFactoryHelper expected = null;                     // TODO: Eseguire l'inizializzazione a un valore appropriato

            target.TransportFactoryHelper = expected;
            Assert.Inconclusive("Impossibile verificare proprietà in sola scrittura.");
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of ClientSubscribedEventArgs
 /// </summary>
 /// <param name="channel">Channel to which the client is subscribing</param>
 /// <param name="transport">Transport chosen by client</param>
 /// <param name="instructions">Instructions provided by client to the transport</param>
 /// <param name="clientId">Client ID assigned by Logbus-ng</param>
 /// <param name="outInstructions">Instructions provided by transport to client</param>
 public ClientSubscribedEventArgs(IOutboundChannel channel, string transport,
                                  IEnumerable <KeyValuePair <string, string> > instructions, string clientId,
                                  IDictionary <string, string> outInstructions)
     : base(channel, transport, instructions)
 {
     ClientId           = clientId;
     ClientInstructions = outInstructions;
 }
Ejemplo n.º 17
0
 public FakeConsumerBase(IInboundChannel inboundChannel,
                         IOutboundChannel outboundChannel,
                         Queue queue,
                         IConsumedMessageBuilder builder,
                         ConsumingConfiguration configuration)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
 }
Ejemplo n.º 18
0
 internal AtMostOnceConsumerWrapper(IInboundChannel inboundChannel,
                                    IOutboundChannel outboundChannel,
                                    Queue queue,
                                    IConsumedMessageBuilder builder,
                                    ConsumingConfiguration configuration)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
 }
Ejemplo n.º 19
0
 internal AtMostOnceConsumerWrapper(IInboundChannel inboundChannel,
                                    IOutboundChannel outboundChannel,
                                    Queue queue,
                                    IConsumedMessageBuilder builder,
                                    ConsumingConfiguration configuration)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
 }
Ejemplo n.º 20
0
 internal override ConsumerBase BuildConsumer(IInboundChannel inboundChannel, IOutboundChannel outboundChannel)
 {
     return new LoggedAtLeastOnceConsumer(inboundChannel,
                                          outboundChannel,
                                          Queue,
                                          Builder,
                                          Configuration,
                                          LogBuilder());
 }
Ejemplo n.º 21
0
 internal override ConsumerBase BuildConsumer(IInboundChannel inboundChannel, IOutboundChannel outboundChannel)
 {
     return(new LoggedAtLeastOnceConsumer(inboundChannel,
                                          outboundChannel,
                                          Queue,
                                          Builder,
                                          Configuration,
                                          LogBuilder()));
 }
Ejemplo n.º 22
0
 internal LoggedAtLeastOnceConsumer(IInboundChannel inboundChannel,
                                    IOutboundChannel outboundChannel,
                                    Queue queue,
                                    IConsumedMessageBuilder builder,
                                    ConsumingConfiguration configuration,
                                    ILog log)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
     _log = log;
 }
Ejemplo n.º 23
0
 internal Connection(RabbitMQ.Client.IConnection connection,
                     IEnumerable <ConsumerBase> consumers,
                     IOutboundChannel outboundChannel,
                     EnvironmentConfiguration configuration)
 {
     _connection      = connection;
     _consumers       = consumers;
     _outboundChannel = outboundChannel;
     Configuration    = configuration;
 }
Ejemplo n.º 24
0
 internal LoggedAtMostOnceConsumer(IInboundChannel inboundChannel,
                                   IOutboundChannel outboundChannel,
                                   Queue queue,
                                   IConsumedMessageBuilder builder,
                                   ConsumingConfiguration configuration,
                                   ILog log)
     : base(inboundChannel, outboundChannel, queue, builder, configuration)
 {
     _log = log;
 }
Ejemplo n.º 25
0
        protected internal ConsumerBase(IInboundChannel inboundChannel,
                                        IOutboundChannel outboundChannel,
                                        Queue queue,
                                        IConsumedMessageBuilder builder,
                                        ConsumingConfiguration configuration)
        {
            InboundChannel = inboundChannel;
            OutboundChannel = outboundChannel;
            _queue = queue;
            _builder = builder;
            Configuration = configuration;

            ConsumerCancelled += OnConsumerCancelled;
        }
Ejemplo n.º 26
0
        protected internal ConsumerBase(IInboundChannel inboundChannel,
                                        IOutboundChannel outboundChannel,
                                        Queue queue,
                                        IConsumedMessageBuilder builder,
                                        ConsumingConfiguration configuration)
        {
            InboundChannel  = inboundChannel;
            OutboundChannel = outboundChannel;
            _queue          = queue;
            _builder        = builder;
            Configuration   = configuration;

            ConsumerCancelled += OnConsumerCancelled;
        }
        public void SubscribeClientTest()
        {
            IOutboundChannel target      = CreateIOutboundChannel();                        // TODO: Eseguire l'inizializzazione a un valore appropriato
            string           transportId = string.Empty;                                    // TODO: Eseguire l'inizializzazione a un valore appropriato
            IEnumerable <KeyValuePair <string, string> > inputInstructions          = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            IEnumerable <KeyValuePair <string, string> > outputInstructions         = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            IEnumerable <KeyValuePair <string, string> > outputInstructionsExpected = null; // TODO: Eseguire l'inizializzazione a un valore appropriato
            string expected = string.Empty;                                                 // TODO: Eseguire l'inizializzazione a un valore appropriato
            string actual;

            actual = target.SubscribeClient(transportId, inputInstructions, out outputInstructions);
            Assert.AreEqual(outputInstructionsExpected, outputInstructions);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verificare la correttezza del metodo di test.");
        }
Ejemplo n.º 28
0
        protected virtual void ConnectToBroker()
        {
            if (_outboundModel != null && !_outboundModel.IsClosed) return;
            _connection = _connectionBuilder.CreateConnection(_configuration.EndpointUri);
            //Logger.DebugFormat("RMQMessagingGateway: Opening channel to Rabbit MQ on connection {0}", Configuration.AMPQUri.GetSanitizedUri());
            _outboundModel = _connection.CreateModel();
            //When AutoClose is true, the last channel to close will also cause the connection to close1. If it is set to
            //true before any channel is created, the connection will close then and there.
            if (_connection.AutoClose == false)
                _connection.AutoClose = true;

            foreach (var exchange in _exchanges)
                exchange.Declare(_outboundModel);

            foreach (var queue in _queues)
                queue.Declare(_outboundModel);

            foreach (var binding in _bindings)
                binding.Declare(_outboundModel);

            var builder = new ConsumedMessageBuilder(_configuration.SerializationConfiguration, _configuration.MessageTypeResolver);
            _outboundChannel = _configuration.OutboundChannelBuilder(_outboundModel, _configuration);
            var consumers = _promises.Select(_ =>
            {
                var model = CreateInboundModel(_connection, _configuration.PrefetchSize, _configuration.PrefetchCount);
                var consumer = _(builder).BuildConsumer(new InboundChannel(model), _outboundChannel);
                return new {Model = model, Consumer = consumer};
            })
                .ToList();

            foreach (var consumer in consumers)
                consumer.Consumer.Declare(consumer.Model);
            _consumers = consumers.Select(_ => _.Consumer);
        }
Ejemplo n.º 29
0
 internal abstract ConsumerBase BuildConsumer(IInboundChannel inboundChannel, IOutboundChannel outboundChannel);
Ejemplo n.º 30
0
 /// <summary>
 /// Required by ILogBus
 /// </summary>
 public void AddOutboundChannel(IOutboundChannel channel)
 {
     _target.AddOutboundChannel(channel);
 }
 /// <summary>
 /// Initializes a new instance of ClientUnsubscribedEventArgs
 /// </summary>
 /// <param name="channel">Channel to which the client was subscribed</param>
 /// <param name="clientId">ID of client</param>
 public ClientUnsubscribedEventArgs(IOutboundChannel channel, string clientId)
 {
     Channel  = channel;
     ClientId = clientId;
 }
Ejemplo n.º 32
0
 public void Apply(IOutboundChannel channel, ConsumedMessageBase message)
 {
 }
Ejemplo n.º 33
0
 internal abstract ConsumerBase BuildConsumer(IInboundChannel inboundChannel, IOutboundChannel outboundChannel);
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes a new instanceClientSubscribingEventArgs
 /// </summary>
 /// <param name="channel">Channel to which the client is subscribing</param>
 /// <param name="transport">Transport chosen by client</param>
 /// <param name="instructions">Instructions provided by client to the transport</param>
 public ClientSubscribingEventArgs(IOutboundChannel channel, string transport,
                                   IEnumerable <KeyValuePair <string, string> > instructions)
     : base(channel, transport, instructions)
 {
 }
Ejemplo n.º 35
0
 public void Apply(IOutboundChannel channel, ConsumedMessageBase message)
 {
     channel.ForwardAsync(message, _exchange, String.Empty);
 }
Ejemplo n.º 36
0
 internal override AggregateConsumingResult Reply(IInboundChannel inboundChannel,
                                                  IOutboundChannel outboundChannel,
                                                  IFallbackStrategy fallbackStrategy)
 {
     fallbackStrategy.Apply(outboundChannel, Message);
     return base.Reply(inboundChannel, outboundChannel, fallbackStrategy);
 }
Ejemplo n.º 37
0
 public void Apply(IOutboundChannel channel, ConsumedMessageBase message)
 {
     channel.ForwardAsync(message, _exchange, String.Empty);
 }
Ejemplo n.º 38
0
 public void Apply(IOutboundChannel channel, ConsumedMessageBase message) { }