Пример #1
1
 internal BrokerWrapper(IConnectionBuilder connectionBuilder,
                        IModel model,
                        EnvironmentConfiguration configuration)
     : base(configuration, connectionBuilder)
 {
     _model = model;
 }
Пример #2
0
        public void InitializationOfAmqpStuff()
        {
            const String queueName = "queue_name";
            const String exchangeName = "exchange_name";
            const String routingKey = "routing_key";

            var configuration = new EnvironmentConfiguration();
            configuration.Endpoint(new Uri("amqp://localhost:5672"));
            configuration.GeneratesMessageIdBy(new Mock<INewId>().Object);
            configuration.ResolveMessageTypeBy(new Mock<IMessageTypeResolver>().Object);

            var model = new Mock<IModel>();
            var connectionBuilder = StubConnectionBuilder(model);
            var broker = new BrokerWrapper(connectionBuilder.Object, model.Object, configuration);
            var consumer = new FakeConsumer(_ => Task.Factory.StartNew(() => { }));
            var queue = broker.DeclareQueue(queueName);
            var exchange = broker.DeclareDirectExchange(exchangeName);
            broker.DeclareExchangeBinding(exchange, queue, routingKey);
            broker.SubscribeByAtLeastOnce(queue, _ => { _.Consumes(consumer); });
            broker.Connect();
            model.Verify(_ => _.QueueDeclare(queueName,
                                             false,
                                             false,
                                             false,
                                             It.IsAny<IDictionary<String, Object>>()));
            model.Verify(_ => _.ExchangeDeclare(exchangeName,
                                                "direct",
                                                false,
                                                false,
                                                It.IsAny<IDictionary<String, Object>>()));
            model.Verify(_ => _.QueueBind(queueName,
                                          exchangeName,
                                          routingKey,
                                          It.IsAny<IDictionary<String, Object>>()));
        }
Пример #3
0
 protected internal Broker(EnvironmentConfiguration configuration, IConnectionBuilder connectionBuilder)
 {
     _configuration = configuration;
     _connectionBuilder = connectionBuilder;
     _retryPolicy = _connectionBuilder.RetryPolicy;
     _circuitBreakerPolicy = _connectionBuilder.CircuitBreakerPolicy;
 }
 internal LoggedReliableOutboundChannel(IModel model,
                                        EnvironmentConfiguration configuration,
                                        IDateTimeProvider dateTimeProvider,
                                        NotConfirmedMessageHandler notConfirmedMessageHandler) // TODO: check if I can access this by EnvironmentConfiguration
     : base(model, configuration, dateTimeProvider, notConfirmedMessageHandler)
 {
 }
Пример #5
0
        public static IBroker New(Action<EnvironmentConfiguration> configure, IConnectionBuilder connectionBuilder)
        {
            if (configure == null)
                throw new ArgumentNullException(nameof(configure));

            if (connectionBuilder == null)
                throw new ArgumentNullException(nameof(connectionBuilder));

            var configuration = new EnvironmentConfiguration();
            configure(configuration);
            return new Broker(configuration, connectionBuilder);
        }
Пример #6
0
 protected internal Broker(EnvironmentConfiguration configuration, IConnectionBuilder connectionBuilder)
 {
     _configuration = configuration;
     _connectionBuilder = connectionBuilder;
 }
Пример #7
0
 public LoggedOutboundChannel(IModel model,
                              EnvironmentConfiguration configuration,
                              IDateTimeProvider dateTimeProvider)
     : base(model, configuration, dateTimeProvider)
 {
 }