public Resender(string connectionString, ResenderArguments a) : base(connectionString, EntityNameHelper.FormatDeadLetterPath(a.Type == BusType.Queue ? a.TopicQueueName : EntityNameHelper.FormatSubscriptionPath(a.TopicQueueName, a.Name))) { Sender = a.Type == BusType.Queue ? (ISenderClient) new QueueClient(connectionString, a.TopicQueueName) : new TopicClient(connectionString, a.TopicQueueName); }
public IMessageReceiverWrapper Get(string topicName, string subscriptionName, ReceiveMode receiveMode) { var subscriptionPath = EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName); var messageReceiver = new MessageReceiver(_connectionString, subscriptionPath, receiveMode, RetryPolicy.Default); return(new MessageReceiverWrapper(messageReceiver)); }
static async Task ReceiveMessagesAsync(string subscriptionName) { string subscriptionPath = EntityNameHelper.FormatSubscriptionPath(TopicName, subscriptionName); IMessageReceiver subscriptionReceiver = new MessageReceiver(ServiceBusConnectionString, subscriptionPath, ReceiveMode.ReceiveAndDelete); Console.WriteLine($"=========================================================================="); Console.WriteLine($"{DateTime.Now} :: Receiving Messages From Subscription: {subscriptionName}"); int receivedMessageCount = 0; while (true) { var receivedMessage = await subscriptionReceiver.ReceiveAsync(TimeSpan.Zero); if (receivedMessage != null) { object colorProperty; receivedMessage.UserProperties.TryGetValue("Color", out colorProperty); Console.WriteLine($"Color Property = {colorProperty}, CorrelationId = {receivedMessage.CorrelationId ?? receivedMessage.CorrelationId}"); receivedMessageCount++; } else { break; } } Console.WriteLine($"{DateTime.Now} :: Received '{receivedMessageCount}' Messages From Subscription: {subscriptionName}"); Console.WriteLine($"=========================================================================="); }
private void btnConnect_Click(object sender, RoutedEventArgs e) { //clear the messages since we're switching queues. _messages.Clear(); if (!string.IsNullOrWhiteSpace(tbxConnStrings.Text) && !string.IsNullOrWhiteSpace(tbxQueue.Text)) { try { string queueName = cbxDeadLetter.IsChecked.Value ? EntityNameHelper.FormatDeadLetterPath(tbxQueue.Text) : $"{tbxQueue.Text}"; queueClient = new QueueClient(tbxConnStrings.Text, queueName, ReceiveMode.PeekLock); RegisterOnMessageHandlerAndReceiveMessages(); MessageBox.Show("Connection Successful!"); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Connection String and Queue Name Required!", "Error!"); } }
public override async Task OpenAsync(string correlationId, List <ConnectionParams> connections, CredentialParams credential) { try { var connection = connections?.FirstOrDefault(); if (connection == null) { throw new ArgumentNullException(nameof(connections)); } _topicName = connection.GetAsNullableString("topic") ?? Name; _tempSubscriber = connection.Get("subscription") == null || connection.Get("Subscription") == null; _subscriptionName = connection.GetAsNullableString("subscription") ?? connection.Get("Subscription") ?? IdGenerator.NextLong(); // "AllMessages"; _connectionString = ConfigParams.FromTuples( "Endpoint", connection.GetAsNullableString("uri") ?? connection.GetAsNullableString("Endpoint"), "SharedAccessKeyName", credential.AccessId ?? credential.GetAsNullableString("shared_access_key_name") ?? credential.GetAsNullableString("SharedAccessKeyName"), "SharedAccessKey", credential.AccessKey ?? credential.GetAsNullableString("shared_access_key") ?? credential.GetAsNullableString("SharedAccessKey") ).ToString(); _namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString); _messageReceiver = new MessageReceiver(_connectionString, EntityNameHelper.FormatSubscriptionPath(_topicName, _subscriptionName)); } catch (Exception ex) { _namespaceManager = null; _logger.Error(correlationId, ex, $"Failed to open message topic '{Name}'."); } await Task.CompletedTask; }
string GetEntityPath(bool deadLetterQueue) { if (deadLetterQueue) { if (queueDescription != null) { return(EntityNameHelper.FormatDeadLetterPath(queueDescription.Path)); } else { var subscriptionPath = EntityNameHelper.FormatSubscriptionPath(subscriptionWrapper.TopicDescription.Path, subscriptionWrapper.SubscriptionDescription.SubscriptionName); return(EntityNameHelper.FormatDeadLetterPath(subscriptionPath)); } } else { if (queueDescription != null) { return(queueDescription.Path); } else { return(EntityNameHelper.FormatSubscriptionPath(subscriptionWrapper.TopicDescription.Path, subscriptionWrapper.SubscriptionDescription.SubscriptionName)); } } }
public override MessageContext ReceiveOnTopic(MessageContext inputcontext, IMessageAdapter adapter) { var entity = EntityNameHelper.FormatSubscriptionPath(inputcontext.ToReplyPath, inputcontext.ToReplySubscription); var client = new SessionClient(inputcontext.ToReplyConnectionString, entity); var messagesession = client.AcceptMessageSessionAsync(inputcontext.ReplyToRequestId).GetAwaiter().GetResult(); var message = inputcontext.ToReplyTimeOut != 0 ? messagesession.ReceiveAsync(TimeSpan.FromSeconds(inputcontext.ToReplyTimeOut)).GetAwaiter().GetResult() : messagesession.ReceiveAsync().GetAwaiter().GetResult(); MessageContext outputcontext = null; if (message != null) { outputcontext = adapter.Read(message, inputcontext.ResultType); messagesession.CompleteAsync(message.SystemProperties.LockToken); } messagesession.CloseAsync().GetAwaiter().GetResult(); client.CloseAsync().GetAwaiter().GetResult(); return(outputcontext); }
async Task TopicClientPeekLockWithDeadLetterTestCase(string topicName, int messageCount = 10) { var topicClient = new TopicClient(TestUtility.NamespaceConnectionString, topicName); var subscriptionClient = new SubscriptionClient( TestUtility.NamespaceConnectionString, topicName, this.SubscriptionName); // Create DLQ Client To Receive DeadLetteredMessages var subscriptionDeadletterPath = EntityNameHelper.FormatDeadLetterPath(this.SubscriptionName); var deadLetterSubscriptionClient = new SubscriptionClient( TestUtility.NamespaceConnectionString, topicName, subscriptionDeadletterPath); try { await this.PeekLockWithDeadLetterTestCase( topicClient.InnerSender, subscriptionClient.InnerSubscriptionClient.InnerReceiver, deadLetterSubscriptionClient.InnerSubscriptionClient.InnerReceiver, messageCount); } finally { await deadLetterSubscriptionClient.CloseAsync(); await topicClient.CloseAsync(); await subscriptionClient.CloseAsync(); } }
/// <summary> /// Tries receiving a single dead lettered message on the Azure Service Bus dead letter queue. /// </summary> /// <param name="connectionString">The connection string to connect to the Azure Service Bus.</param> public async Task AssertDeadLetterMessageAsync(string connectionString) { var connectionStringBuilder = new ServiceBusConnectionStringBuilder(connectionString); connectionStringBuilder.EntityPath = EntityNameHelper.FormatDeadLetterPath(connectionStringBuilder.EntityPath); var messageReceiver = new MessageReceiver(connectionStringBuilder, ReceiveMode.ReceiveAndDelete); try { bool received = false; messageReceiver.RegisterMessageHandler( async(message, ct) => { received = true; _logger.LogInformation("Received dead lettered message in test suite"); await messageReceiver.CompleteAsync(message.SystemProperties.LockToken); }, new MessageHandlerOptions(exception => { _logger.LogError(exception.Exception, "Failure during receiving dead lettered messages"); return(Task.CompletedTask); })); Policy.Timeout(TimeSpan.FromMinutes(2)) .Wrap(Policy.HandleResult <bool>(result => !result) .WaitAndRetryForever(i => TimeSpan.FromSeconds(1))) .Execute(() => received); } finally { await messageReceiver.CloseAsync(); } }
public static IHealthBuilder AddAzureServiceBusTopicSubscriptionDeadLetterQueueCheck( this IHealthCheckBuilder builder, string name, string connectionString, string topicName, string subscriptionName, long deadLetterWarningThreshold = 1, long?deadLetterErrorThreshold = null) { if (deadLetterErrorThreshold.HasValue && (deadLetterWarningThreshold > deadLetterErrorThreshold)) { throw new ArgumentException("Error threshold must exceed warning threshold", nameof(deadLetterErrorThreshold)); } var managementClient = new ManagementClient(connectionString); builder.AddCheck( name, ServiceBusHealthChecks.CheckDeadLetterQueueCount(Logger, EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName), name, GetQueueMessageCount, deadLetterWarningThreshold, deadLetterErrorThreshold)); return(builder.Builder); async Task <MessageCountDetails> GetQueueMessageCount() { var info = await managementClient.GetSubscriptionRuntimeInfoAsync(topicName, subscriptionName); return(info.MessageCountDetails); } }
public MessageReceiver GetTopicDeadLetterClient() { string subscriptionPath = EntityNameHelper.FormatSubscriptionPath(_config.Topic, _config.Subscription); string deadLetterPath = EntityNameHelper.FormatDeadLetterPath(subscriptionPath); return(new MessageReceiver(_config.Connection, deadLetterPath, ReceiveMode.PeekLock, RetryPolicy.Default, 0)); }
public async Task DeadletterMessage(string connectionString, string topicPath, string subscriptionPath, Message message) { var path = EntityNameHelper.FormatSubscriptionPath(topicPath, subscriptionPath); var receiver = new MessageReceiver(connectionString, path, ReceiveMode.PeekLock); while (true) { var messages = await receiver.ReceiveAsync(_maxMessageCount); if (messages == null || messages.Count == 0) { break; } var foundMessage = messages.FirstOrDefault(m => m.MessageId.Equals(message.MessageId)); if (foundMessage != null) { await receiver.DeadLetterAsync(foundMessage.SystemProperties.LockToken); break; } } await receiver.CloseAsync(); }
public async Task <long> PurgeMessages(string connectionString, string topicPath, string subscriptionPath, bool isDlq) { var path = EntityNameHelper.FormatSubscriptionPath(topicPath, subscriptionPath); path = isDlq ? EntityNameHelper.FormatDeadLetterPath(path) : path; long purgedCount = 0; var receiver = new MessageReceiver(connectionString, path, ReceiveMode.ReceiveAndDelete); var operationTimeout = TimeSpan.FromSeconds(5); while (true) { var messages = await receiver.ReceiveAsync(_maxMessageCount, operationTimeout); if (messages == null || messages.Count == 0) { break; } purgedCount += messages.Count; } await receiver.CloseAsync(); return(purgedCount); }
public async Task Capture_Transaction_When_Receive_From_Topic_Subscription() { await using var scope = await TopicScope.CreateWithTopicAndSubscription(_adminClient); var sender = new MessageSender(_environment.ServiceBusConnectionString, scope.TopicName); var receiver = new MessageReceiver(_environment.ServiceBusConnectionString, EntityNameHelper.FormatSubscriptionPath(scope.TopicName, scope.SubscriptionName)); await sender.SendAsync( new Message(Encoding.UTF8.GetBytes("test message"))).ConfigureAwait(false); await receiver.ReceiveAsync(TimeSpan.FromSeconds(30)).ConfigureAwait(false); if (!_sender.WaitForTransactions(TimeSpan.FromMinutes(2))) { throw new Exception("No transaction received in timeout"); } _sender.Transactions.Should().HaveCount(1); var transaction = _sender.FirstTransaction; var subscription = $"{scope.TopicName}/Subscriptions/{scope.SubscriptionName}"; transaction.Name.Should().Be($"{ServiceBus.SegmentName} RECEIVE from {subscription}"); transaction.Type.Should().Be(ApiConstants.TypeMessaging); transaction.Context.Message.Should().NotBeNull(); transaction.Context.Message.Queue.Should().NotBeNull(); transaction.Context.Message.Queue.Name.Should().Be(subscription); }
///<inheritdoc/> public override async Task <bool> InitializeAsync() { bool result = await base.InitializeAsync(); if (!result) { return(false); } Dictionary <string, object> parameters = new Dictionary <string, object>() { { nameof(Card.DeckId), Entity.DeckId } }; ApiReply <List <PracticeHistoryEntry> > reply = await ApiConnector.GetAsync <PracticeHistoryEntry>(parameters); if (!reply.WasSuccessful) { NotificationMessageProvider.ShowErrorMessage(reply.ResultMessage); return(false); } PracticeHistoryEntries.AddRange(reply.Result); SelectableDisplayUnits.Add(EntityNameHelper.GetName <Deck>()); SelectableDisplayUnits.AddRange(Entity.Cards.Select(card => card.GetDisplayName())); foreach (Card card in Entity.Cards) { cardIdLookup.Add(card.GetDisplayName(), card.CardId); } SelectedDisplayUnit = SelectableDisplayUnits.First(); return(true); }
public async Task Subscribe(string endpointName, Action <IRoutableMessage> MessageHandler, Func <Exception, Task> ErrorHandler) { // Get the subscription information from the endpointName setting in the configuration file IApplicationSecretsConnectionStrings subscriber = _applicationSecrets.Secret(endpointName); string connectionString = subscriber.Value; string topicName = subscriber[Topic]; string subscriptionName = subscriber[Subscription]; string path = EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName); var receiver = new MessageReceiver(connectionString, path); receiver.RegisterMessageHandler( async(message, cancellationToken) => { await receiver.CompleteAsync(message.SystemProperties.LockToken); string body = Encoding.UTF8.GetString(message.Body); IRoutableMessage msg = body.MessageFromBus(); MessageHandler(msg); }, new MessageHandlerOptions(e => ErrorHandler(e.Exception)) { AutoComplete = false, MaxConcurrentCalls = 2 }); }
async Task TopicClientPeekLockWithDeadLetterTestCase(bool partitioned, bool sessionEnabled, int messageCount = 10) { await ServiceBusScope.UsingTopicAsync(partitioned, sessionEnabled, async (topicName, subscriptionName) => { var topicClient = new TopicClient(TestUtility.NamespaceConnectionString, topicName); var subscriptionClient = new SubscriptionClient( TestUtility.NamespaceConnectionString, topicName, subscriptionName); // Create DLQ Client To Receive DeadLetteredMessages var subscriptionDeadletterPath = EntityNameHelper.FormatDeadLetterPath(subscriptionName); var deadLetterSubscriptionClient = new SubscriptionClient( TestUtility.NamespaceConnectionString, topicName, subscriptionDeadletterPath); try { await this.PeekLockWithDeadLetterTestCase( topicClient.InnerSender, subscriptionClient.InnerSubscriptionClient.InnerReceiver, deadLetterSubscriptionClient.InnerSubscriptionClient.InnerReceiver, messageCount); } finally { await deadLetterSubscriptionClient.CloseAsync(); await topicClient.CloseAsync(); await subscriptionClient.CloseAsync(); } }); }
private static async Task MainAsync() { var client = new QueueClient("<connection-string>", "myfirstqueue"); client.RegisterSessionHandler((session, message, ct) => Task.FromResult(new SessionHandler()), args => Task.CompletedTask); var receiver = new MessageReceiver( "<connection-string>", "myfirstqueue"); while (true) { var message = await receiver.ReceiveAsync(); if (message == null) { continue; } Console.WriteLine($"New message: [{message.ScheduledEnqueueTimeUtc}] {Encoding.UTF8.GetString(message.Body)}"); await receiver.DeadLetterAsync(message.SystemProperties.LockToken, "HandsOnAzure - test"); await Task.Delay(100); var dtqname = EntityNameHelper.FormatDeadLetterPath("myfirstqueue"); } }
public static async Task ListenToTopicSubscriptionsPrefetchAsync(string ConnectionString, string TopicName, string SubscriptionName) { var receiver = new MessageReceiver(ConnectionString, EntityNameHelper.FormatSubscriptionPath(TopicName, SubscriptionName), ReceiveMode.ReceiveAndDelete, null, 0); receiver.PrefetchCount = 100; while (true) { try { // Browse messages from queue var message = await receiver.ReceiveAsync(); // If the returned message value is null, we have reached the bottom of the log if (message != null) { ProcessMessages(message, Color.White); } else { // We have reached the end of the log. break; } } catch (ServiceBusException e) { if (!e.IsTransient) { Console.WriteLine(e.Message); throw; } } } await receiver.CloseAsync(); }
public async Task <List <DeadLetterQueueMessage> > GetSubscriptionMessages(string topicName, string subscriptionName) { var deadLetterName = EntityNameHelper.FormatDeadLetterPath(EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName)); var messages = await GetMessages(deadLetterName); return(messages); }
async Task DeadLetterFireEvents() { await ServiceBusScope.UsingQueueAsync(partitioned : false, sessionEnabled : false, async queueName => { this.queueClient = new QueueClient(TestUtility.NamespaceConnectionString, queueName, ReceiveMode.PeekLock); await TestUtility.SendMessagesAsync(this.queueClient.InnerSender, 1); var messages = await TestUtility.ReceiveMessagesAsync(this.queueClient.InnerReceiver, 1); this.listener.Enable((name, queue, arg) => name.Contains("DeadLetter")); await TestUtility.DeadLetterMessagesAsync(this.queueClient.InnerReceiver, messages); this.listener.Disable(); QueueClient deadLetterQueueClient = null; try { deadLetterQueueClient = new QueueClient(TestUtility.NamespaceConnectionString, EntityNameHelper.FormatDeadLetterPath(this.queueClient.QueueName), ReceiveMode.ReceiveAndDelete); await TestUtility.ReceiveMessagesAsync(deadLetterQueueClient.InnerReceiver, 1); } finally { deadLetterQueueClient?.CloseAsync().Wait(TimeSpan.FromSeconds(maxWaitSec)); } Assert.True(this.events.TryDequeue(out var deadLetterStart)); AssertDeadLetterStart(queueName, deadLetterStart.eventName, deadLetterStart.payload, deadLetterStart.activity, null); Assert.True(this.events.TryDequeue(out var deadLetterStop)); AssertDeadLetterStop(queueName, deadLetterStop.eventName, deadLetterStop.payload, deadLetterStop.activity, deadLetterStart.activity); Assert.True(this.events.IsEmpty); }); }
public async Task <List <DeadLetterQueueMessage> > GetQueueMessages(string queueName) { var deadLetterName = EntityNameHelper.FormatDeadLetterPath(queueName); var messages = await GetMessages(deadLetterName); return(messages); }
public async virtual Task RequeueAllDeadLettersAsync(string filter = null) { _logger?.LogDebug($"Requeuing messages to {QueueName}."); var queueClient = new QueueClient(ConnectionString, QueueName); var deadQueuePath = EntityNameHelper.FormatDeadLetterPath(QueueName); var deadQueueReceiver = new MessageReceiver(ConnectionString, deadQueuePath); var messages = await deadQueueReceiver.ReceiveAsync(100, new System.TimeSpan(0, 0, 10)); var remainingMessages = new List <Message>(); var targetMessages = new List <Message>(); while (messages != null && messages.Any()) { targetMessages.AddRange(string.IsNullOrWhiteSpace(filter) ? messages.ToList() : messages.AsQueryable().Where(filter).ToList()); remainingMessages.AddRange(messages.Where(a => !targetMessages.Exists(b => b.SystemProperties.LockToken == a.SystemProperties.LockToken))); messages = await deadQueueReceiver.ReceiveAsync(100, new System.TimeSpan(0, 0, 10)); } remainingMessages.ForEach(a => deadQueueReceiver.AbandonAsync(a.SystemProperties.LockToken)); targetMessages.ToList().ForEach(async a => { await queueClient.SendAsync(a.Clone()); await deadQueueReceiver.CompleteAsync(a.SystemProperties.LockToken); }); }
public async Task Capture_Transaction_When_ReceiveDeferred_From_Topic_Subscription() { await using var scope = await TopicScope.CreateWithTopicAndSubscription(_adminClient); var sender = new MessageSender(_environment.ServiceBusConnectionString, scope.TopicName); var receiver = new MessageReceiver(_environment.ServiceBusConnectionString, EntityNameHelper.FormatSubscriptionPath(scope.TopicName, scope.SubscriptionName)); await sender.SendAsync( new Message(Encoding.UTF8.GetBytes("test message"))).ConfigureAwait(false); var message = await receiver.ReceiveAsync(TimeSpan.FromSeconds(30)).ConfigureAwait(false); await receiver.DeferAsync(message.SystemProperties.LockToken).ConfigureAwait(false); await receiver.ReceiveDeferredMessageAsync(message.SystemProperties.SequenceNumber).ConfigureAwait(false); if (!_sender.WaitForTransactions(TimeSpan.FromMinutes(2), count: 2)) { throw new Exception("No transaction received in timeout"); } _sender.Transactions.Should().HaveCount(2); var transaction = _sender.FirstTransaction; transaction.Name.Should().Be($"{ServiceBus.SegmentName} RECEIVE from {scope.TopicName}/Subscriptions/{scope.SubscriptionName}"); transaction.Type.Should().Be(ApiConstants.TypeMessaging); var secondTransaction = _sender.Transactions[1]; secondTransaction.Name.Should().Be($"{ServiceBus.SegmentName} RECEIVEDEFERRED from {scope.TopicName}/Subscriptions/{scope.SubscriptionName}"); secondTransaction.Type.Should().Be(ApiConstants.TypeMessaging); }
private IAsyncResult BeginCreateLink(TimeSpan timeout, AsyncCallback callback, object state) { IList <AmqpDescribed> amqpDescribeds = this.CreateFilters(); string str = (!string.IsNullOrWhiteSpace(base.PartitionId) ? EntityNameHelper.FormatPartitionReceiverPath(this.entityName, base.PartitionId) : this.entityName); return(this.messagingFactory.BeginOpenEntity(this, str, this.EntityType, this.PrefetchCount, this.sessionId, this.sessionReceiver, base.Mode, amqpDescribeds, base.Epoch, timeout, callback, state)); }
public async Task DeleteMessage(string connectionString, string queue, Message message, bool isDlq) { var path = isDlq ? EntityNameHelper.FormatDeadLetterPath(queue) : queue; var receiver = new MessageReceiver(connectionString, path, ReceiveMode.PeekLock); while (true) { var messages = await receiver.ReceiveAsync(_maxMessageCount); if (messages == null || messages.Count == 0) { break; } var foundMessage = messages.FirstOrDefault(m => m.MessageId.Equals(message.MessageId)); if (foundMessage != null) { await receiver.CompleteAsync(foundMessage.SystemProperties.LockToken); break; } } await receiver.CloseAsync(); }
public void Create_Dead_Letter_Message_Receiver_With_Expected_NonDefault_Properties() { var config = new MyEndpointHandlingConfig { ConnectionString = "Endpoint=sb://your-sb.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=", EntityPath = "unittests.singlemessagetype/Subscriptions/MessageReceiverFactoryShould", MaxConcurrentCalls = 2, MaxAutoRenewDurationSeconds = 60, AutoComplete = true, }; var expectedServiceBusEndpoint = "sb://your-sb.windows.net/"; var expectedDeadLetterPath = EntityNameHelper.FormatDeadLetterPath(config.EntityPath); var expectedReceiveMode = ReceiveMode.ReceiveAndDelete; var expectedRetryPolicy = new NoRetry(); var expectedPrefetchCount = 1; var messageReceiver = _messageReceiverFactory.CreateDeadLetterMessageReceiver(config, expectedReceiveMode, expectedRetryPolicy, expectedPrefetchCount); (messageReceiver as MessageReceiver).ServiceBusConnection.Endpoint.Should().Be(expectedServiceBusEndpoint); (messageReceiver as MessageReceiver).Path.Should().Be(expectedDeadLetterPath); (messageReceiver as MessageReceiver).ReceiveMode.Should().Be(expectedReceiveMode); (messageReceiver as MessageReceiver).RetryPolicy.Should().Be(expectedRetryPolicy); (messageReceiver as MessageReceiver).PrefetchCount.Should().Be(expectedPrefetchCount); }
//https://github.com/Azure/azure-service-bus/blob/master/samples/DotNet/Microsoft.Azure.ServiceBus/ReceiveSample/readme.md public AzureServiceBusTopicReceiver(string connectionString, string topicName, string subscriptionName, bool peekLock = true, MessageHandlerOptions handlerOptions = null) : base( CreateClient(connectionString, topicName, subscriptionName, peekLock), CreateMessageReceiver(connectionString, EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName), peekLock), handlerOptions) { }
public IMessageReceiver Create(string serviceBusConnectionString, string topicName, string subscriptionName, bool dlqMode) { Validate(subscriptionName); Validate(serviceBusConnectionString); Validate(topicName); if (conn == null) { conn = new ServiceBusConnection(new ServiceBusConnectionStringBuilder(serviceBusConnectionString)); } var path = EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName); if (dlqMode) { path += "/$deadletterqueue"; } return(new MessageReceiver( conn, path, ReceiveMode.PeekLock, new RetryExponential( BackoffMin, BackoffMax, ReceiverRetryCount), ReceiverBatchSize)); }
/// <summary> /// Constructor /// </summary> /// <param name="navigationManager">NavigationManager (Injected)</param> /// <param name="apiConnector">ApiConnector (Injected)</param> public DeckSearchViewModel(NavigationManager navigationManager, IApiConnector apiConnector) : base(navigationManager, apiConnector) { PracticeDeckCommand = new NavigationCommand(navigationManager) { CommandText = Messages.Practice, IsRelative = true, IsEnabledFunction = (parameter) => (parameter as Deck).CardCount > 0, ToolTip = Messages.PracticeCommandToolTip.FormatWith(EntityNameHelper.GetName <Deck>()), TargetUriFactory = (param) => $"/{(param as Deck).DeckId}/Practice" }; AddCardCommand = new NavigationCommand(navigationManager) { CommandText = Messages.NewCard, IsRelative = true, ToolTip = Components.Messages.NewCommandToolTip.FormatWith(EntityNameHelper.GetName <Card>()), TargetUriFactory = (param) => $"/{(param as Deck).DeckId}/Cards/New" }; ShowStatisticsCommand = new NavigationCommand(navigationManager) { CommandText = Messages.PracticeStatistics, IsRelative = true, ToolTip = Messages.ShowStatisticsCommandToolTip.FormatWith(EntityNameHelper.GetName <Deck>()), TargetUriFactory = (param) => $"/{(param as Deck).DeckId}/Statistics" }; }