mirror of https://github.com/apache/activemq.git
fix and add test for: https://issues.apache.org/jira/browse/AMQ-4686
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1515843 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45e1462609
commit
4e4d072d6e
|
@ -554,8 +554,8 @@ public class ProtocolConverter {
|
|||
String browser = headers.get(Stomp.Headers.Subscribe.BROWSER);
|
||||
if (browser != null && browser.equals(Stomp.TRUE)) {
|
||||
|
||||
if (!this.version.equals(Stomp.V1_1)) {
|
||||
throw new ProtocolException("Queue Browser feature only valid for Stomp v1.1 clients!");
|
||||
if (this.version.equals(Stomp.V1_0)) {
|
||||
throw new ProtocolException("Queue Browser feature only valid for Stomp v1.1+ clients!");
|
||||
}
|
||||
|
||||
consumerInfo.setBrowser(true);
|
||||
|
|
|
@ -357,4 +357,71 @@ public class Stomp12Test extends StompTestSupport {
|
|||
stompConnection.sendFrame(disconnect);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueueBrowerSubscription() throws Exception {
|
||||
|
||||
final int MSG_COUNT = 10;
|
||||
|
||||
String connectFrame = "STOMP\n" +
|
||||
"login:system\n" +
|
||||
"passcode:manager\n" +
|
||||
"accept-version:1.2\n" +
|
||||
"host:localhost\n" +
|
||||
"\n" + Stomp.NULL;
|
||||
|
||||
stompConnection.sendFrame(connectFrame);
|
||||
|
||||
String f = stompConnection.receiveFrame();
|
||||
LOG.debug("Broker sent: " + f);
|
||||
|
||||
assertTrue(f.startsWith("CONNECTED"));
|
||||
|
||||
for(int i = 0; i < MSG_COUNT; ++i) {
|
||||
String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n" +
|
||||
"receipt:0\n" +
|
||||
"\n" + "Hello World {" + i + "}" + Stomp.NULL;
|
||||
stompConnection.sendFrame(message);
|
||||
StompFrame repsonse = stompConnection.receive();
|
||||
assertEquals("0", repsonse.getHeaders().get(Stomp.Headers.Response.RECEIPT_ID));
|
||||
}
|
||||
|
||||
String subscribe = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
|
||||
"id:12345\n" + "browser:true\n\n" + Stomp.NULL;
|
||||
stompConnection.sendFrame(subscribe);
|
||||
|
||||
for(int i = 0; i < MSG_COUNT; ++i) {
|
||||
StompFrame message = stompConnection.receive();
|
||||
assertEquals(Stomp.Responses.MESSAGE, message.getAction());
|
||||
assertEquals("12345", message.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
|
||||
}
|
||||
|
||||
// We should now get a browse done message
|
||||
StompFrame browseDone = stompConnection.receive();
|
||||
LOG.debug("Browse Done: " + browseDone.toString());
|
||||
assertEquals(Stomp.Responses.MESSAGE, browseDone.getAction());
|
||||
assertEquals("12345", browseDone.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
|
||||
assertEquals("end", browseDone.getHeaders().get(Stomp.Headers.Message.BROWSER));
|
||||
assertTrue(browseDone.getHeaders().get(Stomp.Headers.Message.DESTINATION) != null);
|
||||
|
||||
String unsub = "UNSUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
|
||||
"id:12345\n\n" + Stomp.NULL;
|
||||
stompConnection.sendFrame(unsub);
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
subscribe = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "id:12345\n\n" + Stomp.NULL;
|
||||
stompConnection.sendFrame(subscribe);
|
||||
|
||||
for(int i = 0; i < MSG_COUNT; ++i) {
|
||||
StompFrame message = stompConnection.receive();
|
||||
assertEquals(Stomp.Responses.MESSAGE, message.getAction());
|
||||
assertEquals("12345", message.getHeaders().get(Stomp.Headers.Message.SUBSCRIPTION));
|
||||
}
|
||||
|
||||
stompConnection.sendFrame(unsub);
|
||||
|
||||
String frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
|
||||
stompConnection.sendFrame(frame);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue