public SqsMessageProducerSendTests()
        {
            _myCommand = new MyCommand {
                Value = "Test"
            };
            _correlationId = Guid.NewGuid();
            _replyTo       = "http:\\queueUrl";
            _contentType   = "text\\plain";
            var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);

            _topicName  = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            _connection = new Connection <MyCommand>(
                name: new ConnectionName(channelName),
                channelName: new ChannelName(channelName),
                routingKey: new RoutingKey(_topicName)
                );

            _message = new Message(
                new MessageHeader(_myCommand.Id, _topicName, MessageType.MT_COMMAND, _correlationId, _replyTo, _contentType),
                new MessageBody(JsonConvert.SerializeObject((object)_myCommand))
                );


            (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
            var awsConnection = new AWSMessagingGatewayConnection(credentials, region);

            _channelFactory  = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection));
            _channel         = _channelFactory.CreateChannel(_connection);
            _messageProducer = new SqsMessageProducer(awsConnection);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Consumer"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="subscriptionName">The name of the associated subscription.</param>
 /// <param name="channel">The channel.</param>
 /// <param name="messagePump">The message pump.</param>
 public Consumer(ConsumerName name, SubscriptionName subscriptionName, IAmAChannel channel, IAmAMessagePump messagePump)
 {
     Name             = name;
     SubscriptionName = subscriptionName;
     Performer        = new Performer(channel, messagePump);
     State            = ConsumerState.Shut;
 }
Ejemplo n.º 3
0
        public SqsRawMessageDeliveryTests()
        {
            (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
            var awsConnection = new AWSMessagingGatewayConnection(credentials, region);

            _channelFactory = new ChannelFactory(awsConnection);
            var channelName = $"Raw-Msg-Delivery-Tests-{Guid.NewGuid().ToString()}".Truncate(45);

            _topicName = $"Raw-Msg-Delivery-Tests-{Guid.NewGuid().ToString()}".Truncate(45);

            var routingKey = new RoutingKey(_topicName);

            var bufferSize = 10;

            //Set rawMessageDelivery to false
            _channel = _channelFactory.CreateChannel(new SqsSubscription <MyCommand>(
                                                         name: new SubscriptionName(channelName),
                                                         channelName: new ChannelName(channelName),
                                                         routingKey: routingKey,
                                                         bufferSize: bufferSize,
                                                         makeChannels: OnMissingChannel.Create,
                                                         rawMessageDelivery: false));

            _messageProducer = new SqsMessageProducer(awsConnection,
                                                      new SnsPublication
            {
                MakeChannels = OnMissingChannel.Create
            });
        }
        public SqsMessageConsumerRequeueTests()
        {
            _myCommand = new MyCommand {
                Value = "Test"
            };
            _correlationId = Guid.NewGuid();
            _replyTo       = "http:\\queueUrl";
            _contentType   = "text\\plain";
            _topicName     = AWSNameExtensions.ToValidSNSTopicName((string)_myCommand.GetType().FullName.ToString());

            _message = new Message(
                new MessageHeader(_myCommand.Id, _topicName, MessageType.MT_COMMAND, _correlationId, _replyTo, _contentType),
                new MessageBody(JsonConvert.SerializeObject((object)_myCommand))
                );

            //Must have credentials stored in the SDK Credentials store or shared credentials file
            if (new CredentialProfileStoreChain().TryGetAWSCredentials("default", out var credentials))
            {
                var awsConnection = new AWSMessagingGatewayConnection(credentials, RegionEndpoint.EUWest1);

                _channelFactory = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection));
                _channel        = _channelFactory.CreateChannel(new Connection <MyCommand>());

                _messageProducer = new SqsMessageProducer(awsConnection);
            }
        }
        public SqsMessageProducerSendTests()
        {
            _myCommand = new MyCommand {
                Value = "Test"
            };
            _correlationId = Guid.NewGuid();
            _replyTo       = "http:\\queueUrl";
            _contentType   = "text\\plain";
            var channelName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);

            _topicName = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            var routingKey = new RoutingKey(_topicName);

            SqsSubscription <MyCommand> subscription = new(
                name : new SubscriptionName(channelName),
                channelName : new ChannelName(channelName),
                routingKey : routingKey
                );

            _message = new Message(
                new MessageHeader(_myCommand.Id, _topicName, MessageType.MT_COMMAND, _correlationId, _replyTo, _contentType),
                new MessageBody(JsonSerializer.Serialize((object)_myCommand, JsonSerialisationOptions.Options))
                );


            (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
            var awsConnection = new AWSMessagingGatewayConnection(credentials, region);

            _channelFactory = new ChannelFactory(awsConnection);
            _channel        = _channelFactory.CreateChannel(subscription);

            _messageProducer = new SqsMessageProducer(awsConnection, new SnsPublication {
                Topic = new RoutingKey(_topicName), MakeChannels = OnMissingChannel.Create
            });
        }
