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 var _ = new SqsMessageProducer(awsConnection, new SqsPublication { MakeChannels = OnMissingChannel.Create, RoutingKey = routingKey }); _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); }
public SQSBufferedConsumerTests() { (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials(); var awsConnection = new AWSMessagingGatewayConnection(credentials, region); _channelFactory = new ChannelFactory(awsConnection); var channelName = $"Buffered-Consumer-Tests-{Guid.NewGuid().ToString()}".Truncate(45); _topicName = $"Buffered-Consumer-Tests-{Guid.NewGuid().ToString()}".Truncate(45); //we need the channel to create the queues and notifications var routingKey = new RoutingKey(_topicName); var channel = _channelFactory.CreateChannel(new SqsSubscription <MyCommand>( name: new SubscriptionName(channelName), channelName: new ChannelName(channelName), routingKey: routingKey, bufferSize: BUFFER_SIZE )); //we want to access via a consumer, to receive multiple messages - we don't want to expose on channel //just for the tests, so create a new consumer from the properties _consumer = new SqsMessageConsumer(awsConnection, channel.Name.ToValidSQSQueueName(), routingKey, BUFFER_SIZE); _messageProducer = new SqsMessageProducer(awsConnection, new SqsPublication { MakeChannels = OnMissingChannel.Create, RoutingKey = routingKey }); }
public SQSBufferedConsumerTests() { //Must have credentials stored in the SDK Credentials store or shared credentials file 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 channelFactory = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection)); var name = Guid.NewGuid().ToString(); //we need the channel to create the queues and notifications channelFactory.CreateChannel(new Connection <MyCommand>( name: new ConnectionName(name), channelName: new ChannelName(name), routingKey: new RoutingKey(_topicName), bufferSize: BUFFER_SIZE )); //we want to access via a consumer, to receive multiple messages - we don't want to expose on channel //just for the tests, so create a new consumer from the properties _consumer = new SqsMessageConsumer(awsConnection, new ChannelName(name).ToValidSQSQueueName(), BUFFER_SIZE); _messageProducer = new SqsMessageProducer(awsConnection); } }
public SQSBufferedConsumerTests() { //Must have credentials stored in the SDK Credentials store or shared credentials file var credentialChain = new CredentialProfileStoreChain(); (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials(); var awsConnection = new AWSMessagingGatewayConnection(credentials, region); _channelFactory = new ChannelFactory(awsConnection, new SqsMessageConsumerFactory(awsConnection)); var channelName = $"Buffered-Consumer-Tests-{Guid.NewGuid().ToString()}".Truncate(45); _topicName = $"Buffered-Consumer-Tests-{Guid.NewGuid().ToString()}".Truncate(45); //we need the channel to create the queues and notifications _channelFactory.CreateChannel(new Connection <MyCommand>( name: new ConnectionName(channelName), channelName: new ChannelName(channelName), routingKey: new RoutingKey(_topicName), bufferSize: BUFFER_SIZE )); //we want to access via a consumer, to receive multiple messages - we don't want to expose on channel //just for the tests, so create a new consumer from the properties var sqsQueueName = new ChannelName(channelName).ToValidSQSQueueName(); _consumer = new SqsMessageConsumer(awsConnection, sqsQueueName, BUFFER_SIZE); _messageProducer = new SqsMessageProducer(awsConnection); }
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); }