cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP Node JS Event Mesh Consume Message failed with payload chunks buffer

TinhLeo
Participant
0 Kudos
630

Hi Everyone,

I've posted a message to Event Mesh using httprest protocol like that

TinhLeo_0-1727509686093.png

With json payload

const messageData = {
                        "test": "test"
                    };
 
On EventMesh consumer apps istream 
.on("data", async (oMessage)
i got payload with payload.data is null but payload.chunks[0].data have data 
Step 0.1 Message: {"source":{"address":"default/test","reliable":true,"persistent":false,"redelivered":false},"target":{},"payload":{"chunks":[{"type":"Buffer","data":[123,34,116,101,115,116,34,58,34,116,101,115,116,34,125]}],"type":"application/json","encoding":null,"data":null,"properties":null}}
 
Then i'm trying to parse chunks buffer like that
TinhLeo_1-1727509941107.png

I've succcess parse message on BAS, VS Code with code of logic above (and real payload i got from BTP apps logs)

TinhLeo_0-1727510446323.png

 


 

but i got error  when i deployed to Cloud foundry

stacktrace":["TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined"," at Function.from (node:buffer:319:9)"," at IncomingStream.<anonymous>

Please give me advice

1. Do i need change some config, add any header, params... to post message to Queue with message.payload.data for consumer instead of message.payload.chunks[0].data

2. If can't post message to queue with payload to message.payload.data then how can i resolve Buffer parse error above?

FYI:

- Checked node version on BAS, VSCode, Cloud Foundry is same also, set node engines in package.json as well

TinhLeo_3-1727510101919.png

Thanks in advance

 

Accepted Solutions (0)

Answers (1)

Answers (1)

TinhLeo
Participant
0 Kudos

Hi everyone,

For point 2. i've resolved seam chunks[0] is buffer object

But still need solution and advice for point 1