Search in sources :

Example 1 with ISOSource

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);
        }
    }
}
Also used : ISOSource(org.jpos.iso.ISOSource) ISOException(org.jpos.iso.ISOException) IOException(java.io.IOException)

Example 2 with ISOSource

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

Example 3 with ISOSource

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;
}
Also used : Context(org.jpos.transaction.Context) ISOSource(org.jpos.iso.ISOSource)

Aggregations

ISOSource (org.jpos.iso.ISOSource)3 IOException (java.io.IOException)1 ISOException (org.jpos.iso.ISOException)1 ISOMsg (org.jpos.iso.ISOMsg)1 SpaceSource (org.jpos.space.SpaceSource)1 Context (org.jpos.transaction.Context)1