Exemple #1
0
        public SqsMessageProducerDlqTests ()
        {
            MyCommand myCommand = new MyCommand{Value = "Test"};
            Guid correlationId = Guid.NewGuid();
            string replyTo = "http:\\queueUrl";
            string contentType = "text\\plain";
            var channelName = $"Producer-DLQ-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            _dlqChannelName =$"Producer-DLQ-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            string topicName = $"Producer-DLQ-Tests-{Guid.NewGuid().ToString()}".Truncate(45);
            var routingKey = new RoutingKey(topicName);
            
            SqsSubscription<MyCommand> subscription = new SqsSubscription<MyCommand>(
                name: new SubscriptionName(channelName),
                channelName: new ChannelName(channelName),
                routingKey: routingKey,
                redrivePolicy: new RedrivePolicy(_dlqChannelName, 2)
            );
            
            _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);
            
            _sender = new SqsMessageProducer(_awsConnection, new SqsPublication{MakeChannels = OnMissingChannel.Create});
            
            _sender.ConfirmTopicExists(topicName);
            
            //We need to do this manually in a test - will create the channel from subscriber parameters
            _channelFactory = new ChannelFactory(_awsConnection);
            _channel = _channelFactory.CreateChannel(subscription);
        }
Exemple #2
0
        public AWSValidateQueuesTests()
        {
            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);

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

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

            //We need to create the topic at least, to check the queues
            var producer = new SqsMessageProducer(_awsConnection,
                                                  new SqsPublication
            {
                MakeChannels = OnMissingChannel.Create
            });

            producer.ConfirmTopicExists(topicName);
        }
Exemple #3
0
        public AWSAssumeQueuesTests()
        {
            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);

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

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

            //create the topic, we want the queue to be the issue
            //We need to create the topic at least, to check the queues
            var producer = new SqsMessageProducer(awsConnection,
                                                  new SnsPublication
            {
                MakeChannels = OnMissingChannel.Create
            });

            producer.ConfirmTopicExists(topicName);

            _channelFactory = new ChannelFactory(awsConnection);
            var channel = _channelFactory.CreateChannel(subscription);

            //We need to create the topic at least, to check the queues
            _consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(), routingKey);
        }