public class XStreamOut
extends java.lang.Object
Here is an example of using the callback API:
Connection conn;
XStreamOut xsOut;
...
// assume myLCRHandler implements XStreamLCRCallbackHandler and
XStreamLCRCallbackHandler hdlr = new MyLCRHandler();
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci:@hostname:port:sid",
"strmadm", "strmadm");
xsOut = XStreamOut.attach(conn, new String("APPLY1"),
lastPosition,
XStreamOut.ATTACH_APP_CONTAINER_MODE +
XStreamOut.ATTACH_EXTENDED_ID_MODE);
while(true)
{
xsOut.receiveLCRCallback(hdlr, XStreamOut.DEFAULT_MODE);
maintainWatermark();
...
if (user_terminate_condition)
{
break;
}
}
xsOut.detach(XStreamOut.DEFAULT_MODE);
}
}
catch(StreamsException e)
{
System.out.println("Streams exception: " + e.getMessage());
}
catch(Exception e)
{
}
Please see processLCR() and processChunk() in XStreamLCRCallbackHandler for examples of implementing the callback methods.Here is an example of using the non-callback API:
Connection conn;
XStreamOut xsOut;
...
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci:@hostname:port:sid",
"strmadm", "strmadm");
xsOut = XStreamOut.attach(conn, new String("APPLY1"),
lastPosition,
XStreamOut.ATTACH_APP_CONTAINER_MODE +
XStreamOut.ATTACH_EXTENDED_ID_MODE);
while(true)
{
LCR alcr = xsOut.receiveLCR(XStreamOut.DEFAULT_MODE);
if (xsOut.getBatchStatus == EXECUTING) // system is active
{
maintainWatermark();
// ... process LCR header
if (alcr instanceof RowLCR)
{
// ... process scalar columns
// process chunk data using receiveChunk() API
if (((RowLCR)alcr).hasChunkData())
{
do
{
ChunkColumnValue chunk = xsOut.receiveChunk(DEFAULT_MODE);
// process the Chunk
} while (!chunk.isEndOfRow())
}
}
}
else // system is idle
{
maintainWatermark();
if (user_terminate_condition)
{
break;
}
}
}
xsOut.detach(XStreamOut.DEFAULT_MODE);
}
}
catch(StreamsException e)
{
System.out.println("Streams exception: " + e.getMessage());
}
catch(Exception e)
{
}
| Modifier and Type | Field and Description |
|---|---|
static int |
ATTACH_APP_CONTAINER_MODE
This attach mode captures application container statements.
|
static int |
ATTACH_EXTENDED_ID_MODE
This attach mode returns transaction ID using extended format, "pdb_id.nn.nn.nn".
|
static int |
DEFAULT_BATCH_INTERVAL
XStreamOut default acknowledge interval value for batch processing
|
static int |
DEFAULT_IDLE_TIMEOUT
XStreamOut default timeout value for idle processing
|
static int |
DEFAULT_MODE
XStreamOut default mode
|
static int |
EXECUTING
XStreamOut batch processing status EXECUTING, which indicates the the batch is in progress
|
static int |
FINISHED
XStreamOut batch processing status FINISHED, which is the default status
|
static int |
NEW_COLUMN_ONLY_MODE
This column list mode allows users to receive LCRs with only new columns in the new value list.
|
| Modifier and Type | Method and Description |
|---|---|
static XStreamOut |
attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, byte[] lastPosition, int mode)
Attaches to outbound server.
|
static XStreamOut |
attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, byte[] lastPosition, int batchInterval, int idleTimeout, int mode)
Attaches to outbound server.
|
void |
detach(int mode)
Detaches from outbound server.
|
int |
getBatchStatus()
Gets batch status.
|
byte[] |
getFetchLowWatermark()
Gets fetch low watermark.
|
ChunkColumnValue |
receiveChunk(int mode)
Receives chunk data in non-callback mode.
|
LCR |
receiveLCR(int mode)
Receives one LCR in non-callback mode.
|
void |
receiveLCRCallback(XStreamLCRCallbackHandler handler, int mode)
Receives a stream of LCRs in callback mode.
|
void |
setProcessedLowWatermark(byte[] processedLowWatermark, byte[] oldestPosition, int mode)
Sets processed low watermark.
|
void |
setProcessedLowWatermark(byte[] processedLowWatermark, int mode)
Sets processed low watermark.
|
public static final int DEFAULT_MODE
public static final int NEW_COLUMN_ONLY_MODE
public static final int DEFAULT_BATCH_INTERVAL
public static final int DEFAULT_IDLE_TIMEOUT
public static final int FINISHED
public static final int EXECUTING
public static final int ATTACH_APP_CONTAINER_MODE
public static final int ATTACH_EXTENDED_ID_MODE
public static XStreamOut attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, byte[] lastPosition, int mode) throws StreamsException
oconn - Oracle database connection.serverName - Name of the XStream outbound server.lastPosition - Position that establishes the starting point of the stream. An exception is thrown if the specified position is non-NULL and less than the outbound server's processed low watermark. Otherwise, LCRs with positions greater than the specified position are sent to the client.mode - The mode of XStream outbound server (for future extension). Valid modes areStreamsException - if error occurs during attach.public static XStreamOut attach(oracle.jdbc.OracleConnection oconn, java.lang.String serverName, byte[] lastPosition, int batchInterval, int idleTimeout, int mode) throws StreamsException
oconn - Oracle database connection.serverName - name of the XStream outbound server.lastPosition - Position that establishes the starting point of the stream. An exception is thrown if the specified position is non-NULL and less than the outbound server's processed low watermark. Otherwise, LCRs with positions greater than the specified position are sent to the client.batchInterval - XStreamOut batch processing interval.idleTimeout - XStreamOut idle timeout value.mode - The mode of XStream outbound server (for future extension). Use XStreamOut.DEFAULT_MODE for now.StreamsException - if error occurs during attach.public void detach(int mode)
throws StreamsException
mode - The mode of XStream outbound server (for future extension). Use XStreamOut.DEFAULT_MODE for now.StreamsException - if error occurs during detach.public void receiveLCRCallback(XStreamLCRCallbackHandler handler, int mode) throws StreamsException
int mode = XStreamOut.DEFAULT_MODE | XStreamOut.COLUMN_NEW_ONLY_MODE;By default XStreamOut returns the union of new columns and old columns that are not present in the new column list.
handler - The XStreamLCRCallbackHandler for handling the LCRs.mode - A bit flag indicates the mode of XStream outbound server. There are two supported modes currently, DEFAULT_MODE and COLUMN_NEW_ONLY_MODEStreamsException - if error occurs during the entire batch.XStreamLCRCallbackHandlerpublic LCR receiveLCR(int mode) throws StreamsException
int mode = XStreamOut.DEFAULT_MODE | XStreamOut.COLUMN_NEW_ONLY_MODE;By default XStreamOut returns the union of new columns and old columns that are not present in the new column list.
mode - A bit flag indicates the mode of XStream outbound server . There are two supported modes currently, DEFAULT_MODE and COLUMN_NEW_ONLY_MODEStreamsException - if error occurs while receiving an LCRpublic ChunkColumnValue receiveChunk(int mode) throws StreamsException
mode - The mode of XStream outbound server (for future extension). Use XStreamOut.DEFAULT_MODE for now.StreamsException - If error occurs while receiving chunk data or constructing a ChunkColumnValue object.public int getBatchStatus()
public byte[] getFetchLowWatermark()
public void setProcessedLowWatermark(byte[] processedLowWatermark,
int mode)
throws StreamsException
processedLowWatermark - The client's processed low watermark.mode - The mode of XStream outbound server (for future extension). Use XStreamOut.DEFAULT_MODE for now.StreamsException - if error occurs while setting the low watermark.public void setProcessedLowWatermark(byte[] processedLowWatermark,
byte[] oldestPosition,
int mode)
throws StreamsException
processedLowWatermark - The client's processed low watermark.oldestPosition - The client's oldest position.mode - The mode of XStream outbound server (for future extension). Use XStreamOut.DEFAULT_MODE for now.StreamsException - if error occurs while setting the low watermark.