A RepraClient interface example.
package com.sybase.connector.repra;
public interface RepraClient
{
/**
*configures the sender properties and connects the sender/receiver of the
*target messaging system.
*/
public void configureClient() throws Exception;
/**
*send out the rep messages to the connection.
*@param String repmsg the text stream of the XML document containing
*the metadata and replication event.
*/
public boolean sendEvent (Object repmsg) throws Exception;
/**
*return true if the connection is healthy.
*/
public boolean isReady();
/**
*close the client connection.
*/
public void close();
/**
*sets the default logger
*/
public void setLogger (RaLogger log);
}
package com.mycompany;
import com.sybase.connector.repra.RepraClient;
import com.sybase.connector.repra.logging.RaLogger;
import java.io.*;
public class SampleClient implements RepraClient
{
BufferedWriter _fout;
String _filename = "myCustomOut.dat"
// This method creates an instance of the BufferedWriter object
public void configureClient() throws Exception
{
_fout = new BufferedWriter(new FileWriter(_filename, true));
}
// You can do whatever you want in this method.
// This sample appends the String value of the message to the file.
public boolean sendEvent(Object repmsg) throws Exception
{
_fout.write(repmsg.toString(), 0, repmsg.toString().length());
_fout.newLine();
_fout.flush();
return true;
}
//It returns true if the client channel is ready.
//Otherwise, it returns false.
public boolean isReady()
{
if (_fout != null)
{
return true;
}
return false;
}
// This method closes the client channel.
public void close()
{
if (isReady())
{
try
{
_fout.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
// This method sets the default logger. In this sample, it
// does nothing.
public void setLogger(RaLogger log)
{
}
}