Original Message:
Sent: Fri February 16, 2024 09:42 AM
From: Kareem Qureshi
Subject: How to parse a JSON message in Java compute node
Hi Francois,
MbElement envVariables = globalenv.getRootElement().getLastChild();
That works and we get Variables element but we need get this below element
-- Define JSON domain in Global Environment
CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON') TYPE Name NAME 'schedulerMessage';
-- Save the entire incoming request message
SET Environment.Variables.schedulerMessage = Root.JSON.Data;
globalenv.getRootElement().getLastChild().getLastChild() this is getting us "null"
Thanks in advance
------------------------------
Kareem Qureshi
Original Message:
Sent: Thu February 15, 2024 08:23 AM
From: Francois Brandelik
Subject: How to parse a JSON message in Java compute node
Instead of using
MbElement envVariables = globalenv.getRootElement().getFirstChild();
Have you tried using:
MbElement envVariables = globalenv.getRootElement().getLastChild();
And if you did what was the result?
------------------------------
Francois Brandelik
Original Message:
Sent: Wed February 14, 2024 05:07 PM
From: Kareem Qureshi
Subject: How to parse a JSON message in Java compute node
In our flow we are setting the following variables and then trying to access these variables in Java compute node that is the next node...
CREATE FILTER MODULE SchedulerInit_StoreRequest
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- Define JSON domain in Global Environment
CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON') TYPE Name NAME 'schedulerMessage';
-- Save the entire incoming request message
SET Environment.Variables.schedulerMessage = Root.JSON.Data;
-- continue normal processing
RETURN TRUE;
END;
END MODULE;
In the Java compute node
MbMessage globalenv = inAssembly.getGlobalEnvironment() ;
MbElement envVariables = globalenv.getRootElement().getFirstChild();
System.out.println("Element name is "+envVariables.getName()); -- prints "Element name is Variables"
But when I try to get this "Environment.Variables.schedulerMessage"
System.out.println("Element is "+envVariables.getFirstChild());
using the following it prints "Element is null" it should be schedulerMessage
I am not sure what am I missing here... it is quite annoying....
Can some one please point out the issue here...
Thanks in advance for the answer :-)
------------------------------
Kareem Qureshi
------------------------------