Posted: Tue Sep 04, 2012 6:42 am Post subject: Receiving variable length message over TCPIP
Novice
Joined: 01 May 2012 Posts: 15
Hi,
I have a message flow which sends data to remote host over TCPIPCLientOutput node and receives the response through TCPIPClientReceive node. The response is not a fixed length data but message length is sent in first four bytes. Also the remote host does not close the connection once it is done sending the response data. Now if I set property "Record Detection" of ClientReceive node as Closed Connection, it always times out and I cant set same to Parsed Record Sequence a I want to receive data in BLOB. Is there any way we can receive variable length data in BLOB format?....Is there any way I can use the first four bytes to know the length of response?. Any help is appreciated.
You don't say if the record is terminated by a delimiter. You should double-check that.
it's also dead-easy to create a message model that contains a 4 byte field and a blob string where the length of the blob is determined by the 4 byte field.
You could use two receive nodes. the first one reads the 4 byte binary message length. Using a transformation node you could set the message length property of the second TCPIPRECEIVE node dynamically with in the localenvironment tree structure.
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
PEPERO wrote:
You could use two receive nodes. the first one reads the 4 byte binary message length. Using a transformation node you could set the message length property of the second TCPIPRECEIVE node dynamically with in the localenvironment tree structure.
This is a pretty common scenario.
The 1st node gets the leght information and then after converting it into an integer puts it into the LocelEnvironment and passes it onto the the second node. something like this may do the job.
Code:
CREATE COMPUTE MODULE My_Flow_Extract_TCPIP_Length
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
declare cLength char;
set cLength = cast(InputRoot.BLOB.BLOB as char CCSID 1208);
set OutputLocalEnvironment.TCPIP.Receive.Length = trim(right(cLength,4));
RETURN TRUE;
END;
_________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Thanks Pepero....
Even I thought of same way and was succesfully able to test it as well. But I was not sure if its good way to have two receive nodes.
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