如何保证在stomp客户端发生订阅?

时间:2017-06-27 09:02:26

标签: java spring stomp spring-websocket spring-messaging

我有以下课程:

@Autowired
private WebSocketStompClient client;

private volatile StompSession stompSession;

public ListenableFuture<StompSession> connect(String token) {
        .....
        //connecting
        return client.connect(settingsBean.getMarketPlaceUrl(),
                new WebSocketHttpHeaders(headers),
                stompHeadersConnect,
                new StompSessionHandlerAdapter() {
                    @Override
                    public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
                        stompSession = session;
                        ...
                        session.subscribe(stompHeadersSubscribe, myFrameHandler);
                         // As I understand I don't have guarantees that subscription was completed successfully
                    }

}

public void send(String url, Object obj) {
    stompSession.send(url, obj);
}

有时send方法在建立连接时调用,但是订阅 - 尚未确定。

如何等待订阅成立的时刻?

0 个答案:

没有答案