Search in sources :

Example 1 with SpaceSource

use of org.jpos.space.SpaceSource 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);
    }
}
Also used : ISOMsg(org.jpos.iso.ISOMsg) SpaceSource(org.jpos.space.SpaceSource) ISOSource(org.jpos.iso.ISOSource)

Example 2 with SpaceSource

use of org.jpos.space.SpaceSource in project jPOS by jpos.

the class IncomingListener method process.

public boolean process(ISOSource src, ISOMsg m) {
    final Context ctx = new Context();
    if (remote)
        src = new SpaceSource((LocalSpace) sp, src, timeout);
    ctx.put(timestamp, new Date(), remote);
    ctx.put(source, src, remote);
    ctx.put(request, m, remote);
    if (additionalContextEntries != null) {
        additionalContextEntries.entrySet().forEach(e -> ctx.put(e.getKey(), e.getValue(), remote));
    }
    sp.out(queue, ctx, timeout);
    return true;
}
Also used : Context(org.jpos.transaction.Context) SpaceSource(org.jpos.space.SpaceSource) Date(java.util.Date)

Aggregations

SpaceSource (org.jpos.space.SpaceSource)2 Date (java.util.Date)1 ISOMsg (org.jpos.iso.ISOMsg)1 ISOSource (org.jpos.iso.ISOSource)1 Context (org.jpos.transaction.Context)1