jPOS无法从服务器接收ISOMsg

时间:2019-04-24 11:10:38

标签: java jpos

我通过this逐步设置了jPOS JAR服务器。我通过以下代码创建服务器:

public class jPOSServer implements ISORequestListener {

    public static void main(String[] args) {
        try {
            Logger logger = new Logger();
            logger.addListener(new SimpleLogListener(System.out));

            XMLChannel serverChannel = new XMLChannel("localhost", 9000, new XMLPackager());
            ((LogSource) serverChannel).setLogger(logger, "server-channel-logger");

            ISOServer isoServer = new ISOServer(9000, serverChannel, null);
            isoServer.setLogger(logger, "server-logger");
            isoServer.addISORequestListener(new jPOSServer());

            new Thread(isoServer).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public boolean process(ISOSource isoSource, ISOMsg isoMsg) {
        ISOMsg m = isoMsg;
        try {
            m.setMTI("0830");
            m.set(11, "000002");
            m.set(41, "00000002");
            isoSource.send(m);
            return true;
        } catch (ISOException e) {
            e.printStackTrace();
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
}

登录JAR服务器在这里:

<log realm="org.jpos.transaction.TransactionManager" at="2019-04-24T15:25:04.787" lifespan="24ms">                       
  <abort>
    txnmgr-1:idle:1
    <context>
      TIMESTAMP: Wed Apr 24 15:25:04 IRDT 2019                                                                           
      SOURCE: org.jpos.iso.channel.XMLChannel@7217f905
      REQUEST:
       <isomsg direction="incoming">                                                                
         <!-- org.jpos.iso.packager.XMLPackager -->                                                                      
         <field id="0" value="0800"/>
         <field id="11" value="000001"/>
         <field id="41" value="00000001"/>
         <field id="70" value="301"/>
       </isomsg>
      RESULT:
       <result>
         <fail>
           [MISCONFIGURED_ENDPOINT] o.j.t.p.QueryHost.prepare:60 'DESTINATION' not present in Context                    
         </fail>
       </result>
      LOGEVT:
        <info>
          RESPONSE not present
        </info>
    </context>
            prepare: o.j.t.p.QueryHost ABORTED READONLY NO_JOIN                                                          
    prepareForAbort: o.j.t.p.SendResponse
    abort: o.j.t.p.SendResponse
    in-transit=0, head=2, tail=2, paused=0, outstanding=0, active-sessions=2/128, tps=0, peak=0, avg=0.00, elapsed=22ms 
    <profiler>          
      prepare: o.j.t.p.QueryHost [20.5/20.5]                                                                             
      prepareForAbort: o.j.t.p.SendResponse [0.8/21.3]                                                                   
        abort: o.j.t.p.SendResponse [0.8/22.1]                                                                           
      end [28.3/50.5]      
    </profiler>         
  </abort>           
</log>               
<log realm="xml-server-8000/127.0.0.1:61804" at="2019-04-24T15:25:07.721" lifespan="3002ms">                             
  <receive>
    <io-timeout/>
  </receive>
</log>
<log realm="xml-server-8000.server.session/127.0.0.1:61804" at="2019-04-24T15:25:07.725">                                
  <session-end/>
</log>
<log realm="org.jpos.q2.iso.ChannelAdaptor" at="2019-04-24T15:29:57.225" lifespan="1ms">                                 
  <warn>
    channel-receiver-jpos-receive
    Read timeout / EOF - reconnecting                                                                                    
  </warn>
</log>     

我通过telnet localhost 8000将数据发送到端口8000上的JAR服务器,并且JAR服务器将数据传递到端口9000上的服务器。JAR服务器接收数据和日志数据,将数据发送到服务器,服务器接收数据。但发生Read timeout错误。我调试了JAR文件,发现此错误已在BaseChannel.java:777上的b = this.streamReceive();处触发。 我怎样才能解决这个问题?谢谢。

1 个答案:

答案 0 :(得分:1)

您是什么意思b = this.streamReceive()中的错误?您的问题似乎是这样的:

        <result>
         <fail>
           [MISCONFIGURED_ENDPOINT] o.j.t.p.QueryHost.prepare:60 'DESTINATION' not present in Context                    
         </fail>
       </result>

这意味着QueryHost参与者不知道向何处发送消息,这就是为什么您没有响应的原因,您需要将目标多路复用器添加到上下文中,显然是在“ DESTINATION”键下。我不知道您是如何创建上下文的,如果它使用的是IncomingListener,那么您将丢失此条目

<property name="ctx.DESTINATION" value="jPOS-AUTORESPONDER" /> 

jPOS-AUTORESPONDER更改为您的多路复用器名称。