// client 1 subscribes to a queue
LOG.debug( "SENDING LISTEN" );
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
contentExchange.setMethod( "POST" );
contentExchange.setURL("http://localhost:8080/amq");
contentExchange.setRequestContent( new ByteArrayBuffer("destination=queue://test&type=listen&message=handler") );
contentExchange.setRequestContentType( "application/x-www-form-urlencoded; charset=UTF-8" );
httpClient.send(contentExchange);
contentExchange.waitForDone();
String jsessionid = contentExchange.getJsessionId();
// client 1 polls for messages
LOG.debug( "SENDING POLL" );
AjaxTestContentExchange poll = new AjaxTestContentExchange();
poll.setMethod( "GET" );
poll.setURL("http://localhost:8080/amq?timeout=5000");
poll.setRequestHeader( "Cookie", jsessionid );
httpClient.send( poll );
// while client 1 is polling, client 2 sends messages to the queue
LOG.debug( "SENDING MESSAGES" );
contentExchange = new AjaxTestContentExchange();
contentExchange.setMethod( "POST" );
contentExchange.setURL("http://localhost:8080/amq");
contentExchange.setRequestContent( new ByteArrayBuffer(
"destination=queue://test&type=send&message=msg1&"+
"d1=queue://test&t1=send&m1=msg2&"+
"d2=queue://test&t2=send&m2=msg3"
) );
contentExchange.setRequestContentType( "application/x-www-form-urlencoded; charset=UTF-8" );