Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8453

Re: Socket Input Adapter

$
0
0

Hello,

 

So if you are reading from a socket, you must have some way of:

1) Determining columns

2) Terminating a record (or message or line):

* Is there a delimiter in the data signifying the end of message?

* Is the data a fixed length?

* Do you read the data one character at a time and keep appending to form a message until you hit some kind of end of message marker?

   InputStreamReader (Java Platform SE 7 )

   BufferedReader (Java Platform SE 7 )

   DataInputStream (Java Platform SE 7 )

 

ESP's TCP Socket Input Adapter reads a byte buffer (of size determined by the "inputBufferSize" parameter. See: Socket CSV Input Adapter Studio Properties ).  I think the closest publicly available example (including source code) of how this is done is the $ESP_HOME/adapters/framework/examples/streaming_input adapter.  This particular example reads from a file rather than a socket but it is fairly close.


It reads a byte stream from an XML file and sends this byte buffer to the next module using the ESP Toolkit Adapter API's:

     utility.sendRowsBuffer(ByteBuffer.wrap(buf, 0, iRead));

See the following example:

     $ESP_HOME/adapters/framework/examples/src/com/sybase/esp/adapter/framework/examplemodules/ExampleStreamingInputTransporter.java

 

Then the next module in line has to parse XML elements from the byte buffer and forms a record (AepRecord) to send to the next module:

    $ESP_HOME/adapters/framework/examples/src/com/sybase/esp/adapter/framework/examplemodules/ExampleStreamingInputFormatter.java

 

The last module in line gets the AepRecord and publishes it to the ESP project.  See:

     $ESP_HOME/adapters/framework/examples/src/com/sybase/esp/adapter/framework/examplemodules/ExampleEspInputTransporter.java

 

In your data I see a pipe symbol (|) delimits the columns.

 

But how are you determining when one record/message ends and the next begins?  Counting the number of columns?


Viewing all articles
Browse latest Browse all 8453

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>