Open csantos opened 8 years ago
This seems really similar to my ask here in #801
you could create your own MessageProcessor implementation. But I don't think this will solve the problem - pretty sure you can't read-then-reset the value of the MessageBody, so you couldn't force the custom/header properties into the body such that it would get de-serialized into your type by the framework.
Here's the scenario. I would like to tap into how the SDK converts the BrokeredMessage into the type of the job function parameter. Looking at ServiceBusTriggerAttributeBindingProvider, it has a hard code list of IQueueTriggerArgumentBindingProviders which the ServiceBusTriggerBinding will use to do the binding. ServiceBusTriggerBinding also has the notion of using IObjectToTypeConverter but that is also hard coded to a finite list of converters.
If I could add my own binding or converter, I would be able to have a base type that has properties common to all of our bus messages that map to items in the BrokeredMessage.Properties dictionary without forcing the writers of the web job functions to dip into the dictionary directly. Essentially I want to be able to write a WebJobs functions with a signature like:
public static void HandleMessage([ServiceBusTrigger("myqueue")] MyMessage myMessage) { Console.WriteLine(myMessage.MyHeaderProperty); }
Versus having to write code like
public static void HandleMessage([ServiceBusTrigger("myqueue")] BrokeredMessage brokeredMessage) { var myHeaderProperty = brokeredMessage.Properties["MyHeaderProperty"] as string; Console.WriteLine(myHeaderProperty); }
This is a real simplistic view of things but we have a few common header properties and having to dig into the dictionary all the time isn't as clean as it could be.