Ejemplo n.º 6
0
 public Performer(
     IAmAChannel channel,
     IAmAMessagePump messagePump)
 {
     _channel     = channel;
     _messagePump = messagePump;
 }
Ejemplo n.º 7
0
        public SqsMessageConsumerRequeueTests()
        {
            _myCommand = new MyCommand {
                Value = "Test"
            };
            Guid   correlationId = Guid.NewGuid();
            string replyTo       = "http:\\queueUrl";
            string contentType   = "text\\plain";
            var    channelName   = $"Consumer-Requeue-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            string topicName     = $"Consumer-Requeue-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            var    routingKey    = new RoutingKey(topicName);

            SqsSubscription <MyCommand> subscription = new(
                name : new SubscriptionName(channelName),
                channelName : new ChannelName(channelName),
                routingKey : routingKey
                );

            _message = new Message(
                new MessageHeader(_myCommand.Id, topicName, MessageType.MT_COMMAND, correlationId, replyTo, contentType),
                new MessageBody(JsonSerializer.Serialize((object)_myCommand, JsonSerialisationOptions.Options))
                );

            //Must have credentials stored in the SDK Credentials store or shared credentials file
            (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
            var awsConnection = new AWSMessagingGatewayConnection(credentials, region);

            //We need to do this manually in a test - will create the channel from subscriber parameters
            _channelFactory = new ChannelFactory(awsConnection);
            _channel        = _channelFactory.CreateChannel(subscription);

            _messageProducer = new SqsMessageProducer(awsConnection, new SnsPublication {
                MakeChannels = OnMissingChannel.Create
            });
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Consumer"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="connectionName">The name of the associated connection.</param>
 /// <param name="channel">The channel.</param>
 /// <param name="messagePump">The message pump.</param>
 public Consumer(ConsumerName name, ConnectionName connectionName, IAmAChannel channel, IAmAMessagePump messagePump)
 {
     Name           = name;
     ConnectionName = connectionName;
     Performer      = new Performer(channel, messagePump);
     State          = ConsumerState.Shut;
 }
        public ASBConsumerTests()
        {
            var command = new ASBTestCommand()
            {
                CommandValue  = "Do the things.",
                CommandNumber = 26
            };

            _correlationId = Guid.NewGuid();
            _channelName   = $"Consumer-Tests-{Guid.NewGuid()}".Truncate(50);
            _topicName     = $"Consumer-Tests-{Guid.NewGuid()}";
            var routingKey = new RoutingKey(_topicName);

            AzureServiceBusSubscription <ASBTestCommand> subscription = new(
                name : new SubscriptionName(_channelName),
                channelName : new ChannelName(_channelName),
                routingKey : routingKey
                );

            _contentType = "application/json";

            _message = new Message(
                new MessageHeader(command.Id, _topicName, MessageType.MT_COMMAND, _correlationId, contentType: _contentType),
                new MessageBody(JsonSerializer.Serialize(command, JsonSerialisationOptions.Options))
                );

            _subscriptionConfiguration = new AzureServiceBusSubscriptionConfiguration()
            {
                DeadLetteringOnMessageExpiration = true,
                DefaultMessageTimeToLive         = TimeSpan.FromDays(4),
                LockDuration     = TimeSpan.FromMinutes(3),
                MaxDeliveryCount = 7,
                SqlFilter        = "1=1"
            };

            var clientProvider = ASBCreds.ASBClientProvider;

            _administrationClient = new AdministrationClientWrapper(clientProvider);
            _administrationClient.CreateSubscription(_topicName, _channelName, _subscriptionConfiguration);

            _serviceBusClient = clientProvider.GetServiceBusClient();

            var channelFactory =
                new AzureServiceBusChannelFactory(new AzureServiceBusConsumerFactory(clientProvider, false));

            _channel = channelFactory.CreateChannel(subscription);

            _producerRegistry = new AzureServiceBusProducerRegistryFactory(
                clientProvider,
                new AzureServiceBusPublication[]
            {
                new AzureServiceBusPublication {
                    Topic = new RoutingKey(_topicName)
                }
            }
                )
                                .Create();
        }
Ejemplo n.º 10
0
 public Performer(
     IAmAChannel channel,
     IAmAMessagePump messagePump,
     bool runAsync = false)
 {
     _channel     = channel;
     _messagePump = messagePump;
     _runAsync    = runAsync;
 }
Ejemplo n.º 11
0
        public ChannelRequeueWithoutDelayTest()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _gateway);

            _requeueMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));
        }
        public ChannelAcknowledgeTests()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new  Channel("test", _gateway);

            _receivedMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            _receivedMessage.DeliveryTag = 12345UL;
        }
