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.