Example usage for org.springframework.messaging.simp.stomp StompHeaders getId

List of usage examples for org.springframework.messaging.simp.stomp StompHeaders getId

Introduction

In this page you can find the example usage for org.springframework.messaging.simp.stomp StompHeaders getId.

Prototype

@Nullable
public String getId() 

Source Link

Document

Get the id header.

Usage

From source file:org.springframework.messaging.simp.stomp.DefaultStompSession.java

@Override
public Subscription subscribe(StompHeaders stompHeaders, StompFrameHandler handler) {
    Assert.hasText(stompHeaders.getDestination(), "Destination header is required");
    Assert.notNull(handler, "StompFrameHandler must not be null");

    String subscriptionId = stompHeaders.getId();
    if (!StringUtils.hasText(subscriptionId)) {
        subscriptionId = String.valueOf(DefaultStompSession.this.subscriptionIndex.getAndIncrement());
        stompHeaders.setId(subscriptionId);
    }/*  w  ww. jav a  2 s.  co m*/
    checkOrAddReceipt(stompHeaders);
    Subscription subscription = new DefaultSubscription(stompHeaders, handler);

    StompHeaderAccessor accessor = createHeaderAccessor(StompCommand.SUBSCRIBE);
    accessor.addNativeHeaders(stompHeaders);
    Message<byte[]> message = createMessage(accessor, EMPTY_PAYLOAD);
    execute(message);

    return subscription;
}