.invoke(ObjectName.getInstance(CONNECTION_FACTORY_NAME),
"$getResource");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
DeadLetterPolicy dlp = new DeadLetterPolicy();
//dlqName =
// dlp.getDeadLetterNameFromDestination((ActiveMQDestination)
// destination);
// This is a hack to get around the fact that the code commented
// above throws a ClassCastException due to ClassLoader weirdness.
Field f = dlp.getClass().getDeclaredField(
"deadLetterPerDestinationName");
f.setAccessible(true);
boolean deadLetterPerDestinationName = f.getBoolean(dlp);
f = dlp.getClass().getDeclaredField("deadLetterPrefix");
f.setAccessible(true);
String deadLetterPrefix = "" + f.get(dlp);
if (deadLetterPerDestinationName) {
dlqName = deadLetterPrefix
+ destination.getClass().getMethod("getPhysicalName",