public class XStreamIn
extends java.lang.Object
Connection conn;
XStreamIn xsIn;
...
// assume myLCRHandler implements XStreamLCRCallbackHandler
XStreamLCRCallbackHandler hdlr = new MyLCRHandler();
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci:@hostname:port:sid",
"strmadm", "strmadm");
xsIn = XStreamIn.attach(conn, new String("APPLY1"), new String("CAP1"),
XStreamIn.DEFAULT_MODE);
while(true)
{
xsIn.sendLCRCallback(hdlr, XStreamIn.DEFAULT_MODE);
// maintain processed low watermark
maintainWatermark();
...
if (user_terminate_condition)
{
break;
}
}
xsIn.detach(XStreamIn.DEFAULT_MODE);
}
catch(StreamsException e)
{
System.out.println("Streams exception: " + e.getMessage());
}
catch(Exception e)
{
}
Please see createLCR() and createChunk() in XStreamLCRCallbackHandler for examples of implementing the callback methods.Here is an example of using the non-callback API:
Connection conn;
XStreamIn xsIn;
...
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci:@hostname:port:sid",
"strmadm", "strmadm");
xsIn = XStreamIn.attach(conn, new String("APPLY1"), new String("CAP1"),
XStreamIn.DEFAULT_MODE);
lwm = xsIn.getProcessedLowWatermark(XStreamIn.DEFAULT_MODE);
while(true)
{
RowLCR rowlcr = new DefaultRowLCR(...);
if (rowlcr has chunk data)
rowlcr.setChunkDataFlag(true);
int status = xsIn.sendLCR(rowlcr, XStreamIn.DEFAULT_MODE);
if (status == EXECUTING)
{
for (each chunk in each lob/long/xmltype column)
{
ChunkColumnValue chunk = new DefaultChunkColumnValue(...);
if (chunk is the last one in the column)
chunk.setLastChunk(true);
if (chunk is the last one for entire row)
chunk.setEndOfRow(true);
xsIn.sendChunk(chunk, XStreamIn.DEFAULT_MODE);
}
}
else // status == FINISHED
{
// maintain watermark
lwm = xsIn.getProcessedLowWatermark(XStreamIn.DEFAULT_MODE);
maintainWatermark();
}
if (user_terminate_condition)
{
break;
}
}
xsIn.detach(XStreamIn.DEFAULT_MODE);
}
catch(StreamsException e)
{
System.out.println("Streams exception: " + e.getMessage());
}
catch(Exception e)
{
}
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BATCH_INTERVAL
XStreamIn default batch interval value for batch processing
|
static int |
DEFAULT_MODE
XStreamIn default mode
|
static int |
EXECUTING
XStreamIn batch processing status EXECUTING, which indicates the the batch is in progress
|
static int |
FINISHED
XStreamIn batch processing status FINISHED, which is the default status
|
| Modifier and Type | Method and Description |
|---|---|
static XStreamIn |
attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, java.lang.String sourceName, int mode)
Attaches to an inbound server.
|
static XStreamIn |
attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, java.lang.String sourceName, int batchInterval, int mode)
Attaches to an inbound server.
|
byte[] |
detach(int mode)
Detaches from an inbound server.
|
void |
flush(int mode)
Flushes the network.
|
byte[] |
getLastPosition()
Gets last position.
|
byte[] |
getOldestPosition()
Gets the oldest position.
|
byte[] |
getProcessedLowWatermark()
Gets the processed low watermark.
|
void |
sendChunk(ChunkColumnValue chunk, int mode)
Sends chunk data in non-callback mode.
|
int |
sendLCR(LCR lcr, int mode)
Sends one LCR in non-callback mode.
|
void |
sendLCRCallback(XStreamLCRCallbackHandler handler, int mode)
Sends a stream of LCRs in callback mode.
|
public static final int DEFAULT_MODE
public static final int DEFAULT_BATCH_INTERVAL
public static final int FINISHED
public static final int EXECUTING
public static XStreamIn attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, java.lang.String sourceName, int mode) throws StreamsException
oconn - Oracle database connection.serverName - Name of the XStream inbound server.sourceName - Name of the data source.mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs during attach.public static XStreamIn attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, java.lang.String sourceName, int batchInterval, int mode) throws StreamsException
oconn - Oracle database connection.serverName - Name of the XStream inbound server.sourceName - Name of the data sourcebatchInterval - XStreamIn batch processing interval.mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs during attach.public byte[] detach(int mode)
throws StreamsException
mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs during detach.public void sendLCRCallback(XStreamLCRCallbackHandler handler, int mode) throws StreamsException
handler - The XStreamLCRCallbackHandler for constructing LCRs.mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs during the batch.public int sendLCR(LCR lcr, int mode) throws StreamsException
lcr - A constructed LCR.mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if the LCR is NULL or invalid, or error occurs while sending the LCR.public void sendChunk(ChunkColumnValue chunk, int mode) throws StreamsException
chunk - A ChunkColumnValue object that contains the chunk data for the LOB, LONG, or XMLTYPE column in a RowLCRmode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs while sending chunk data.public byte[] getProcessedLowWatermark()
attach
sendLCR
sendLCRCallback
flush
This method can be called while the client is attached to an XStream inbound server.public byte[] getOldestPosition()
attach
sendLCR
flush
This method can be called while the client is attached to an XStream inbound server.public byte[] getLastPosition()
public void flush(int mode)
throws StreamsException
mode - The mode of XStream inbound server (for future extension). Use XStreamIn.DEFAULT_MODE for now.StreamsException - if error occurs while flushing network.