我的 ISO JPOS 客户端实现正确打印消息长度输出,但是当我执行 tcpdump 时,我看到消息长度以“1”为前缀。所以 tcpdump 将消息头显示为"10000431804003001000000000084946520200922160158801"
而不是"0000431804003001000000000084946520200922160158801"
知道可能是什么问题。
下面是我的客户端打印出的消息长度和解压 ISO:
0000431804003001000000000084946520200922160158801
<log realm="post-channel/xx.xx.xx.x:xxxx" at="Tue Sep 22 16:01:58 WAT 2020.579" lifespan="1ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[deploy/cfg/customizedPackager.xml] -->
<header>303030303433</header>
<field id="0" value="1804"/>
<field id="11" value="849465"/>
<field id="12" value="20200922160158"/>
<field id="24" value="801"/>
</isomsg>
</send>
</log>
我的代码实现如下:
Date currDate = new Date();
SimpleDateFormat lda = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
String d = lda.format(currDate);
QMUX mux1 = (QMUX) NameRegistrar.getIfExists("mux.pesa-link-mux");
LoggingUtil.logDebugInfo("SIGNON MUX: " + mux1.getName());
Random randomGenerator = new Random();
int randomInt = randomGenerator.nextInt(1000000);
String formatedInt;
formatedInt = String.format("%06d", randomInt);
ISOMsg m = new ISOMsg();
//m.setHeader("000043".getBytes());
ISOPackager p = new GenericPackager("/usr/app/customized.xml");
byte[] b = new byte[1];
m.setPackager(p);
m.setMTI("1804");
m.set(11, formatedInt);
m.set(12, d);
m.set(24, "801");
byte[] data = m.pack();
short messageLength = (short) data.length;
String msglen = String.format("%6s", String.valueOf(messageLength)).replace(' ', '0');
String message = msglen + new String(data);
LoggingUtil.logDebugInfo(":: message length :: " + message + " :: len: " + msglen);
ISOMsg resp = mux1.request(m, 30 * 1000);
频道配置在这里
<channel-adaptor name="pd-channel-adaptor" class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.PostChannel" type="client" connect="yes" logger="Q2"
realm="post-channel" packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="deploy/cfg/customized.xml" />
<property name="host" value="1111.11.11.11" />
<property name="port" value="3322" />
</channel>
<in>pd_link_send</in>
<out>pd_link_receive</out>
<reconnect-delay>1000</reconnect-delay>
<keep-alive>yes</keep-alive>
</channel-adaptor>