I am trying to add a custom property to the BrokeredMessage.Properties
collection before sending it to the Azure Service Bus. The custom property type is an enum:
[Serializable, DataContract]
public enum FooBar
{
[EnumMember]
Foo = 0,
[EnumMember]
Bar = 1
}
I have also tried numerous combinations of the Attributes, and a version with no Attributes.
This is the code which adds the property and sends the message:
var brokeredMessage = new BrokeredMessage(new MessageObject(){ //etc });
brokeredMessage.Properties.Add("FooBar", FooBar.Foo);
queueClient.Send(brokeredMessage);
The following error is returned when attempting to send the message:
System.Runtime.Serialization.SerializationException : Serialization operation failed due to unsupported type Namespace.FooBar.
I've tried to track down some more detailed documentation on the BrokeredMessage.Properties
limitations (if any), and can't find anything which specifies that only primitive types can be used.
Any ideas as to why this doesn't work?
Edit:
Should have said I am using V2.1.0.0 of Microsoft.ServiceBus.
Overview of application Create Azure Service Bus Queue using Azure Portal. Create HTTP trigger Azure Function to send the message into Queue. Create a Service Bus Queue trigger Azure function to read a message from Queue.
Azure Service Bus premium tier stores metadata and data in regions that you select. When geo-disaster recovery is set up for an Azure Service Bus premium namespace, the metadata is copied over to the secondary region that you select.
Shortly, you can use only simple types like string, integers.
For your case, you can try two ways
Choose by you self, which one is better for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With