// do we need to do this for synchronous calls? Vagueries of Couriers?
courier.setReplyToEpr(replyToEPR);
final Message response = courier.pickup(timeout);
if (response == null) {
throw new ResponseTimeoutException("No response received within timeout period") ;
}
return response ;
} else {
return message;
}
}
} catch (FaultMessageException e) {
throw e;
} catch (final CourierServiceBindException e) {
// meant to be masked by the SI fail-over
if (logger.isDebugEnabled()) {
logger.debug("Caught service lookup exception for EPR [" + targetEPR + "] and Service [" + service + "] and Message ["+message.getHeader()+"]. ", e);
}
// could be stale EPR, so move on to next entry in registry.
} catch (final CourierMarshalUnmarshalException e) {
logger.warn("Courier indicated (un)marshal related error "+e+" during delivery to EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]. " + e.getMessage());
throw new MessageDeliverException("Caught (un)marshal related exception during attempted send/receive.", e);
} catch (final CourierTransportException e) {
// meant to be masked by the SI fail-over
if (logger.isDebugEnabled()) {
logger.debug("Courier indicated transport related error "+e+" during send/receive with EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"]. ", e);
}
} catch (CourierException e) {
// probable config error. Log it and move on to next EPR/service entry.
logger.warn("Possible configuration error while using Courier for EPR [" + targetEPR + "] and Service [" + service + "] and Message ["+message.getHeader()+"]. " + e.getMessage());
} catch (MalformedEPRException e) {
// Hmmmm???... Can this really happen? The Courier has already been created. Haven't we already validated the EPR during the Courier lookup (above)??
logger.error("Unexpected error. Badly formed EPR [" + targetEPR + "] for Service [" + service + "]. But the EPR has already been validated!!");
throw e;
} catch (final CourierTimeoutException ex) {
logger.error("Response timeout using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].");
// timeout from synchronous invocation
// would like to make this an independent exception (not inherit from MDE). But signatures and applications would break.
throw new ResponseTimeoutException("Caught response timeout!", ex);
} catch (final MessageDeliverException mde) {
throw mde ;
} catch (Throwable t) {
logger.error("Unexpected throwable during attempted message delivery using Courier for EPR [" + targetEPR + "] for Service [" + service + "] and Message ["+message.getHeader()+"].", t);