ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=TEST.Q");
QueueViewMBean queueMbean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true);
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("JMSExpiration", Long.toString(System.currentTimeMillis() + 2000));
headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
String msgId = queueMbean.sendTextMessage(headers, "test", "system", "manager");
// allow message to expire on the queue
TimeUnit.SECONDS.sleep(3);
Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager");
c.start();