{
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
Destination topic = (Destination)ic.lookup("/topic/ATopic");
Connection conn = cf.createConnection();
Slot slot = new Slot();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(topic);
consumer.setMessageListener(new SimpleMessageListener(slot));
conn.start();
Connection conn2 = cf.createConnection();
Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = session2.createProducer(topic);
Message m = session.createTextMessage("blah");
prod.send(m);
TextMessage rm = (TextMessage)slot.poll(5000);
assertEquals("blah", rm.getText());
// Only for JBoss Remoting > 2.0.0.Beta1
long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
log.info("sleeping " + (sleepTime / 60000) + " minutes");
Thread.sleep(sleepTime);
log.info("after sleep");
// send the second message. In case of remoting timeout, the callback server won't forward
// this message to the MessageCallbackHandler, and the test will fail
Message m2 = session.createTextMessage("blah2");
prod.send(m2);
TextMessage rm2 = (TextMessage)slot.poll(5000);
assertNotNull(rm2);
assertEquals("blah2", rm2.getText());
conn.close();