Ejemplo n.º 13
0
        public void Establish()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _gateway);

            _requeueMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            _stopWatch = new Stopwatch();
        }
        public ChannelMessageReceiveTests()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _gateway);

            _sentMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            A.CallTo(() => _gateway.Receive(1000)).Returns(_sentMessage);
        }
        public ChannelRequeueWithUsnpportedDelayTests()
        {
            _consumer = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _consumer);

            _requeueMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            _stopWatch = new Stopwatch();
        }
Ejemplo n.º 16
0
        public void Establish()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _gateway);

            _receivedMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            _receivedMessage.SetDeliveryTag(12345UL);
        }
Ejemplo n.º 17
0
        public void Establish()
        {
            _gateway = A.Fake <IAmAMessageConsumerSupportingDelay>();
            A.CallTo(() => _gateway.DelaySupported).Returns(true);

            _channel = new Channel("test", _gateway);

            _requeueMessage = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("a test body"));

            _stopWatch = new Stopwatch();
        }
Ejemplo n.º 18
0
        public BufferedChannelTests()
        {
            _gateway = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _gateway, BufferLimit);

            _messageOne = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("FirstMessage"));

            _messageTwo = new Message(
                new MessageHeader(Guid.NewGuid(), "key", MessageType.MT_EVENT),
                new MessageBody("SecondMessage"));
        }
        public ASBProducerTests()
        {
            _command = new ASBTestCommand()
            {
                CommandValue  = "Do the things.",
                CommandNumber = 26
            };

            _correlationId = Guid.NewGuid();
            var channelName = $"Producer-Send-Tests-{Guid.NewGuid()}".Truncate(50);

            _topicName = $"Producer-Send-Tests-{Guid.NewGuid()}";
            var routingKey = new RoutingKey(_topicName);

            AzureServiceBusSubscription <ASBTestCommand> subscription = new(
                name : new SubscriptionName(channelName),
                channelName : new ChannelName(channelName),
                routingKey : routingKey
                );

            _contentType = "application/json";

            _message = new Message(
                new MessageHeader(_command.Id, _topicName, MessageType.MT_COMMAND, _correlationId, contentType: _contentType),
                new MessageBody(JsonSerializer.Serialize(_command, JsonSerialisationOptions.Options))
                );

            var clientProvider = ASBCreds.ASBClientProvider;

            _administrationClient = new AdministrationClientWrapper(clientProvider);
            _administrationClient.CreateSubscription(_topicName, channelName, new AzureServiceBusSubscriptionConfiguration());

            var channelFactory =
                new AzureServiceBusChannelFactory(new AzureServiceBusConsumerFactory(clientProvider, false));

            _channel = channelFactory.CreateChannel(subscription);

            _producerRegistry = new AzureServiceBusProducerRegistryFactory(
                clientProvider,
                new AzureServiceBusPublication[]
            {
                new AzureServiceBusPublication {
                    Topic = new RoutingKey(_topicName)
                }
            }
                )
                                .Create();
        }
