/** * For response messages, returns the value of MSA-2 (the message ID of the message sent by the * sending system). This value may be needed prior to main message parsing, so that * (particularly in a multi-threaded scenario) the message can be routed to the thread that sent * the request. We need this information first so that any parse exceptions are thrown to the * correct thread. Implementers of Parsers should take care to make the implementation of this * method very fast and robust. Returns null if MSA-2 can not be found (e.g. if the message is * not a response message). */ public String getAckID(String message) { try { return getAppropriateParser(message).getAckID(message); } catch (HL7Exception e) { return null; } }
/** * For response messages, returns the value of MSA-2 (the message ID of the message sent by the * sending system). This value may be needed prior to main message parsing, so that * (particularly in a multi-threaded scenario) the message can be routed to the thread that sent * the request. We need this information first so that any parse exceptions are thrown to the * correct thread. Implementers of Parsers should take care to make the implementation of this * method very fast and robust. Returns null if MSA-2 can not be found (e.g. if the message is * not a response message). */ public String getAckID(String message) { try { return getAppropriateParser(message).getAckID(message); } catch (HL7Exception e) { return null; } }
/** * Processes a single incoming message by sending it to the appropriate * internal location. If an incoming message contains an MSA-2 field, it is * assumed that this message is meant as a reply to a message that has been * sent earlier. In this case an attempt is give the message to the object * that sent the corresponding outbound message. If the message contains an * MSA-2 but there are no objects that appear to be waiting for it, it is * discarded and an exception is logged. If the message does not contain an * MSA-2 field, it is concluded that the message has arrived unsolicited. In * this case it is sent to the Responder (in a new Thread). */ protected void processMessage(String message) { String ackID = conn.getParser().getAckID(message); if (ackID == null) { log.debug("Unsolicited Message Received: {}", message); getExecutorService().submit(new Grunt(conn, message)); } else { if (!conn.isRecipientWaiting(ackID, message)) { log.info("Unexpected Message Received. This message appears to be an acknowledgement (MSA-2 has a value) so it will be ignored: {}", message); } else { log.debug("Response Message Received: {}", message); } } }
/** * Processes a single incoming message by sending it to the appropriate * internal location. If an incoming message contains an MSA-2 field, it is * assumed that this message is meant as a reply to a message that has been * sent earlier. In this case an attempt is give the message to the object * that sent the corresponding outbound message. If the message contains an * MSA-2 but there are no objects that appear to be waiting for it, it is * discarded and an exception is logged. If the message does not contain an * MSA-2 field, it is concluded that the message has arrived unsolicited. In * this case it is sent to the Responder (in a new Thread). */ protected void processMessage(String message) { String ackID = conn.getParser().getAckID(message); if (ackID == null) { log.debug("Unsolicited Message Received: {}", message); getExecutorService().submit(new Grunt(conn, message)); } else { if (!conn.isRecipientWaiting(ackID, message)) { log.info("Unexpected Message Received. This message appears to be an acknowledgement (MSA-2 has a value) so it will be ignored: {}", message); } else { log.debug("Response Message Received: {}", message); } } }