How to configure jpos channel header with spaces

2019-05-21 10:30发布

问题:

I came across an issue, when the jpos channel header string has spaces. I configured that in the channel adaptor configuration as below, but when I start the Q2 server, it seems it trims the header value. As a result of that, I'm not getting any response from the jpos server for certain requests.

<channel-adaptor class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2"  name="my-channel">
    <channel class="CBCChannel" logger="Q2"
             packager="org.jpos.iso.packager.GenericPackager" header="ISOHEADER        ">
        <property name="packager-config" value="/path/to/PACKAGER/iso87ascii.xml" />
        <property name="host" value="xxx.xx.xx.xx"/>
        <property name="port" value="yyyy" />

    </channel>
    <in>channel-send</in>
    <out>channel-receive</out>
    <property name="timeout" value="300000" />
    <property name="keep-alive" value="true" />
    <reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

The CBCChannel just extends the RawChannel

public class CBCChannel extends RawChannel {

    public CBCChannel() throws ISOException {
    }

    public CBCChannel(String host, int port, ISOPackager p, byte[] header) {
        super(host, port, p, header);
    }

    public CBCChannel(ISOPackager p, byte[] header) throws IOException {
        super(p, header);
    }

    public CBCChannel(ISOPackager p, byte[] header, ServerSocket serverSocket) throws IOException {
        super(p, header, serverSocket);
    }
}

Is there any way to configure channel header which contains spaces without neglecting the spaces?

回答1:

I guess you only need to override setHeader method:

public CBCChannel extends RawChannel {
....
    public void setHeader(String header){
        super.setHeader(header.getBytes());
    }

}

But you would only be doing what BaseChannel does in regard to the header. Are you sure you need a RawChannel based channel?



标签: iso8583 jpos