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

  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.

    cd /work/custom
    mkdir customclasses
    /usr/jdk141/bin/javac -classpath .:/opt/sybase/EAServer/repra/
    lib/repraconn.jar -d customclasses com/mycompany/SampleClient.java
    
  3. Verify the compilation.

    When the compilation finishes without any error messages, go to the customclasses directory to verify that SampleClient.class is under com/mycompany.

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.

    • For EAServer:

      1. Copy the jar file or the directory structure containing the Java classes created from the previous step to the EAServer or java/classes directory.

      2. If you are using the jar file, start EAServer and connect to it from EAServer Manager.

        Go to the Servers/<your server> directory and right-click the Server Properties menu. Select the Java Classes tab and click Add to add the name of the jar file, such as mycustom.jar. Click OK.

      3. Add repra.con.jar to the Server Properties.

    • For WebLogic:

      1. Shut down the application server if it is running.

      2. Modify the $BEA_HOME/repra/bin/repra_env.sh file to add the full path of mycustom.jar or the customclasses directory to the end of the CLASSPATH definition.

        set CLASSPATH=/work/custom/customclasses:$CLASSPATH
        or 
        set CLASSPATH=/work/custom/customclasses/mycustom.jar;$CLASSPATH
        
      3. Start the WebLogic Server to activate the new environment change.

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