public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; try { to = get ("to"); from = get ("from"); channel = (ISOChannel) NameRegistrar.get ( "channel." + get ("channel") ); ready = channel.toString() + ".ready"; new Thread (new Sender ()).start (); new Thread (new Receiver ()).start (); } catch (NameRegistrar.NotFoundException e) { throw new ConfigurationException (e); } } @SuppressWarnings("unchecked")
public void run () { Thread.currentThread().setName ("channel-receiver-"+from); for (;;) { try { sp.rd (ready); ISOMsg m = channel.receive (); sp.out (from, m); } catch (Exception e) { Logger.log ( new LogEvent ( ISOChannelAdaptor.this, "channel-receiver-"+from, e ) ); disconnect (); } } } }
public void run () { Thread.currentThread().setName ("channel-sender-" + to); for (;;) { try { checkConnection (); Object o = sp.in (to, 10000); if (o instanceof ISOMsg) channel.send ((ISOMsg) o); } catch (Exception e) { Logger.log ( new LogEvent ( ISOChannelAdaptor.this, "channel-sender"+to, e ) ); ISOUtil.sleep (1000); } } } }