final ReflectorCometHandler handler = new ReflectorCometHandler(true);
context.addCometHandler(handler);
if (!queue.messagesWaiting()) {
queue.setActivationCallback(new QueueActivationCallback() {
public void activate(MessageQueue queue) {
queue.setActivationCallback(null);
context.resumeCometHandler(handler);
try {
context.notify(null, CometEvent.NOTIFY, handler);