SocketProxy proxy = new SocketProxy();
proxy.setTarget(new URI("tcp://localhost:" + stompBrokerUri.getPort()));
proxy.setReceiveBufferSize(receiveBufferSize);
proxy.open();
StompConnection stompConnection = new StompConnection();
stompConnection.open(new Socket("localhost", proxy.getUrl().getPort()));
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
frame = "SUBSCRIBE\n" + "destination:/queue/" + dest.getQueueName() + "\n" + "ack:client\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
// ensure dispatch has started before pause
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("MESSAGE"));
proxy.pause();
// writes should back up... writeTimeout will kick in a abort the connection
TimeUnit.SECONDS.sleep(1);
// see the blocked threads
//dumpAllThreads("blocked on write");
// abort should be done after this
TimeUnit.SECONDS.sleep(4);
proxy.goOn();
// get a buffered message
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("MESSAGE"));
// verify connection is dead
try {
for (int i=0; i<10; i++) {
stompConnection.send("/queue/" + dest.getPhysicalName(), messageTextPrefix + "ReplyText" + i);
}
fail("expected send to fail with timeout out connection");
} catch (SocketException expected) {
LOG.info("got exception on send after timeout: " + expected);
}