Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

How to properly complete session message?

$
0
0

Other info

  • Sessions enabled in queue

Recipient (full dotnet 4.6.2)

Task OnStart() {
    var factory = MessagingFactory.CreateFromConnectionString(Settings.ConnectionString);
    var queueClient = factory.CreateQueueClient(Settings.RecipientQueue, ReceiveMode.PeekLock);
    var options = new SessionHandlerOptions()
    {
          AutoComplete = false,
          MaxConcurrentSessions = 1
    };
    queueClient.RegisterSessionHandler(typeof(SessionHandler), options);
}

...

class SessionHandler : IMessageSessionAsyncHandler {
...
    public async Task OnMessageAsync(MessageSession session, BrokeredMessage message)
    {
         await message.CompleteAsync();
    }
...
}

Publisher (dotnet core 2.1):

        public Task PublishAsync(string queueName, string eventName, object data)
        {
            var message = new Message
            {
                Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data)),
                SessionId = queueName,
                ReplyToSessionId = queueName,
                TimeToLive = TimeSpan.FromSeconds(30),
                ReplyTo = settings.RecipientQueue
            };
            return new MessageSender(connection, queueName).SendAsync(message);
        }

Actual Behavior

  1. Everything is OK when I'm using queues without SessionId and Session disabled
  2. User errors in Azure Portal Metrics when using queues with SessionId and Session enabled
  3. Exception: Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll ("A timeout has occurred during the operation. e786d05b-<numers>-404b-917b-<numbers>5b_G6"). Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll ("A timeout has occurred during the operation. e786d05b--404b-917b-5b_G6")
  4. Exception: Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll ("A timeout has occurred during the operation. TrackingId:<numbers>-3b64-4dc1-b9e5-<number>, SystemTracker:<message-bus-name>:queue:<queue-name>~<numbers>, Timestamp:<date-time>"). Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll

Expected Behavior

  1. Sessions works and no reason for errors in monitor

Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>