예제 #1
0
        public SynchronizedCache(ManagementClient serviceBusManagementClient, ITopicClient serviceBusTopicClient)
        {
            this.serviceBusManagementClient = serviceBusManagementClient;
            this.topicClient = serviceBusTopicClient;

            this.cacheType          = typeof(TValue).Name;
            this.subscriptionName   = $"{cacheType}-{Environment.MachineName}";
            this.lazyInitialization = new Lazy <Task>(EnsureInitializationAsync, LazyThreadSafetyMode.ExecutionAndPublication);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="client">Topic Client</param>
        public BusTopicClient(ITopicClient client)
        {
            if (null == client)
            {
                throw new ArgumentNullException("client");
            }

            this.client = client;
        }
예제 #3
0
        public TopicDispatcher(ITopicFactory <T> topicFactory)
        {
            if (topicFactory == null)
            {
                throw new ArgumentNullException(nameof(topicFactory));
            }

            _client = topicFactory.Create();
        }
 public TopicClientSendOperations(string serviceBusConnectionString, string topicName, int maxRetryCountOnSend, int minimumBackOff = 1, int maximumBackOff = 10)
 {
     _serviceBusConnectionString = serviceBusConnectionString;
     _topicName           = topicName;
     _minimumBackOff      = minimumBackOff;
     _maximumBackOff      = maximumBackOff;
     _maxRetryCountOnSend = maxRetryCountOnSend;
     CustomTopicClient    = CreateTopicClient();
 }
예제 #5
0
        static async Task MainAsync()
        {
            topicClient = new TopicClient(ServiceBusConnectionString, TopicName);

            // Send messages.
            await SendMessagesAsync(NumberOfMessages);

            await topicClient.CloseAsync();
        }
예제 #6
0
 public OrdersController(IConfiguration configuration)
 {
     Configuration = configuration;
     connStr       = Configuration["DbConnectionString"];
     // Note 1: change from sb to https
     sbConnectionString = Configuration["SBConnectionString"];
     topicName          = Configuration["SBTopic"];
     topicClient        = new TopicClient(sbConnectionString, topicName);
 }
 public DefaultServiceBusPersisterConnection(ServiceBusConnectionStringBuilder serviceBusConnectionStringBuilder,
                                             string subscriptionClientName)
 {
     _serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
                                          throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
     _subscriptionClientName = subscriptionClientName;
     _subscriptionClient     = new SubscriptionClient(_serviceBusConnectionStringBuilder, subscriptionClientName);
     _topicClient            = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
 }
예제 #8
0
        static void Main(string[] args)
        {
            var serviceBusConnectionString = ConfigurationManager.AppSettings["ServiceBusTopicSubscriptionSenderSharedAccessPolicy"];
            var topicName = ConfigurationManager.AppSettings["ServiceBusTopicName"];

            topicClient = new TopicClient(serviceBusConnectionString, topicName);
            SendMessageAsync().GetAwaiter().GetResult();
            Console.ReadKey();
        }
예제 #9
0
 public ProcessSignatureEnqueuer(
     ITopicClient topicClient,
     IBrokeredMessageSerializer <SignatureValidationMessage> serializer,
     IOptionsSnapshot <ProcessSignatureConfiguration> configuration)
 {
     _topicClient   = topicClient ?? throw new ArgumentNullException(nameof(topicClient));
     _serializer    = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
        public ITopicClient CreateModel()
        {
            if (_topicClient.IsClosedOrClosing)
            {
                _topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
            }

            return(_topicClient);
        }
예제 #11
0
        public TopicPublisherAgent()
        {
            if (string.IsNullOrEmpty(serviceBusConnectionString))
            {
                throw new ConfigurationErrorsException(nameof(serviceBusConnectionString));
            }

            topicClient = new TopicClient(serviceBusConnectionString, topicName);
        }
        public DefaultServiceBusPersisterConnection(ServiceBusConnectionStringBuilder serviceBusConnectionStringBuilder,
                                                    ILogger <DefaultServiceBusPersisterConnection> logger)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
                                                 throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
            _topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
        }
예제 #13
0
        public ServiceBusTopicHandler(string connectionString, string topic, string subscriptionName, Func <Message, CancellationToken, Task> onMessageRecivedCallBack)
        {
            // create connection link
            topicClient        = new TopicClient(connectionString, topic);
            subscriptionClient = new SubscriptionClient(connectionString, topic, subscriptionName);

            // Register subscription message handler and receive messages in a loop
            RegisterOnMessageHandlerAndReceiveMessages(onMessageRecivedCallBack);
        }
예제 #14
0
 public AzureServiceBusInstance(IMessageReceiver messageReceiver, ITopicClient topicClient, AzureServiceBusTransportSettings settings, ILogger logger, int connectionStringNumber)
 {
     this.messageReceiver        = messageReceiver;
     this.topicClient            = topicClient;
     this.settings               = settings;
     this.logger                 = logger;
     this.connectionStringNumber = connectionStringNumber;
     detectFailureFast           = true;
 }
예제 #15
0
 public EmailMessageEnqueuer(
     ITopicClient topicClient,
     IServiceBusMessageSerializer serializer,
     ILogger <EmailMessageEnqueuer> logger)
 {
     _topicClient = topicClient ?? throw new ArgumentNullException(nameof(topicClient));
     _serializer  = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #16
0
 public DefaultServiceBusConnectionManager(IOptions <EventBusConnectionOptions> options)
 {
     if (options?.Value == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     ServiceBusConnectionStringBuilder = new ServiceBusConnectionStringBuilder(options.Value.TopicConnectionString);
     _topicClient = new TopicClient(ServiceBusConnectionStringBuilder, RetryPolicy.Default);
 }
예제 #17
0
 /// <summary>
 /// Creates a TopicClient which is used for all basic interactions with a Service Bus topic.
 /// </summary>
 /// <returns>Instance of TopicClient</returns>
 public ITopicClient CreateModel()
 {
     EnsureConnection();
     if (topicClient == null || topicClient.IsClosedOrClosing)
     {
         topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
     }
     return(topicClient);
 }
예제 #18
0
 public SymbolsMessageEnqueuer(
     ITopicClient topicClient,
     IBrokeredMessageSerializer <SymbolsValidatorMessage> serializer,
     TimeSpan?messageDelay)
 {
     _topicClient  = topicClient ?? throw new ArgumentNullException(nameof(topicClient));
     _serializer   = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _messageDelay = messageDelay;
 }
예제 #19
0
 public ServiceBusLifeCycleEventHub(
     string connectionString,
     string topicName,
     string subscriptionName,
     ILoggerFactory logFactory)
 {
     _subscriptionClient = new SubscriptionClient(connectionString, topicName, subscriptionName);
     _topicClient        = new TopicClient(connectionString, topicName);
     _logger             = logFactory.CreateLogger(GetType());
 }
예제 #20
0
        public Application(IOptions <AppSettings> appSettings, ILogger <Application> log)
        {
            _appSettings = appSettings.Value;
            _log         = log;

            _connString = _appSettings.PubEndpoint;
            _topicName  = _appSettings.TopicName;

            _topicClient = new TopicClient(_connString, _topicName);
        }
예제 #21
0
        public void GivenTopic_WhenAskingForClient_ThenItReturnsCorrectClient()
        {
            // arrange
            // act
            const string expected    = "topic";
            ITopicClient topicClient = ServiceBusTopic.Client(expected);

            // assert
            topicClient.TopicName.Should().Be(expected);
        }
예제 #22
0
        public DefaultServiceBusPersisterConnection(ServiceBusConnectionStringBuilder serviceBusConnectionStringBuilder,
                                                    ILogger <DefaultServiceBusPersisterConnection> logger)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
                                                 throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
            _topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
            Console.WriteLine($"Servicebus topic for client {_topicClient.TopicName} created");
        }
예제 #23
0
 internal ServiceBusEventBus(ISubscriptionClient subscriptionClient, ITopicClient topicClient, ServiceBusOptions serviceBusOptions,
                             ISubscriptionManager subscriptionManager, IHandlerResolver handlerResolver, ILogger <ServiceBusEventBus> logger)
 {
     _subscriptionClient  = subscriptionClient ?? throw new ArgumentNullException(nameof(subscriptionClient));
     _topicClient         = topicClient ?? throw new ArgumentNullException(nameof(topicClient));
     _serviceBusOptions   = serviceBusOptions ?? throw new ArgumentNullException(nameof(serviceBusOptions));
     _subscriptionManager = subscriptionManager ?? throw new ArgumentNullException(nameof(subscriptionManager));
     _handlerResolver     = handlerResolver ?? throw new ArgumentNullException(nameof(handlerResolver));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #24
0
        static async Task MainAsync()
        {
            client = new TopicClient(ServiceBusConnectionString, TopicName);

            // Send messagee //
            await SendMessagesAsync();

            System.Console.ReadKey();
            await client.CloseAsync();
        }
예제 #25
0
        static async Task MainAsync()
        {
            const int numberOfMessages = 5;

            topicClient = new TopicClient(serviceBusConnectionString, topicName);
            await SendMessagesAsync(numberOfMessages);

            Console.ReadKey();
            await topicClient.CloseAsync();
        }
        public DefaultServiceBusPersisterConnection(string serviceBusConnectionString, ILogger <DefaultServiceBusPersisterConnection> logger,
                                                    string topicName)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _topicName = topicName ?? throw new ArgumentNullException(nameof(topicName));
            ServiceBusConnectionStringBuilder = serviceBusConnectionString ?? throw new ArgumentNullException(nameof(serviceBusConnectionString));

            _topicClient = new TopicClient(ServiceBusConnectionStringBuilder, _topicName, RetryPolicy.Default);
        }
예제 #27
0
        private static async Task MainAsync()
        {
            const int numberOfMessages = 10;

            _topicClient = new TopicClient(ServiceBusConnectionString, TopicName);
            await SendMessageAsync(numberOfMessages);

            Console.ReadKey();
            await _topicClient.CloseAsync();
        }
예제 #28
0
        static async Task MainAsync()
        {
            topicClient = new TopicClient(ServiceBusConnectionString, TopicName);

            await SendMessagesAsync();

            Console.ReadKey();

            await topicClient.CloseAsync();
        }
        public ServiceBusMQClient(
            IConfiguration configuration,
            ILogger <ServiceBusMQClient> logger)
        {
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            var connectionString = configuration.GetConnectionString("ServiceBus") ?? throw new ArgumentNullException("ServiceBus connection string missing!");

            topicClient = new TopicClient(connectionString, TopicName);
        }
        private ITopicClient GetTopicClient()
        {
            if (_topicClient != null)
            {
                return(_topicClient);
            }

            _topicClient = _queueManager.CreateTopicSender(_topicPath).Result;
            return(_topicClient);
        }