|
Oracle® Database XStream Java API Reference 11g Release 2 (11.2) E16674-02 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
oracle.streams.XStreamOut
public class XStreamOut
The XStreamOut class provides APIs for using Oracle XStream Out. This is the main Java API for Oracle XStream Out. It contains several main API methods as shown in the list.
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.DEFAULT_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.DEFAULT_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)
{
}
| Field Summary | |
|---|---|
static int |
DEFAULT_BATCH_INTERVALXStreamOut default acknowledge interval value for batch processing |
static int |
DEFAULT_IDLE_TIMEOUTXStreamOut default timeout value for idle processing |
static int |
DEFAULT_MODEXStreamOut default mode |
static int |
EXECUTINGXStreamOut batch processing status EXECUTING, which indicates the the batch is in progress |
static int |
FINISHEDXStreamOut batch processing status FINISHED, which is the default status |
static int |
NEW_COLUMN_ONLY_MODEThis column list mode allows users to receive LCRs with only new columns in the new value list. |
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Method Detail |
|---|
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). Use XStreamOut.DEFAULT_MODE for now.StreamsException - 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.XStreamLCRCallbackHandler
public 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 LCR
public 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.
|
Oracle® Database XStream Java API Reference 11g Release 2 (11.2) E16674-02 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||