Reputation: 784
I set the jPOS JAR server step by step by this. I create a server by below code :
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;
}
}
}
Log in JAR server is here:
<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>
I send data by telnet localhost 8000
to JAR server on port 8000 and JAR server pass data to the server on port 9000. JAR server receives data and log data, send data to Server and server receive data. but Read timeout
error occurred. I debug the JAR file and found the bug is fired at b = this.streamReceive();
on BaseChannel.java:777.
How can I fix this? thanks.
Upvotes: 2
Views: 2058
Reputation: 1865
what do you mean bug is in b = this.streamReceive()
? Your problem seem to be this:
<result>
<fail>
[MISCONFIGURED_ENDPOINT] o.j.t.p.QueryHost.prepare:60 'DESTINATION' not present in Context
</fail>
</result>
It means the QueryHost participant doesn't know where to send the message and that's why you are not having a response, you need to add the destination mux to the context, aparently under the "DESTINATION" key. I don't know how you are creating the context, if it is using the IncomingListener you are missing this entry
<property name="ctx.DESTINATION" value="jPOS-AUTORESPONDER" />
Changing jPOS-AUTORESPONDER
for whatever your mux name is.
Upvotes: 1