我有一个发送和接收 iso 消息的 jpos 实现。它首先需要登录,然后再进行其他任何操作。作为客户端,我能够发送请求(customized.xml 打包程序)并且还可以成功接收响应而没有问题。
但是,当对方向我发送请求时,同一个打包器(customized.xml 打包器)无法将收到的请求解包。
为了尝试解决传入请求的问题,我决定创建一个新的自定义打包程序(customized2.xml),但我注意到所有传入请求仍然引用旧打包程序(customized.xml)。我该如何处理或者最好的做法是什么。
我的配置:
10_mychannel.xml
<?xml version="1.0" encoding="UTF-8"?>
<channel-adaptor name="mychannel-channel" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" type="client" connect="yes" logger="Q2" realm="post-channel" packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="cfg/customized.xml" />
<property name="packager-logger" value="Q2" />
<property name="packager-realm" value="custom-packager" />
<property name="host" value="14.101.333.111" />
<property name="port" value="7777" />
<property name="length-digits" value="6" />
<property name="connection-timeout" value="30000" />
<property name="timeout" value="300000" />
</channel>
<in>my-channel-send</in>
<out>my-channel-receive</out>
<reconnect-delay>10000</reconnect-delay>
<keep-alive>yes</keep-alive>
</channel-adaptor>
20_my_mux.xml
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="my-mux">
<in>my-channel-receive</in>
<out>my-channel-send</out>
<ready>my-channel.ready</ready>
</mux>
21_my_q_beans.xml
<qbean name='LogonManager' class='com.my.processor.LogonManager' />
50_my_server.xml
<server class="org.jpos.q2.iso.QServer" logger="Q2" name="xml-server-7777" realm="xml-server-7777">
<attr name="port" type="java.lang.Integer">7777</attr>
<channel class="org.jpos.iso.channel.ASCIIChannel" packager="org.jpos.iso.packager.GenericPackager" type="server" logger="Q2" realm="xml-server-7777">
<property name="packager-config" value="cfg/customized2.xml" />
<property name="timeout" value="180000"/>
</channel>
<request-listener class="com.my.processor.myListener" logger="Q2" realm="incoming-request-listener" />
</server>
来样请求
public class myListener implements ISORequestListener{
private static final String FTREQUEST = "1200";
private static final String REVADVICE = "1420";
private static final String NETWORKREQ = "1804";
Log log1;
@Override
public boolean process(ISOSource source, ISOMsg m) {
System.out.println("::::: Waiting :::::");
log.info("::::: Inside Listener :::::");
try {
String mti = m.getMTI();
System.out.println("mti ::: " + mti);
log.info("mti ::: " + mti);
switch (mti) {
case FTREQUEST:
log.info("Inside Financial Transaction Request");
//implementation here
m.setMTI("1210");
m.set(2, m.getString(2));
m.set(3, m.getString(3));
m.set(4, m.getString(4));
m.set(11, m.getString(11));
m.set(12, m.getString(12));
m.set(39, "100");
source.send(m);
break;
case REVADVICE:
log.info("Reversal Advice");
break;
case NETWORKREQ:
log.info("Network Management Request");
break;
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
return true;
}
}