Get Node Parent

#1

I am trying to get the node-id of the node that sent the msg being processed.

I can get the current node-id using this but I can't see how to directly get the parent node it this possible?

Thanks!

0 Likes

#2

Can I ask why? To quote @dceejay

In general nodes should not know or care about other nodes... that is one of the basic tenet for flow based programming... they should be a series of black boxes...

0 Likes

#3

Aside from the 'why' question, the simple answer is that information is not available to a node. It is just given the message to process.

0 Likes

#4

The why is because I am trying to track a msg's progress for analysis and reporting.

I know I could configure a node to report each msg but then I would have to configure each node so I can track the output and I am looking at potentially a hundred or more to maintain.

Is there a a way to get the current flow config?

0 Likes

#5

If you enable the 'metrics' option in the logging properties (or create a custom logger to just capture metrics rather than flood your main runtime log) you'll get events for each message passing in and out of each node. You can use that, to some degree, to track messages and see where time is being spent in a flow.

We have in the roadmap a feature to make the message routing a pluggable component - that would allow for custom code to be added to the message path and allow for more customised log/tracing of messages.

0 Likes

#6

Thanks!

I actually came up with a workable solutions. Probably not the most secure or portable method but it works...

I am reading the flows_*.json file and then parsing all content looking for the current node's ID in the wires section. Any node that includes a mention of the current node in the wires can send a msg to the current node and is a parent.

This then gives me the details of any parent and a specific location in the flow without having to configure every node I create.

0 Likes