Ejemplo n.º 20
0
      public AWSValidateInfrastructureTests()
      {
          _myCommand = new MyCommand {
              Value = "Test"
          };
          Guid   correlationId = Guid.NewGuid();
          string replyTo       = "http:\\queueUrl";
          string contentType   = "text\\plain";
          var    channelName   = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
          string topicName     = $"Producer-Send-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
          var    routingKey    = new RoutingKey(topicName);

          SqsSubscription <MyCommand> subscription = new(
              name : new SubscriptionName(channelName),
              channelName : new ChannelName(channelName),
              routingKey : routingKey,
              makeChannels : OnMissingChannel.Create
              );

          _message = new Message(
              new MessageHeader(_myCommand.Id, topicName, MessageType.MT_COMMAND, correlationId, replyTo, contentType),
              new MessageBody(JsonConvert.SerializeObject((object)_myCommand))
              );


          (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
          var awsConnection = new AWSMessagingGatewayConnection(credentials, region);

          //We need to do this manually in a test - will create the channel from subscriber parameters
          //This doesn't look that different from our create tests - this is because we create using the channel factory in
          //our AWS transport, not the consumer (as it's a more likely to use infrastructure declared elsewhere)
          _channelFactory = new ChannelFactory(awsConnection);
          _channel        = _channelFactory.CreateChannel(subscription);

          //Now change the subscription to validate, just check what we made
          subscription = new(
              name : new SubscriptionName(channelName),
              channelName : _channel.Name,
              routingKey : routingKey,
              makeChannels : OnMissingChannel.Validate
              );

          _messageProducer = new SqsMessageProducer(awsConnection, new SqsPublication {
                MakeChannels = OnMissingChannel.Validate, RoutingKey = routingKey
            });

          _consumer = new SqsMessageConsumer(awsConnection, _channel.Name.ToValidSQSQueueName(), routingKey);
      }
Ejemplo n.º 21
0
        public SqsQueuePurgeTests()
        {
            MyCommand myCommand = new MyCommand {
                Value = "Test"
            };

            _message = new Message(
                new MessageHeader(myCommand.Id, "MyCommand", MessageType.MT_COMMAND),
                new MessageBody(JsonConvert.SerializeObject((object)myCommand))
                );

            //Must have credentials stored in the SDK Credentials store or shared credentials file
            if (new CredentialProfileStoreChain().TryGetAWSCredentials("default", out var credentials))
            {
                var awsConnection = new AWSMessagingGatewayConnection(credentials, RegionEndpoint.EUWest1);

                _channelFactory = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection));
                _channel        = _channelFactory.CreateChannel(new Connection <MyCommand>());

                _messageProducer = new SqsMessageProducer(awsConnection);
            }
        }
