This is what I ended up doing:
Hashtable t = new Hashtable();
t.put(Context.PROVIDER_URL, "localhost:1099");
t.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
Context ctx = new InitialContext(t);
Queue q = (Queue) ctx.lookup("/queue/DLQ");
//----------------------------
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("/ConnectionFactory");
Connection connection = cf.createConnection();
Session session = connection.createSession(true, 0);
//---------------------------------
MessageConsumer consumer = session.createConsumer(q);
connection.start();
SpyObjectMessage m;
Queue originialDestination = null;
//There can only be one in my case, but really you have to look it up every time.
MessageProducer producer = null;
while ((m = (SpyObjectMessage) consumer.receive(5000)) != null) {
Object o = m.getObject();
Date messageDate = new Date(m.getJMSTimestamp());
String originalQueue = m.getStringProperty("JBOSS_ORIG_DESTINATION");
if (originialDestination == null) {
originialDestination = (Queue) ctx.lookup("/queue/" +
originalQueue.substring(originalQueue.indexOf('.') + 1));
producer = session.createProducer(originialDestination);
}
producer.send(session.createObjectMessage((Serializable) o));
m.acknowledge();
}
//session.commit(); //Uncomment to make this real.
connection.close();
ctx.close();