public DefaultSubscription(StompHeaders headers, StompFrameHandler handler) { super(headers.getReceipt()); Assert.notNull(headers.getDestination(), "Destination must not be null"); Assert.notNull(handler, "StompFrameHandler must not be null"); this.headers = headers; this.handler = handler; DefaultStompSession.this.subscriptions.put(headers.getId(), this); }
@Override public String toString() { return "Subscription [id=" + getSubscriptionId() + ", destination='" + this.headers.getDestination() + "', receiptId='" + getReceiptId() + "', handler=" + getHandler() + "]"; } }
@Override public Subscription subscribe(StompHeaders headers, StompFrameHandler handler) { Assert.hasText(headers.getDestination(), "Destination header is required"); Assert.notNull(handler, "StompFrameHandler must not be null"); String subscriptionId = headers.getId(); if (!StringUtils.hasText(subscriptionId)) { subscriptionId = String.valueOf(DefaultStompSession.this.subscriptionIndex.getAndIncrement()); headers.setId(subscriptionId); } checkOrAddReceipt(headers); Subscription subscription = new DefaultSubscription(headers, handler); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SUBSCRIBE); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, EMPTY_PAYLOAD); execute(message); return subscription; }
@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }
@Test public void subscribe() { this.session.afterConnected(this.connection); assertTrue(this.session.isConnected()); String destination = "/topic/foo"; StompFrameHandler frameHandler = mock(StompFrameHandler.class); Subscription subscription = this.session.subscribe(destination, frameHandler); Message<byte[]> message = this.messageCaptor.getValue(); StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertEquals(StompCommand.SUBSCRIBE, accessor.getCommand()); StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders()); assertEquals(stompHeaders.toString(), 2, stompHeaders.size()); assertEquals(destination, stompHeaders.getDestination()); assertEquals(subscription.getSubscriptionId(), stompHeaders.getId()); }
@Test public void send() { this.session.afterConnected(this.connection); assertTrue(this.session.isConnected()); String destination = "/topic/foo"; String payload = "sample payload"; this.session.send(destination, payload); Message<byte[]> message = this.messageCaptor.getValue(); StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertEquals(StompCommand.SEND, accessor.getCommand()); StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders()); assertEquals(stompHeaders.toString(), 2, stompHeaders.size()); assertEquals(destination, stompHeaders.getDestination()); assertEquals(new MimeType("text", "plain", StandardCharsets.UTF_8), stompHeaders.getContentType()); assertEquals(-1, stompHeaders.getContentLength()); // StompEncoder isn't involved assertEquals(payload, new String(message.getPayload(), StandardCharsets.UTF_8)); }
@Test public void subscribeWithHeaders() { this.session.afterConnected(this.connection); assertTrue(this.session.isConnected()); String subscriptionId = "123"; String destination = "/topic/foo"; StompHeaders stompHeaders = new StompHeaders(); stompHeaders.setId(subscriptionId); stompHeaders.setDestination(destination); StompFrameHandler frameHandler = mock(StompFrameHandler.class); Subscription subscription = this.session.subscribe(stompHeaders, frameHandler); assertEquals(subscriptionId, subscription.getSubscriptionId()); Message<byte[]> message = this.messageCaptor.getValue(); StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); assertEquals(StompCommand.SUBSCRIBE, accessor.getCommand()); stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders()); assertEquals(stompHeaders.toString(), 2, stompHeaders.size()); assertEquals(destination, stompHeaders.getDestination()); assertEquals(subscriptionId, stompHeaders.getId()); }
public DefaultSubscription(StompHeaders headers, StompFrameHandler handler) { super(headers.getReceipt()); Assert.notNull(headers.getDestination(), "Destination must not be null"); Assert.notNull(handler, "StompFrameHandler must not be null"); this.headers = headers; this.handler = handler; DefaultStompSession.this.subscriptions.put(headers.getId(), this); }
@Override public String toString() { return "Subscription [id=" + getSubscriptionId() + ", destination='" + this.headers.getDestination() + "', receiptId='" + getReceiptId() + "', handler=" + getHandler() + "]"; } }
@Override public Subscription subscribe(StompHeaders headers, StompFrameHandler handler) { Assert.hasText(headers.getDestination(), "Destination header is required"); Assert.notNull(handler, "StompFrameHandler must not be null"); String subscriptionId = headers.getId(); if (!StringUtils.hasText(subscriptionId)) { subscriptionId = String.valueOf(DefaultStompSession.this.subscriptionIndex.getAndIncrement()); headers.setId(subscriptionId); } checkOrAddReceipt(headers); Subscription subscription = new DefaultSubscription(headers, handler); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SUBSCRIBE); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, EMPTY_PAYLOAD); execute(message); return subscription; }
@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }
if (stompHeaders.getDestination() == null) { Assert.state(this.destinationExpression != null, "One of 'destination' or 'destinationExpression' must " + "be" + final String destination = stompHeaders.getDestination(); final ApplicationEventPublisher eventPublisher = this.applicationEventPublisher; if (eventPublisher != null) {
public DefaultSubscription(StompHeaders headers, StompFrameHandler handler) { super(headers.getReceipt()); Assert.notNull(headers.getDestination(), "Destination must not be null"); Assert.notNull(handler, "StompFrameHandler must not be null"); this.headers = headers; this.handler = handler; DefaultStompSession.this.subscriptions.put(headers.getId(), this); }
public DefaultSubscription(StompHeaders headers, StompFrameHandler handler) { super(headers.getReceipt()); Assert.notNull(headers.getDestination(), "Destination must not be null"); Assert.notNull(handler, "StompFrameHandler must not be null"); this.headers = headers; this.handler = handler; DefaultStompSession.this.subscriptions.put(headers.getId(), this); }
@Override public String toString() { return "Subscription [id=" + getSubscriptionId() + ", destination='" + this.headers.getDestination() + "', receiptId='" + getReceiptId() + "', handler=" + getHandler() + "]"; } }
@Override public String toString() { return "Subscription [id=" + getSubscriptionId() + ", destination='" + this.headers.getDestination() + "', receiptId='" + getReceiptId() + "', handler=" + getHandler() + "]"; } }
@Override public Subscription subscribe(StompHeaders headers, StompFrameHandler handler) { Assert.hasText(headers.getDestination(), "Destination header is required"); Assert.notNull(handler, "StompFrameHandler must not be null"); String subscriptionId = headers.getId(); if (!StringUtils.hasText(subscriptionId)) { subscriptionId = String.valueOf(DefaultStompSession.this.subscriptionIndex.getAndIncrement()); headers.setId(subscriptionId); } checkOrAddReceipt(headers); Subscription subscription = new DefaultSubscription(headers, handler); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SUBSCRIBE); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, EMPTY_PAYLOAD); execute(message); return subscription; }
@Override public Subscription subscribe(StompHeaders headers, StompFrameHandler handler) { Assert.hasText(headers.getDestination(), "Destination header is required"); Assert.notNull(handler, "StompFrameHandler must not be null"); String subscriptionId = headers.getId(); if (!StringUtils.hasText(subscriptionId)) { subscriptionId = String.valueOf(DefaultStompSession.this.subscriptionIndex.getAndIncrement()); headers.setId(subscriptionId); } checkOrAddReceipt(headers); Subscription subscription = new DefaultSubscription(headers, handler); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SUBSCRIBE); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, EMPTY_PAYLOAD); execute(message); return subscription; }
@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }
@Override public Receiptable send(StompHeaders headers, Object payload) { Assert.hasText(headers.getDestination(), "Destination header is required"); String receiptId = checkOrAddReceipt(headers); Receiptable receiptable = new ReceiptHandler(receiptId); StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SEND); accessor.addNativeHeaders(headers); Message<byte[]> message = createMessage(accessor, payload); execute(message); return receiptable; }