Ejemplo n.º 22
0
        public SqsQueuePurgeTests()
        {
            MyCommand myCommand = new MyCommand {
                Value = "Test"
            };

            _message = new Message(
                new MessageHeader(myCommand.Id, "MyCommand", MessageType.MT_COMMAND),
                new MessageBody(JsonConvert.SerializeObject((object)myCommand))
                );

            var credentialChain = new CredentialProfileStoreChain();

            if (credentialChain.TryGetAWSCredentials("default", out var credentials) && credentialChain.TryGetProfile("default", out var profile))
            {
                var awsConnection = new AWSMessagingGatewayConnection(credentials, profile.Region);

                _channelFactory = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection));
                _channel        = _channelFactory.CreateChannel(_connection);

                _messageProducer = new SqsMessageProducer(awsConnection);
            }
        }
Ejemplo n.º 23
0
        public RMQMessageConsumerRetryDLQTests()
        {
            Guid   correlationId = Guid.NewGuid();
            string contentType   = "text\\plain";
            var    channelName   = $"Requeue-Limit-Tests-{Guid.NewGuid().ToString()}";

            _topicName = $"Requeue-Limit-Tests-{Guid.NewGuid().ToString()}";
            var routingKey = new RoutingKey(_topicName);

            //what do we send
            var myCommand = new MyDeferredCommand {
                Value = "Hello Requeue"
            };

            _message = new Message(
                new MessageHeader(myCommand.Id, _topicName, MessageType.MT_COMMAND, correlationId, "", contentType),
                new MessageBody(JsonSerializer.Serialize((object)myCommand, JsonSerialisationOptions.Options))
                );

            var deadLetterQueueName  = $"{_message.Header.Topic}.DLQ";
            var deadLetterRoutingKey = $"{_message.Header.Topic}.DLQ";

            var subscription = new RmqSubscription <MyCommand>(
                name: new SubscriptionName(channelName),
                channelName: new ChannelName(channelName),
                routingKey: routingKey,
                //after 2 retries, fail and move to the DLQ
                requeueCount: 2,
                //delay before re-queuing
                requeueDelayInMilliseconds: 50,
                deadLetterChannelName: new ChannelName(deadLetterQueueName),
                deadLetterRoutingKey: deadLetterRoutingKey,
                makeChannels: OnMissingChannel.Create
                );

            var rmqConnection = new RmqMessagingGatewayConnection
            {
                AmpqUri            = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")),
                Exchange           = new Exchange("paramore.brighter.exchange"),
                DeadLetterExchange = new Exchange("paramore.brighter.exchange.dlq")
            };

            //how do we send to the queue
            _sender = new RmqMessageProducer(rmqConnection, new RmqPublication());

            //set up our receiver
            _channelFactory = new ChannelFactory(new RmqMessageConsumerFactory(rmqConnection));
            _channel        = _channelFactory.CreateChannel(subscription);

            //how do we handle a command
            IHandleRequests <MyDeferredCommand> handler = new MyDeferredCommandHandler();

            //hook up routing for the command processor
            var subscriberRegistry = new SubscriberRegistry();

            subscriberRegistry.Register <MyDeferredCommand, MyDeferredCommandHandler>();

            //once we read, how do we dispatch to a handler. N.B. we don't use this for reading here
            _commandProcessor = new CommandProcessor(
                subscriberRegistry: subscriberRegistry,
                handlerFactory: new QuickHandlerFactory(() => handler),
                requestContextFactory: new InMemoryRequestContextFactory(),
                policyRegistry: new PolicyRegistry()
                );

            //pump messages from a channel to a handler - in essence we are building our own dispatcher in this test
            IAmAMessageMapper <MyDeferredCommand> mapper = new MyDeferredCommandMessageMapper(_topicName);

            _messagePump = new MessagePumpBlocking <MyDeferredCommand>(_commandProcessor, mapper)
            {
                Channel = _channel, TimeoutInMilliseconds = 5000, RequeueCount = 3
            };

            _deadLetterConsumer = new RmqMessageConsumer(
                connection: rmqConnection,
                queueName: deadLetterQueueName,
                routingKey: deadLetterRoutingKey,
                isDurable: false,
                makeChannels: OnMissingChannel.Assume
                );
        }
 public MessagePumpSynchronizationContext(IAmAChannel channel)
 {
     _channel = channel;
 }
