Author |
Message
|
mona |
Posted: Tue Jun 26, 2012 7:03 am Post subject: problem in TCP/IP |
|
|
Novice
Joined: 14 Mar 2012 Posts: 19
|
Hi
I want send Data from POS to MB7 with Dynamic Lenght,with this config:
POS----> TCPIP Server input -----> compute node------>TCPIP Server Receive ----->MQoutput
TCPIP Server input:
Record detection : Fix length
Length : 2
----------------
compute node:
SET OutputLocalEnvironment = InputLocalEnvironment;
SET OutputLocalEnvironment.TCPIP.Receive.Length =
CAST(InputRoot.BLOB.BLOB AS CHAR CCSID 1208);
---------------
TCPIP Server Receive:
Record detection : Fix length
Length : 0
--------------
but ,only 80 byte data recived and save in MQoutput.
can you help me? |
|
Back to top |
|
 |
Esa |
Posted: Tue Jun 26, 2012 7:31 am Post subject: Re: problem in TCP/IP |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
mona wrote: |
TCPIP Server Receive:
Record detection : Fix length
Length : 0
--------------
but ,only 80 byte data recived and save in MQoutput.
|
If you don't define the lenght, the node will obviously use the default record length, which is 80 bytes.
Have you tried record detection type 'Connection closed'? |
|
Back to top |
|
 |
mona |
Posted: Tue Jun 26, 2012 8:34 pm Post subject: |
|
|
Novice
Joined: 14 Mar 2012 Posts: 19
|
yes, if change the property of record detection to 'Connection clode', don't any data receive.
of course, I think problem in compute node code, because i got these error:
------------------------------
('.TCP_POS_HOSTFlow_Compute.Main', '7.9') Error detected whilst executing the SQL statement ''SET OutputLocalEnvironment.TCPIP.Receive.Length = CAST(InputRoot.BLOB.BLOB AS CHARACTER CCSID 1208);''.
The message broker detected an error whilst executing the given statement. An exception has been thrown to cut short the SQL program.
------------------------------
('.TCP_POS_HOSTFlow_Compute.Main', '8.13') : Error casting the value ''X'0080''' to ''CHARACTER''.
An error occurred when casting a value to a different data type. This may be because no conversions exist between the two data types or because the particular value was unsuitable.
Subsequent messages will indicate the context of the error.
------------------------------
Source character ''80'' in field ''0080'' cannot be converted to Unicode from codepage '1208'.
The source character is an invalid code point within the given codepage.
Correct the application that generated the message.
------------------------------
I don't know |
|
Back to top |
|
 |
Esa |
Posted: Tue Jun 26, 2012 11:32 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
So you are getting the lenght of the TCPIP message in InputRoot.BLOB.BLOB?
You should cast it to integer, not char. I'm not sure but you may even need to use a message set. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jun 27, 2012 4:04 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Here is some code that I've seen used to correctly format a fixed length header in a TCP/IP Message. The header is fixed length It contins the length of the data to follow in the stream.
Code: |
BEGIN
declare tcpHeader char;
declare tcpMsgLen integer;
declare stcpData BLOB ASBITSTREAM(InputRoot.XMLNSC CCSID 1208);
set tcpMsgLen = length(CAST(tcpData AS CHAR CCSID 1208));
set tcpHeader = '#' || left(cast(tcpMsgLen as char) || ' ',4);
set OutputRoot.Properties.MessageFormat = 'BLOB';
set OutputRoot.BLOB.BLOB = cast(tcpHeader as BLOB CCSID 1208) || tcpData;
RETURN TRUE;
END;
|
How the length is formatted (integer of char) depends upon how the endpoint agree to do it.
This next bit of code takes the fixed length part of the message (5 bytes) as read by a TCPServerInputNode and sets up the length param for a TCPServerReceive node to read.
Code: |
BEGIN
declare tcpDataLength char;
set tcpDataLength = cast(InputRoot.BLOB.BLOB as char CCSID 1208);
set OutputLocalEnvironment.TCPIP.Receive.Length = trim(right(tcpDataLength,4));
RETURN TRUE;
END;
|
The above code is an example. There are some obvious deficiencies that I won't point out but it can form the basis of a flow that uses TCPIP Communications. _________________ 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. |
|
Back to top |
|
 |
McueMart |
Posted: Wed Jun 27, 2012 5:30 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
You are incorrectly stating that the character set of the incoming blob (which encodes the payload length) is 1208. If you instead just use something like:
Code: |
SET OutputLocalEnvironment.TCPIP.Receive.Length =
CAST(TRANSLATE(CAST(InputRoot.BLOB.BLOB AS CHAR),'X''') AS INTEGER)
|
Does this work? |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jun 27, 2012 5:48 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
McueMart wrote: |
You are incorrectly stating that the character set of the incoming blob (which encodes the payload length) is 1208. If you instead just use something like:
Does this work? |
Which is why I said that there are some deficiencies...
The person who wrote it wasn't a very good coder let alone a tester but I just grabbed it as an example of a pretty standard way of handling variable length TCP/IP messages. _________________ 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. |
|
Back to top |
|
 |
McueMart |
Posted: Wed Jun 27, 2012 5:55 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Yes sorry, i wasn't referring to you smdavies when i said 'you are incorrectly stating...', i was referring to the OP
Cheers. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jun 27, 2012 2:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The OP is assigning the text to the length variable instead of assigning the length of the text to the length variable... Working as designed...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|