Home > Software design >  Perform MessageActions on Messages for .Net 6 Isolated Worker ServiceBusTriggers
Perform MessageActions on Messages for .Net 6 Isolated Worker ServiceBusTriggers

Time:02-13

I want to be able to perform flexible actions on Service Bus Messages through a .Net 6 out-of-process ServiceBusTrigger. Actions include abandoning, completing, deferring, as well as dead-letter-queuing messages. I.e. the same actions that are available through the ServiceBusReceivedMessage and ServiceBusMessageActions bindings of the in-process ServiceBusTrigger.

However, out-of-process triggers seem only to be able to bind the message body as a string, as well as the FunctionContext. Are the described actions available for out-of-process triggers in some other way? If not, do you know if it's on the roadmap for near future releases?

Example of how the actions are available for in-process triggers:

[FunctionName(nameof(InProcessReceiver))]
public async Task RunAsync(
   [ServiceBusTrigger("%TOPIC_NAME%", "%SUB_NAME%", Connection="CONNECTION_NAME")] 
   ServiceBusReceivedMessage message,
   ServiceBusMessageActions messageActions
)
{
   await messageActions.DeadLetterMessageAsync(message);
   //await messageActions.AbandonMessageAsync(message);
   //await messageActions.CompleteMessageAsync(message);
   //await messageActions.DeferMessageAsync(message);
}

Example of out-of-process trigger, for which I want to do the same things as above

[Function(nameof(OutOfProcessReceiver))]
public async Task RunAsync(
   [ServiceBusTrigger("%TOPIC_NAME%", "%SUB_NAME%", Connection="CONNECTION_NAME")] 
   string mySbMsg
)
{   
   //How to access message actions and bind them to the current message here?          
}

As mentioned by the Microsoft team in this roadmap blog post, the future is isolated. Therefore I'm trying to avoid in-process, but I realize that it might be the only solution for now.

Thanks in advance!

CodePudding user response:

Are the described actions available for out-of-process triggers in some other way? If not, do you know if it's on the roadmap for near future releases?

At the moment it's not possible. Out of process/isolated worker SDK cannot pass to the Function native SDK types. There are a few related issues you can track for updates.

  • Related