use of org.jpos.iso.ISOSource in project jPOS by jpos.
the class SpaceSource method notify.
@Override
public void notify(String key, ISOMsg m) {
sp.removeListener(this.key, this);
ISOSource source = (ISOSource) isp.inp(key);
if (m != null && source != null && source.isConnected()) {
try {
source.send((ISOMsg) m.clone());
// actually pick it
sp.inp(key);
} catch (Exception e) {
Q2.getQ2().getLog().warn(e);
}
}
}
use of org.jpos.iso.ISOSource in project jPOS by jpos.
the class SendResponse method sendResponse.
private void sendResponse(long id, Context ctx) {
ISOSource src = (ISOSource) ctx.get(source);
ISOMsg m = (ISOMsg) ctx.get(request);
ISOMsg resp = (ISOMsg) ctx.get(response);
try {
if (ctx.getResult().hasInhibit()) {
ctx.log("*** RESPONSE INHIBITED ***");
} else if (ctx.get(TX.toString()) != null) {
ctx.log("*** PANIC - TX not null - RESPONSE OMITTED ***");
} else if (resp == null) {
ctx.log(response + " not present");
} else if (src == null) {
ctx.log(source + " not present");
} else if (!src.isConnected())
ctx.log(source + " is no longer connected");
else {
if (src instanceof SpaceSource)
((SpaceSource) src).init(isp, timeout);
if (src.isConnected() && resp != null) {
headerStrategy.handleHeader(m, resp);
src.send(resp);
}
}
} catch (Throwable t) {
ctx.log(t);
}
}
use of org.jpos.iso.ISOSource in project jPOS by jpos.
the class SendResponse method prepare.
public int prepare(long id, Serializable context) {
Context ctx = (Context) context;
ISOSource source = (ISOSource) ctx.get(this.source);
if (source == null || !source.isConnected())
return ABORTED | READONLY | NO_JOIN;
return PREPARED | READONLY;
}
Aggregations