Hi,
I have a business process C# step in a subscription message, where I would like to get the value of a custom property that is present in a parent message, in a published message.
How can i get this property using a C# statement?
It's probably quite easy, but I'm a newbee at Neuron and would appreciate any feedback
Thanks.
Tags:
Can you further describe your message flow? If you want a custom property from one message to be present on another message, you will have to read it from the first one and set it on the second one.
To get the value of a custom property in a C# step:
context.Data.GetProperty("<prefix>", <property_name>", <default_value>");
To set the value of a custom property in a C# step:
string value = context.Data.SetProperty("<prefix>", "<property_name>", <property_value>");
If you need to read the value of a custom property in one C# step, then apply it to a different message in a second C# step, you will need to save that value as a process property.
To set a process property:
context.Properties.Add("<property_name>", "<property_value>");
To get the value of a process property:
string value = context.Properties["<property_name>"];
I hope this helps!
Joe
Hi Joe, thanks for a very swift response.
Message flow is as follows:
1.C# client publish a message to the bus with a custom property.
2.Subsrciber Service endpoint is activated (REST call), and a reply is send back to the bus.
-In the On Publish event (for subscriber), I have a Business Process that saves the result from the REST call to a file. I need to use the custom property from step 1 to name the file.
I have attached a quick drawing of the process, thanks
Thanks for the details! This is fairly easy to do, albeit not very obvious. There is an ESBMessge header property called RequestHeadersToPreserve that is used to tell subscribers to save the value of a custom property on a request message and reapply it to the response message. You could actually set this in your C# client code. For example, if you have a property called Task.Filename, then use code similar to this:
myRequestMsg.Header.RequestHeadersToPreserve = "Task.Filename";
Then, in your OnPublish business process you can get the value of that custom property using the GetProperty("Task", "Filename") function on ESBMessage.
Let me know if this works for you,
Joe
This is perfect, thanks.
Very simple and easy to apply!
/Per
Neuron ESB Product Support Forums and Communities
© 2024 Created by Neuron Admin. Powered by