public RmqValidateExistingInfrastructureTests() { _message = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange(Guid.NewGuid().ToString()) }; _messageProducer = new RmqMessageProducer(rmqConnection, new RmqPublication { MakeChannels = OnMissingChannel.Validate }); _messageConsumer = new RmqMessageConsumer( connection: rmqConnection, queueName: _message.Header.Topic, routingKey: _message.Header.Topic, isDurable: false, highAvailability: false, makeChannels: OnMissingChannel.Validate); //This creates the infrastructure we want new QueueFactory(rmqConnection, _message.Header.Topic).Create(3000); }
public ControlBusSenderFactoryTests() { _fakeOutboxSync = A.Fake <IAmAnOutboxSync <Message> >(); s_fakeGateway = A.Fake <IAmAMessageProducerSync>(); s_senderFactory = new ControlBusSenderFactory(); }
public RmqMessageProducerQueueLengthTests() { _messageOne = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content")); _messageTwo = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange"), }; _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer( connection: rmqConnection, queueName: _messageOne.Header.Topic, routingKey: _messageOne.Header.Topic, isDurable: false, highAvailability: false, batchSize: 5, maxQueueLength: 1, makeChannels: OnMissingChannel.Create ); //create the infrastructure _messageConsumer.Receive(0); }
public RMQBufferedConsumerTests() { var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange") }; _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer(connection: rmqConnection, queueName: _topic, routingKey: _topic, isDurable: false, highAvailability: false, batchSize: BatchSize); //create the queue, so that we can receive messages posted to it new QueueFactory(rmqConnection, _topic).Create(3000); }
public RmqMessageProducerSupportsMultipleThreadsTests() { _message = new Message( new MessageHeader(Guid.NewGuid(), "nonexistenttopic", MessageType.MT_COMMAND), new MessageBody("test content")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange") }; _messageProducer = new RmqMessageProducer(rmqConnection); }
public RestMsMessageProducerSendTests() { var configuration = new RestMSMessagingGatewayConfiguration { Feed = new Feed { Name = "test", Type = "Default" }, RestMS = new RestMsSpecification { Uri = new Uri("http://localhost:3416/restms/domain/default"), Id = "dh37fgj492je", User = "******", Key = "wBgvhp1lZTr4Tb6K6+5OQa1bL9fxK7j8wBsepjqVNiQ=", Timeout = 2000 } }; _messageProducer = new RestMsMessageProducer(configuration); _messageConsumer = new RestMsMessageConsumer(configuration, QueueName, Topic); _message = new Message(new MessageHeader(Guid.NewGuid(), Topic, MessageType.MT_COMMAND), new MessageBody("test content")); }
public RmqMessageProducerSendMessageTests() { _message = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange") }; _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer(rmqConnection, _message.Header.Topic, _message.Header.Topic, false, false); new QueueFactory(rmqConnection, _message.Header.Topic).Create(3000); }
public RmqMessageConsumerOperationInterruptedTests() { var messageHeader = new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND); messageHeader.UpdateHandledCount(); _sentMessage = new Message(messageHeader, new MessageBody("test content")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange") }; _sender = new RmqMessageProducer(rmqConnection); _receiver = new RmqMessageConsumer(rmqConnection, _sentMessage.Header.Topic, _sentMessage.Header.Topic, false, false); _badReceiver = new OperationInterruptedRmqMessageConsumer(rmqConnection, _sentMessage.Header.Topic, _sentMessage.Header.Topic, false, 1, false); _sender.Send(_sentMessage); }
/// <summary> /// Initializes an Instance of <see cref="AzureServiceBusConsumer"/> /// </summary> /// <param name="topicName">The name of the Topic.</param> /// <param name="subscriptionName">The name of the Subscription on the Topic.</param> /// <param name="messageProducerSync">An instance of the Messaging Producer used for Requeue.</param> /// <param name="administrationClientWrapper">An Instance of Administration Client Wrapper.</param> /// <param name="serviceBusReceiverProvider">An Instance of <see cref="ServiceBusReceiverProvider"/>.</param> /// <param name="batchSize">How many messages to receive at a time.</param> /// <param name="receiveMode">The mode in which to Receive.</param> /// <param name="makeChannels">The mode in which to make Channels.</param> /// <param name="subscriptionConfiguration">The configuration options for the subscriptions.</param> public AzureServiceBusConsumer(string topicName, string subscriptionName, IAmAMessageProducerSync messageProducerSync, IAdministrationClientWrapper administrationClientWrapper, IServiceBusReceiverProvider serviceBusReceiverProvider, int batchSize = 10, ServiceBusReceiveMode receiveMode = ServiceBusReceiveMode.ReceiveAndDelete, OnMissingChannel makeChannels = OnMissingChannel.Create, AzureServiceBusSubscriptionConfiguration subscriptionConfiguration = default) { _subscriptionName = subscriptionName; _topicName = topicName; _messageProducerSync = messageProducerSync; _administrationClientWrapper = administrationClientWrapper; _serviceBusReceiverProvider = serviceBusReceiverProvider; _batchSize = batchSize; _makeChannel = makeChannels; _subscriptionConfiguration = subscriptionConfiguration ?? new AzureServiceBusSubscriptionConfiguration(); _receiveMode = receiveMode; GetMessageReceiverProvider(); }
public RmqMessageProducerDelayedMessageTests() { var header = new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND); var originalMessage = new Message(header, new MessageBody("test3 content")); var mutatedHeader = new MessageHeader(header.Id, Guid.NewGuid().ToString(), MessageType.MT_COMMAND); mutatedHeader.Bag.Add(HeaderNames.DELAY_MILLISECONDS, 1000); _message = new Message(mutatedHeader, originalMessage.Body); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.delay.brighter.exchange", supportDelay: true) }; _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer(rmqConnection, _message.Header.Topic, _message.Header.Topic, false, false); new QueueFactory(rmqConnection, _message.Header.Topic).Create(3000); }
public RmqMessageProducerDLQTests() { _message = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content")); var deadLetterQueueName = $"{_message.Header.Topic}.DLQ"; var deadLetterRoutingKey = $"{_message.Header.Topic}.DLQ"; 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") }; _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer( connection: rmqConnection, queueName: _message.Header.Topic, routingKey: _message.Header.Topic, isDurable: false, highAvailability: false, deadLetterQueueName: deadLetterQueueName, deadLetterRoutingKey: deadLetterRoutingKey, makeChannels: OnMissingChannel.Create ); _deadLetterConsumer = new RmqMessageConsumer( connection: rmqConnection, queueName: deadLetterQueueName, routingKey: deadLetterRoutingKey, isDurable: false, makeChannels: OnMissingChannel.Assume ); //create the infrastructure _messageConsumer.Receive(0); }
public RmqMessageConsumerMultipleTopicTests() { _messageTopic1 = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content for topic test 1")); _messageTopic2 = new Message( new MessageHeader(Guid.NewGuid(), Guid.NewGuid().ToString(), MessageType.MT_COMMAND), new MessageBody("test content for topic test 2")); var rmqConnection = new RmqMessagingGatewayConnection { AmpqUri = new AmqpUriSpecification(new Uri("amqp://*****:*****@localhost:5672/%2f")), Exchange = new Exchange("paramore.brighter.exchange") }; var topics = new[] { _messageTopic1.Header.Topic, _messageTopic2.Header.Topic }; var queueName = Guid.NewGuid().ToString(); _messageProducer = new RmqMessageProducer(rmqConnection); _messageConsumer = new RmqMessageConsumer(rmqConnection, queueName, topics, false, false); new QueueFactory(rmqConnection, queueName, topics).Create(3000); }
public SqsMessageProducerRequeueTests() { MyCommand myCommand = new MyCommand { Value = "Test" }; Guid correlationId = Guid.NewGuid(); string replyTo = "http:\\queueUrl"; string contentType = "text\\plain"; var channelName = $"Producer-Requeue-Tests-{Guid.NewGuid().ToString()}".Truncate(45); string topicName = $"Producer-Requeue-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 ); _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 new CredentialProfileStoreChain(); (AWSCredentials credentials, RegionEndpoint region) = CredentialsChain.GetAwsCredentials(); var awsConnection = new AWSMessagingGatewayConnection(credentials, region); _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); }
public void Repost(List <string> messageIds, IAmAnOutboxSync <Message> outBox, IAmAMessageProducerSync messageProducerSync) { var foundMessages = GetMessagesFromOutBox(outBox, messageIds); foreach (var foundMessage in foundMessages) { messageProducerSync.Send(foundMessage); } }