6.3.1 Sending stream data (in-process connection custom adaptor)

This subsection explains the basic processing flow for using an in-process connection custom adaptor to send stream data, based on an implementation example.

Implementation example

public class Inpro_SendSample implements StreamInprocessUP {
 // Implement StreamInprocessUP.
 public void execute(SDPConnector con) {
   // 1. Connect to the input stream to be sent.
   StreamInput in = con.openStreamOutput("GROUP","STREAM1");

   // 2. Send tuples.
   Object[] data=new Object[]{new Integer(1)};
   StreamTuple tuple=new StreamTuple(data);
   in.put(tuple);

   // 3. Send data transmission completion notification.
   in.putEnd();

   // 4. Disconnect from the input stream.
   in.close();

   // 5. Disconnect from the SDP server.
   con.close();
 }
}

Explanation of the implementation details

The meaning of each process is explained below. The numbers correspond to the comment numbers in the implementation example.

  1. Uses the SDPConnector type object (con), which was passed as a parameter of the execute method, to connect to an input stream that has "GROUP" as its query group name and "STREAM1" as its stream name, and acquires the StreamInput type object (in).

    StreamInput in = con.openStreamInput("GROUP","STREAM1");

  2. Uses the StreamInput type object (in) to send tuples.

    in.put(tuple);

  3. Uses the StreamInput type object (in) to send a data transmission completion notification.

    in.putEnd();

  4. Uses the StreamInput type object (in) to disconnect from the input stream.

    in.close();

  5. Uses the SDPConnector type object to disconnect from the SDP server.

    con.close();