Custom trailer in ISO message

95 views Asked by At

I'm using Base24 channel in my jpos and I want to add extra characters after my trailer can anyone share your thought how to add it.

1

There are 1 answers

0
Andrés Alcarraz On

Here is a possible implementation, this implementation won't check that the received trailer matches the custom trailer, but you can add that code if needed.

public class MyCustomBase24 extends Base24Channel {
  byte[] customTrailer = ...;
  protected sendMessageTrailer() {
    super.sendMessageTrailer();
    serverOut.write(customTrailer); //
  }
  protected byte[] streamReceive() {
    byte[] d = super.streamReceive();
    //read the extra trailer chars
    byte[] extra = new byte[customTrailer.length]; 
    serverIn.readFully(extra);
    return d;

  }
}

This class calls the Base24Channel's sendMessageTrailer to send the 0x03 and then it sends the extra bytes, at receive time, after Base24Channel stopped receiving after the 0x03 it reads the extra bytes.

I'm assuming those extra bytes are present in incoming messages also, if not you wouldn't need to override the streamReceive method.

Then you just need to replace the class attribute of the XML deploy descriptor, with your custom class, instead of org.jpos.iso.channel.Base24Channel.