0

I have a listener that processes a message from a queue and then sends it to my response queue.

It seems to not through any errors, but the second message seem to silently fail because it never goes into the response queue.

try
{
    await using var sender = _serviceBusClient.CreateSender(queueName);
    var message = new ServiceBusMessage(messageContent);
    await sender.SendMessageAsync(message);

    _logger.LogInformation("Message sent successfully to {QueueName} at {Time}", queueName, DateTime.UtcNow);
    _logger.LogInformation("Sender state: Closed={Closed}, HasPending=Unknown", sender.IsClosed); // SDK doesn’t expose pending

    return true;
}
catch (ServiceBusException sbEx) when (sbEx.IsTransient)
{
    _logger.LogError(sbEx, "ServiceBusException while sending to {QueueName}. IsTransient: {IsTransient}",
        queueName, sbEx.IsTransient);
    System.Threading.Thread.Sleep(2000);
    return false;
}
catch (Exception ex)
{
    _logger.LogInformation($"Error sending message to service bus queue: {ex.Message}");
    return false;
}

I have registered my Servicebusclient as a singleton. I have another function that makes use of queue system, but it sends messages to queue with no disparity in messages being sent.

New contributor
Vin Mushwana is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Where is this code hosted, what service? Commented Nov 17 at 14:39
  • Its in azure. Its a function app that processes these queues Commented Nov 18 at 4:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.