Ejemplo n.º 25
0
 public Performer(IAmAChannel channel, IAmAMessagePump messagePump)
 {
     _channel = channel;
     _messagePump = messagePump;
 }
Ejemplo n.º 26
0
        public void Establish()
        {
            _messageConsumer = A.Fake <IAmAMessageConsumer>();

            _channel = new Channel("test", _messageConsumer);
        }
 public ChannelDisposalTests()
 {
     _messageConsumer = A.Fake <IAmAMessageConsumer>();
     _channel         = new Channel("test", _messageConsumer);
 }
        public SnsReDrivePolicySDlqTests()
        {
            Guid   correlationId = Guid.NewGuid();
            string replyTo       = "http:\\queueUrl";
            string contentType   = "text\\plain";
            var    channelName   = $"Redrive-Tests-{Guid.NewGuid().ToString()}".Truncate(45);

            _dlqChannelName = $"Redrive-DLQ-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            _topicName      = $"Redrive-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            var routingKey = new RoutingKey(_topicName);

            //how are we consuming
            var subscription = new SqsSubscription <MyCommand>(
                name: new SubscriptionName(channelName),
                channelName: new ChannelName(channelName),
                routingKey: routingKey,
                //don't block the redrive policy from owning retry management
                requeueCount: -1,
                //delay before requeuing
                requeueDelayInMs: 50,
                //we want our SNS subscription to manage requeue limits using the DLQ for 'too many requeues'
                redrivePolicy: new RedrivePolicy
                (
                    deadLetterQueueName: new ChannelName(_dlqChannelName),
                    maxReceiveCount: 2
                ));

            //what do we send
            var myCommand = new MyDeferredCommand {
                Value = "Hello Redrive"
            };

            _message = new Message(
                new MessageHeader(myCommand.Id, _topicName, MessageType.MT_COMMAND, correlationId, replyTo, contentType),
                new MessageBody(JsonSerializer.Serialize((object)myCommand, JsonSerialisationOptions.Options))
                );

            //Must have credentials stored in the SDK Credentials store or shared credentials file
            (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials();
            _awsConnection = new AWSMessagingGatewayConnection(credentials, region);

            //how do we send to the queue
            _sender = new SqsMessageProducer(_awsConnection, new SnsPublication {
                MakeChannels = OnMissingChannel.Create
            });

            //We need to do this manually in a test - will create the channel from subscriber parameters
            _channelFactory = new ChannelFactory(_awsConnection);
            _channel        = _channelFactory.CreateChannel(subscription);

            //how do we handle a command
            IHandleRequests <MyDeferredCommand> handler = new MyDeferredCommandHandler();

            //hook up routing for the command processor
            var subscriberRegistry = new SubscriberRegistry();

            subscriberRegistry.Register <MyDeferredCommand, MyDeferredCommandHandler>();

            //once we read, how do we dispatch to a handler. N.B. we don't use this for reading here
            _commandProcessor = new CommandProcessor(
                subscriberRegistry: subscriberRegistry,
                handlerFactory: new QuickHandlerFactory(() => handler),
                requestContextFactory: new InMemoryRequestContextFactory(),
                policyRegistry: new PolicyRegistry()
                );

            //pump messages from a channel to a handler - in essence we are building our own dispatcher in this test
            IAmAMessageMapper <MyDeferredCommand> mapper = new MyDeferredCommandMessageMapper(_topicName);

            _messagePump = new MessagePumpBlocking <MyDeferredCommand>(_commandProcessor, mapper)
            {
                Channel = _channel, TimeoutInMilliseconds = 5000, RequeueCount = 3
            };
        }
Ejemplo n.º 29
0
 public InMemoryChannelFactory(FakeChannel channel = null)
 {
     _channel = channel;
 }