|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
IIB10 - Problems retrieving JSON from Environment tree |
« View previous topic :: View next topic » |
Author |
Message
|
beefheart |
Posted: Mon Mar 13, 2023 8:39 am Post subject: IIB10 - Problems retrieving JSON from Environment tree |
|
|
Newbie
Joined: 13 Mar 2023 Posts: 2
|
Hello, how are you?
I am developing a message flow in the IIB version mentioned in the title.
Context:
I start by getting a set of database rows (15000 approx) via JDBC(Oracle 8i database) using a java compute node, and then I need to send it to an API endpoint split into 500 rows per message. So I iterate through the ResultSet and generate the required 500 row JSON files and output them to the Out terminal.
In the middle of that logic I need to store the message of 500 items, to get the URL to which the message will be sent (it is not a fixed URL, it is dynamically generated based on the name of the file to send -which I generate using an ESQL aggregating the timestamp of the sending time to the fixed name-).
To obtain this URL I need to make a request to an endpoint of the API we are working with, specifying in the body an attribute with the file name mentioned above.
To store the JSON file before generating the URL to send it to, I decided to use the Environment tree, saving it in its variables.
The problem I'm having is that, after generating the URL, when I get the JSON again from the Environment, the JSON is deformed, losing array brackets [], and generating unnecessary commas in the middle of attributes.
To save the JSON in Environment, I use an ESQL with the following line:
Code: |
SET Environment.JSON = InputRoot.JSON; |
To get it, I used another ESQL after getting the required URL by trying to use the following statements (there have been several attempts, all failed):
--------
Code: |
SET OutputRoot.JSON = Environment.JSON; |
--------
Code: |
CREATE LASTCHILD OF OutputRoot DOMAIN('JSON') PARSE(Environment.JSON);Â |
--------
Code: |
DECLARE messageBlob BLOB ASBITSTREAM(Environment.JSON, InputRoot.Properties.Encoding, InputRoot.Properties.CodedCharSetId );
CREATE LASTCHILD OF OutputRoot DOMAIN('JSON') PARSE(messageBlob , InputRoot.Properties.Encoding, InputRoot.Properties.CodedCharSetId ); |
--------
In all 3 cases I have had the same problems when I "reincorporate" the JSON body to the OutputRoot.
Examples of the given failure:
Created JSON object from the obtained data in JavaCompute:
Code: |
[
{
"case-item": {
"case-count": 1,
"dimensions": {
"height": 1e-3,
"length": 1e-3,
"unit-of-measure": "cm",
"width": 1e-3
},
"weight": { "unit-of-measure": "KG", "weight": 1e-1 }
},
"corp-ids": [],
"description": "ASADOBO SOBRE 10G. LA MANCHEGA",
"discontinued": true,
"ecom-ids": ["2363"],
"feature-attributes": {
"food-safety": "food",
"is-bulk": false,
"is-case-storage": false,
"is-chemical": false,
"is-crushable": false,
"is-egg": false,
"is-glass-packaged": false,
"is-hazardous": false,
"is-heavy": false,
"is-raw": false,
"is-specific-chilled": false,
"is-stackable": false,
"is-vertical": false,
"is-weight-variable-on-receipt": false
},
"image": "empty",
"item-address": {
"aisle": "",
"area": "",
"bay": "",
"position": "",
"shelf": ""
},
"item-type": "REG",
"mfc-id": "0044",
"mfc-stop-buy": true,
"mfc-stop-fulfill": false,
"min-remaining-shelf-life": 0,
"name": "nombre web",
"primary-corp-id": "",
"requires-expiration-date": true,
"retail-item": {
"weight": { "unit-of-measure": "KG", "weight": 1e-3 },
"dimensions": {
"height": 1e-3,
"length": 1e-3,
"unit-of-measure": "cm",
"width": 1e-3
}
},
"seasonal": false,
"shelf-life": 0,
"slotting-eligible": false,
"supplier-info": [
{
"supplier-id": "111",
"supplier-keep-buy": true,
"supplier-name": "TIENDA SUPPLIER",
"supplier-product-id": "00001",
"supplier-type": "DC"
}
],
"temperature-zone": ["ambient"],
"tom-id": "2363",
"custom-fields": [],
"barcodes": ["2363"],
"categories-hierarchy": [
{ "id": "1", "name": "COMESTIBLES" },
{ "id": "01", "name": "ALMACEN" },
{ "id": "0118", "name": "SALSAS, ADEREZOS Y CONDIMENTOS" },
{ "id": "011801", "name": "CONDIMENTOS" },
{ "id": "01180101", "name": "ADOBO ENVASADOS" }
]
}
] |
The same JSON saved and then recuperated from Environment:
Code: |
{
"": {
"case-item": {
"case-count": 1,
"dimensions": {
"height": 1e-3,
"length": 1e-3,
"unit-of-measure": "cm",
"width": 1e-3
},
"weight": { "unit-of-measure": "KG", "weight": 1e-1 }
},
"corp-ids": {},
"description": "ASADOBO SOBRE 10G. LA MANCHEGA",
"discontinued": true,
"ecom-ids": { "": "2363" },
"feature-attributes": {
"food-safety": "food",
"is-bulk": false,
"is-case-storage": false,
"is-chemical": false,
"is-crushable": false,
"is-egg": false,
"is-glass-packaged": false,
"is-hazardous": false,
"is-heavy": false,
"is-raw": false,
"is-specific-chilled": false,
"is-stackable": false,
"is-vertical": false,
"is-weight-variable-on-receipt": false
},
"image": "empty",
"item-address": {
"aisle": "",
"area": "",
"bay": "",
"position": "",
"shelf": ""
},
"item-type": "REG",
"mfc-id": "0044",
"mfc-stop-buy": true,
"mfc-stop-fulfill": false,
"min-remaining-shelf-life": 0,
"name": "nombre web",
"primary-corp-id": "",
"requires-expiration-date": true,
"retail-item": {
"weight": { "unit-of-measure": "KG", "weight": 1e-3 },
"dimensions": {
"height": 1e-3,
"length": 1e-3,
"unit-of-measure": "cm",
"width": 1e-3
}
},
"seasonal": false,
"shelf-life": 0,
"slotting-eligible": false,
"supplier-info": {
"": {
"supplier-id": "111",
"supplier-keep-buy": true,
"supplier-name": "TIENDA SUPPLIER",
"supplier-product-id": "00001",
"supplier-type": "DC"
}
},
"temperature-zone": { "": "ambient" },
"tom-id": "2363",
"custom-fields": {},
"barcodes": { "": "2363" },
"categories-hierarchy": {
"": { "id": "1", "name": "COMESTIBLES" },
"": { "id": "01", "name": "ALMACEN" },
"": { "id": "0118", "name": "SALSAS, ADEREZOS Y CONDIMENTOS" },
"": { "id": "011801", "name": "CONDIMENTOS" },
"": { "id": "01180101", "name": "ADOBO ENVASADOS" }
}
}
} |
Thanks for your time, best regards |
|
Back to top |
|
 |
mgk |
Posted: Mon Mar 13, 2023 8:51 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
|
Back to top |
|
 |
beefheart |
Posted: Tue Mar 14, 2023 10:00 am Post subject: |
|
|
Newbie
Joined: 13 Mar 2023 Posts: 2
|
Thank you very much for your reply! I was able to solve the problem by using the following lines of code when storing the message in Environment (which are already in the topic in case someone else has this problem in the future)
Code: |
DECLARE jsonMessage REFERENCE TO InputRoot.JSON;
DECLARE bodyBlob BLOB ASBITSTREAM(jsonMessage, 546, 1208);
DECLARE creationPtr REFERENCE TO Environment;
CREATE LASTCHILD OF creationPtr DOMAIN('JSON') PARSE(bodyBlob, 546, 1208); |
I used the encoding and ccid harcoded numbers since the message previously came from a java compute node which created a completely empty output assembly.
Thanks a lot! Best regards! |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 16, 2023 5:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Lot of work to marshal and unmarshal the data. It would have been easier and much more economical to create the parser in Environment and then just move the message tree...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|