1.1.1

Table Of Contents
Implement the AsyncEventListener Interface
Dene a class that implements the
http://www.vmware.com/support/developer/vfabric-sqlre/111-api/com/vmware/sqlre/callbacks/AsyncEventListener.html
interface. For example:
package user.application;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.ResultSetMetaData;
import java.util.Iterator;
import java.util.List;
import com.vmware.sqlfire.callbacks.AsyncEventListener;
import com.vmware.sqlfire.callbacks.Event;
public class TestAsyncEvenListener implements AsyncEventListener
{
private FileOutputStream fos;
public void close()
{
try {
this.fos.close();
}
catch (IOException e) {
//handle exception
}
}
public void init(String filePath)
{
try {
this.fos = new FileOutputStream(filePath);
}
catch (FileNotFoundException e) {
//handle exception
}
}
public boolean processEvents(List<Event> events)
{
try {
Iterator<Event> itr = events.iterator();
Event.Type evType = null;
for (Event event : events) {
ResultSetMetaData rsmd = event.getResultSetMetaData();
String schemaName = rsmd.getSchemaName(1 /*from column # 1*/);
String tableName = rsmd.getTableName(1 /*from column # 1*/);
evType = event.getType();
//The primary key could be either a single value for single column
// primary key or could be an Object[] in case of Composite primary
key.
//For tables without primary key defined, the value returned is a
Long
// which uniquely identifies the row. User can map rows
created/updated/deleted
199
Handling DML Events Asynchronously