Sample implementation of the RepraClient interface

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)
     {
     }
}

StepsCompiling the customized sender processor

To compile your sender processor:

  1. Change to the directory of your sender processor.

  2. Use the Java compiler by defining the -classpath parameter with the required libraries to compile the customized class.

  3. Verify the compilation.

    When the compilation finishes without any error messages, go to the customclasses directory to see if SampleClient.class is under com\mycompany (Windows) or com/mycompany (UNIX).

StepsBuilding the runtime environment for the customized sender processor

To use a jar file that includes the customized sender processor, go to the customclasses directory and use the jar command to build a jar file from the com directory. Otherwise, you can use the directory path to set up your environment.

NoteSybase recommends that you use jar file format for the customization.

  1. Build a jar file.

NoteFor information on creating new custom sender and formatter classes, see “Creating new custom sender and custom formatter classes”.