How to configure jpos channel header with spaces

折月煮酒 提交于 2020-01-02 09:56:26

问题


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?



来源:https://stackoverflow.com/questions/45709755/how-to-configure-jpos-channel-header-with-spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!