public synchronized void setTimeout(long timeout, TimeUnit timeunit) { if (connection.isEstablished()) connection.getInitiator().setTimeout(timeout, timeunit); else this.timeoutMillis = timeunit.toMillis(timeout); }
public void run() { try { // get message ID String ID = generator.getID(); Message out = parser.parse(outText); Terser tOut = new Terser(out); tOut.set("/MSH-10", ID); // send, get response Message in = initiator.sendAndReceive(out); // get ACK ID Terser tIn = new Terser(in); String ackID = tIn.get("/MSA-2"); if (ID.equals(ackID)) { System.out.println("OK - ack ID matches"); } else { throw new RuntimeException( "Ack ID for message " + ID + " is " + ackID); } } catch (Exception e) { e.printStackTrace(); } } });
public synchronized Message sendAndReceive(Message out) throws HL7Exception, LLPException, IOException { if (!connection.isEstablished()) { connection.establishConnection(); setTimeout(timeoutMillis, TimeUnit.MILLISECONDS); } return connection.getInitiator().sendAndReceive(out); }
public synchronized Message sendAndReceive(Message out) throws HL7Exception, LLPException, IOException { if (!connection.isEstablished()) { connection.establishConnection(); setTimeout(timeoutMillis, TimeUnit.MILLISECONDS); } return connection.getInitiator().sendAndReceive(out); }
public synchronized void setTimeout(long timeout, TimeUnit timeunit) { if (connection.isEstablished()) connection.getInitiator().setTimeout(timeout, timeunit); else this.timeoutMillis = timeunit.toMillis(timeout); }
public void run() { try { // get message ID String ID = generator.getID(); Message out = parser.parse(outText); Terser tOut = new Terser(out); tOut.set("/MSH-10", ID); // send, get response Message in = initiator.sendAndReceive(out); // get ACK ID Terser tIn = new Terser(in); String ackID = tIn.get("/MSA-2"); if (ID.equals(ackID)) { System.out.println("OK - ack ID matches"); } else { throw new RuntimeException( "Ack ID for message " + ID + " is " + ackID); } } catch (Exception e) { e.printStackTrace(); } } });
Message response = initiator.sendAndReceive(adt);