}
private static void deliverMessage(Serializable message, JMSEpr epr, KeyValuePair[] properties) {
String destType = null;
String destName = null;
JmsCourier courier = null;
ObjectMessage jmsMessage = null;
addJndiExtensions(epr);
destType = epr.getDestinationType();
destName = epr.getDestinationName();
try {
courier = new JmsCourier(epr);
} catch (CourierException e) {
throw new RuntimeException("Failed to create JMSCourier to JMS " + destType + " '" + destName + "': " + e.getMessage());
}
try {
try {
jmsMessage = courier.getJmsSession(epr.getAcknowledgeMode()).createObjectMessage(message);
} catch (CourierException e) {
throw new RuntimeException("Failed to get JMS Session for sending to JMS " + destType + " '" + destName + "': " + e.getMessage());
} catch (JMSException e) {
throw new RuntimeException("Failed to create JMS Message for sending to JMS " + destType + " '" + destName + "': " + e.getMessage());
}
if(properties != null) {
try {
setStringProperties(jmsMessage, properties);
} catch (JMSException e) {
throw new RuntimeException("Failed to set properties on the JMS Message to JMS " + destType + " '" + destName + "': " + e.getMessage());
}
}
try {
courier.deliver(jmsMessage);
} catch (CourierException e) {
throw new RuntimeException("Failed to deliver JMS Message to JMS " + destType + " '" + destName + "': " + e.getMessage());
}
} finally {
courier.cleanup();
}
}