/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="parameters">(Optional) The parameters that were used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusQueueName">The name of the monitored Service Bus Queue</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> public ServiceBusQueueCommunicationListener(IServiceBusMessageReceiver receiver, ServiceInitializationParameters parameters, string serviceBusQueueName, string serviceBusSendConnectionString = null, string serviceBusReceiveConnectionString = null) : base(receiver, parameters, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { if (string.IsNullOrWhiteSpace(serviceBusQueueName)) throw new ArgumentOutOfRangeException(nameof(serviceBusQueueName)); ServiceBusQueueName = serviceBusQueueName; }
public ServiceBusCommunicationListener(IServiceBusMessageReceiver serviceBusMessageReceiver, string connectionString, string queueName) { _serviceBusMessageReceiver = serviceBusMessageReceiver; _connectionString = connectionString; _queueName = queueName; }
public void SetUp() { _receiver = A.Fake <IServiceBusMessageReceiver>(); _factory = A.Fake <IReceiverClientFactory>(); _receiverClient = A.Fake <IReceiverClient>(); A.CallTo(() => _factory.Create()) .Returns(_receiverClient); _sut = new GenericServiceBusCommunicationListener(null, _factory, _receiver); }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusQueueName">(Optional) The name of the monitored Service Bus Queue (EntityPath in connectionstring is supported too)</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.). /// </param> /// <param name="serviceBusReceiveConnectionString">(Required) A Service Bus connection string that can be used for Receiving messages. /// </param> public ServiceBusQueueCommunicationListener(IServiceBusMessageReceiver receiver, ServiceContext context, string serviceBusQueueName, string serviceBusSendConnectionString, string serviceBusReceiveConnectionString) : base(context, serviceBusQueueName, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { Receiver = receiver ?? throw new ArgumentNullException(nameof(receiver)); }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// Uses external clientFactory to use msi or middleware /// </summary> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="clientFactory">A factory to create either QueueClient or SubscriptionClient to listen for messages</param> /// <param name="receiver">A handler for incoming messages</param> public GenericServiceBusCommunicationListener( ServiceContext context, IReceiverClientFactory clientFactory, IServiceBusMessageReceiver receiver) : base(context) { _clientFactory = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory)); _receiver = receiver ?? throw new ArgumentNullException(nameof(receiver)); }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusTopicName">The name of the monitored Service Bus Topic</param> /// <param name="serviceBusSubscriptionName">The name of the monitored Service Bus Topic Subscription</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> public ServiceBusSubscriptionCommunicationListener(IServiceBusMessageReceiver receiver, ServiceContext context, string serviceBusTopicName, string serviceBusSubscriptionName, string serviceBusSendConnectionString = null, string serviceBusReceiveConnectionString = null) : base(receiver, context, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { if (string.IsNullOrWhiteSpace(serviceBusTopicName)) throw new ArgumentOutOfRangeException(nameof(serviceBusTopicName)); if (string.IsNullOrWhiteSpace(serviceBusSubscriptionName)) throw new ArgumentOutOfRangeException(nameof(serviceBusSubscriptionName)); ServiceBusTopicName = serviceBusTopicName; ServiceBusSubscriptionName = serviceBusSubscriptionName; }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusTopicName">The name of the monitored Service Bus Topic (optional, EntityPath is supported too)</param> /// <param name="serviceBusSubscriptionName">The name of the monitored Service Bus Topic Subscription</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. (Returned as Service Endpoint.) </param> /// <param name="serviceBusReceiveConnectionString">(Required) A Service Bus connection string that can be used for Receiving messages. /// </param> public ServiceBusSubscriptionCommunicationListener(IServiceBusMessageReceiver receiver, ServiceContext context, string serviceBusTopicName, string serviceBusSubscriptionName, string serviceBusSendConnectionString, string serviceBusReceiveConnectionString) : base(context, serviceBusTopicName, serviceBusSubscriptionName, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { Receiver = receiver; }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="parameters">(Optional) The parameters that were used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusQueueName">The name of the monitored Service Bus Queue</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> public ServiceBusQueueCommunicationListener(IServiceBusMessageReceiver receiver, ServiceInitializationParameters parameters, string serviceBusQueueName, string serviceBusSendConnectionString = null, string serviceBusReceiveConnectionString = null) : base(receiver, parameters, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { if (string.IsNullOrWhiteSpace(serviceBusQueueName)) { throw new ArgumentOutOfRangeException(nameof(serviceBusQueueName)); } ServiceBusQueueName = serviceBusQueueName; }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiverFactory">(Required) Creates a handler that processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusQueueName">(Optional) The name of the monitored Service Bus Queue (EntityPath in connectionstring is supported too)</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.). /// </param> /// <param name="serviceBusReceiveConnectionString">(Required) A Service Bus connection string that can be used for Receiving messages. /// </param> public ServiceBusQueueCommunicationListener(Func <IServiceBusCommunicationListener, IServiceBusMessageReceiver> receiverFactory, ServiceContext context, string serviceBusQueueName, string serviceBusSendConnectionString, string serviceBusReceiveConnectionString) : base(context, serviceBusQueueName, serviceBusSendConnectionString, serviceBusReceiveConnectionString) { if (receiverFactory == null) { throw new ArgumentNullException(nameof(receiverFactory)); } var serviceBusMessageReceiver = receiverFactory(this); Receiver = serviceBusMessageReceiver ?? throw new ArgumentException("Receiver factory cannot return null.", nameof(receiverFactory)); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="parameters">(Optional) The parameters that were used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> protected ServiceBusCommunicationListener(IServiceBusMessageReceiver receiver , ServiceInitializationParameters parameters , string serviceBusSendConnectionString , string serviceBusReceiveConnectionString) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (receiver == null) { throw new ArgumentNullException(nameof(receiver)); } if (string.IsNullOrWhiteSpace(serviceBusSendConnectionString)) { serviceBusSendConnectionString = CloudConfigurationManager.GetSetting(DefaultSendConnectionStringConfigurationKey); } if (string.IsNullOrWhiteSpace(serviceBusReceiveConnectionString)) { serviceBusReceiveConnectionString = CloudConfigurationManager.GetSetting(DefaultReceiveConnectionStringConfigurationKey); } if (string.IsNullOrWhiteSpace(serviceBusSendConnectionString)) { throw new ArgumentOutOfRangeException(nameof(serviceBusSendConnectionString)); } if (string.IsNullOrWhiteSpace(serviceBusReceiveConnectionString)) { throw new ArgumentOutOfRangeException(nameof(serviceBusReceiveConnectionString)); } Parameters = parameters; Receiver = receiver; ServiceBusSendConnectionString = serviceBusSendConnectionString; ServiceBusReceiveConnectionString = serviceBusReceiveConnectionString; _stopProcessingMessageTokenSource = new CancellationTokenSource(); StopProcessingMessageToken = _stopProcessingMessageTokenSource.Token; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> protected ServiceBusCommunicationListener(IServiceBusMessageReceiver receiver , ServiceContext context , string serviceBusSendConnectionString , string serviceBusReceiveConnectionString) { if (context == null) throw new ArgumentNullException(nameof(context)); if (receiver == null) throw new ArgumentNullException(nameof(receiver)); if (string.IsNullOrWhiteSpace(serviceBusSendConnectionString)) serviceBusSendConnectionString = CloudConfigurationManager.GetSetting(DefaultSendConnectionStringConfigurationKey); if (string.IsNullOrWhiteSpace(serviceBusReceiveConnectionString)) serviceBusReceiveConnectionString = CloudConfigurationManager.GetSetting(DefaultReceiveConnectionStringConfigurationKey); if (string.IsNullOrWhiteSpace(serviceBusSendConnectionString)) throw new ArgumentOutOfRangeException(nameof(serviceBusSendConnectionString)); if (string.IsNullOrWhiteSpace(serviceBusReceiveConnectionString)) throw new ArgumentOutOfRangeException(nameof(serviceBusReceiveConnectionString)); Context = context; Receiver = receiver; ServiceBusSendConnectionString = serviceBusSendConnectionString; ServiceBusReceiveConnectionString = serviceBusReceiveConnectionString; _stopProcessingMessageTokenSource = new CancellationTokenSource(); StopProcessingMessageToken = _stopProcessingMessageTokenSource.Token; }
public ServiceBusProcessingControllerTests() { _serviceBusMessageReceiver = A.Fake <IServiceBusMessageReceiver>(); _serviceBusMessageWriter = A.Fake <IServiceBusMessageWriter>(); _testee = new ServiceBusProcessingController(_serviceBusMessageReceiver, _serviceBusMessageWriter); }
public ServiceBusProcessingController(IServiceBusMessageReceiver serviceBusMessageReceiver, IServiceBusMessageWriter serviceBusMessageWriter) { _serviceBusMessageReceiver = serviceBusMessageReceiver; _serviceBusMessageWriter = serviceBusMessageWriter; }
/// <summary> /// Creates a new instance, using the init parameters of a <see cref="StatefulService"/> /// </summary> /// <param name="receiver">(Required) Processes incoming messages.</param> /// <param name="context">(Optional) The context that was used to init the Reliable Service that uses this listener.</param> /// <param name="serviceBusQueueName">The name of the monitored Service Bus Queue</param> /// <param name="serviceBusSendConnectionString">(Optional) A Service Bus connection string that can be used for Sending messages. /// (Returned as Service Endpoint.) When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="serviceBusReceiveConnectionString">(Optional) A Service Bus connection string that can be used for Receiving messages. /// When not supplied, an App.config appSettings value with key 'Microsoft.ServiceBus.ConnectionString.Receive' /// is used.</param> /// <param name="requireSessions">Indicates whether the provided Message Queue requires sessions.</param> public ServiceBusQueueCommunicationListener(IServiceBusMessageReceiver receiver, ServiceContext context, string serviceBusQueueName, string serviceBusSendConnectionString = null, string serviceBusReceiveConnectionString = null, bool requireSessions = false) : base(context, serviceBusQueueName, serviceBusSendConnectionString, serviceBusReceiveConnectionString, requireSessions) { Receiver = receiver; }