Neuron ESB User Network

The Service Bus for the Connected Business

Accessing custom property in parent message (C# step in business process)

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.

Views: 559

Reply to This

Replies to This Discussion

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

Attachments:

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

RSS

Neuron ESB Product Support Forums and Communities

Latest Activity

Anupama Nair posted a discussion

Marketo Adapter Invalid Token

Hi,We are using the Marketo adapter to push account updates to Marketo. It works well for some time then starts failing with Invalid Token unless restarted. Is there a configuration that can be done so it can auto refresh the token when required?Thanks!See More
Nov 6, 2023
Sayantini Basak posted a discussion

Maximum payload size(REST API) for requests interfacing to NeuronESB

I am new to Neuron ESB and in our current scenario,We need to process batch transactions comprising of ~1000 records and send them to Neuron ESB for further processing. I would like to understand what is the maximum size of payload that can be transferred using REST interface to Neuron ESB.See More
Jul 22, 2022
Profile IconRobert E Dunie and Sayantini Basak joined Neuron ESB User Network
Apr 28, 2022
Profile IconDayanand, Frederic C, Steffen Greve-Oksfeldt and 1 more joined Neuron ESB User Network
Mar 16, 2022
Profile IconCam Vong and Mitja Luznar joined Neuron ESB User Network
Jan 27, 2022
Profile IconWill Hitzges, Chad Parsons, michael larsen and 4 more joined Neuron ESB User Network
Jun 11, 2021
Anupama Nair posted a discussion

ODBC stored proc polling with temporary tables

We have set up an ODBC adapter to poll a stored proc.We found that if the stored proc has a temporary table defined the rows returned are always 0.Any idea why this would be and what we can do to get around it?See More
Dec 14, 2020
Prasanth Kharade is now a member of Neuron ESB User Network
Dec 30, 2019

Badge

Loading…

© 2024   Created by Neuron Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service