*
*/
public static void main(String[] args) throws InterruptedException
{
// Create connection
Connection con = new Connection();
con.connect("localhost", 5672, "test", "guest", "guest",false);
// Create session
Session session = con.createSession(0);
// Create an instance of the listener
Listener listener = new Listener();
session.setSessionListener(listener);
// create a subscription
session.messageSubscribe("message_queue",
"listener_destination",
MessageAcceptMode.NONE,
MessageAcquireMode.PRE_ACQUIRED,
null, 0, null);
// issue credits
// XXX
session.messageFlow("listener_destination", MessageCreditUnit.BYTE, Session.UNLIMITED_CREDIT);
session.messageFlow("listener_destination", MessageCreditUnit.MESSAGE, 11);
// confirm completion
session.sync();
// check to see if we have received all the messages
System.out.println("Waiting 100 seconds for messages from listener_destination");
Thread.sleep(100*1000);
System.out.println("Shutting down listener for listener_destination");
session.messageCancel("listener_destination");
//cleanup
session.close();
con.close();
}