Map<String,String> params = getURLParameters(targetEPR);
try {
Message message = parser.parse(xmlFormat);
ConnectionHub connectionHub = ConnectionHub.getInstance();
Connection connection = getConnection(targetEPR, connectionHub);
Initiator initiator = connection.getInitiator();
String timeout = params.get(HL7Constants.TIMEOUT_PARAM);
if (timeout != null) {
initiator.setTimeoutMillis(Integer.parseInt(timeout));
} else {
initiator.setTimeoutMillis(HL7Constants.DEFAULT_TIMEOUT);
}
returnMsg = initiator.sendAndReceive(message);
connectionHub.detach(connection);
if (log.isDebugEnabled()) {
log.debug("HL7 message successfully dispatched to URL " + targetEPR);
log.debug("Response message received from target EP : " + returnMsg.toString());
}