.net6 to .net8 isolated process Service Bus IAsyncCollector replacement

Alistair Young 31 Reputation points
2024-05-08T13:25:53.9333333+00:00

To send a message to a queue via a binding I previously used in .net6:

[ServiceBus("thequeue", Connection = "ServiceBusConnection", EntityType = ServiceBusEntityType.Queue)] IAsyncCollector<ServiceBusMessage> outputQueue When trying to do the same in net8:

[Function(nameof(QueueHandler))] [ServiceBusOutput("%TestOutputQueueName%", Connection = "ServiceBusConnection")] public async Task<ServiceBusMessage> Run([ServiceBusTrigger("%TestInputQueueName%", Connection = "ServiceBusConnection", AutoCompleteMessages = false)] ServiceBusReceivedMessage message, ServiceBusReceiver receiver, ServiceBusMessageActions serviceBusMessageActions)

var outputMessage = new ServiceBusMessage { Body = BinaryData.FromString("testcontent"), MessageId = message.MessageId }; outputMessage.ApplicationProperties["RetryCount"] = "111"; IEnumerable<ServiceBusMessage> outputMessages = [outputMessage]; return outputMessage; The received message on the queue always has an empty Body but the RetryCount property is correct. Sending a primitive type from the function is of no use as I need to set properties on the message itself. I need to complete and then retry a failed message. The complete works fine. The sent message always has an empty body.

Is there a way to reproduce the net6 behaviour of IAsyncCollector?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
556 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alistair Young 31 Reputation points
    2024-05-10T14:41:36.9966667+00:00

    If I inject an IQueueClient I can send to that queue without relying on the old in-process way of doing it with IAsyncCollector

    0 comments No comments