public class WebSocketStompClient
extends org.springframework.messaging.simp.stomp.StompClientSupport
implements org.springframework.context.SmartLifecycle
WebSocketClient
including SockJsClient
.Constructor and Description |
---|
WebSocketStompClient(WebSocketClient webSocketClient)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> |
connect(String url,
org.springframework.messaging.simp.stomp.StompSessionHandler handler,
Object... uriVars)
Connect to the given WebSocket URL and notify the given
StompSessionHandler
when connected on the STOMP level after the CONNECTED frame is received. |
org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> |
connect(String url,
WebSocketHttpHeaders handshakeHeaders,
org.springframework.messaging.simp.stomp.StompHeaders connectHeaders,
org.springframework.messaging.simp.stomp.StompSessionHandler handler,
Object... uriVariables)
An overloaded version of
connect(String, StompSessionHandler, Object...) that also accepts
WebSocketHttpHeaders to use for the WebSocket handshake and
StompHeaders for the STOMP CONNECT frame. |
org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> |
connect(String url,
WebSocketHttpHeaders handshakeHeaders,
org.springframework.messaging.simp.stomp.StompSessionHandler handler,
Object... uriVariables)
An overloaded version of
connect(String, StompSessionHandler, Object...) that also
accepts WebSocketHttpHeaders to use for the WebSocket handshake. |
org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> |
connect(URI url,
WebSocketHttpHeaders handshakeHeaders,
org.springframework.messaging.simp.stomp.StompHeaders connectHeaders,
org.springframework.messaging.simp.stomp.StompSessionHandler sessionHandler)
An overloaded version of
connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)
that accepts a fully prepared URI . |
int |
getInboundMessageSizeLimit()
Get the configured inbound message buffer size in bytes.
|
int |
getPhase()
Return the configured phase.
|
WebSocketClient |
getWebSocketClient()
Return the configured WebSocketClient.
|
boolean |
isAutoStartup()
Return the value for the 'autoStartup' property.
|
boolean |
isRunning() |
protected org.springframework.messaging.simp.stomp.StompHeaders |
processConnectHeaders(org.springframework.messaging.simp.stomp.StompHeaders connectHeaders) |
void |
setAutoStartup(boolean autoStartup)
Set whether to auto-start the contained WebSocketClient when the Spring
context has been refreshed.
|
void |
setInboundMessageSizeLimit(int inboundMessageSizeLimit)
Configure the maximum size allowed for inbound STOMP message.
|
void |
setPhase(int phase)
Specify the phase in which the WebSocket client should be started and
subsequently closed.
|
void |
setTaskScheduler(org.springframework.scheduling.TaskScheduler taskScheduler) |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
public WebSocketStompClient(WebSocketClient webSocketClient)
StompClientSupport.setDefaultHeartbeat(long[])
to "0,0" but will
reset it back to the preferred "10000,10000" when a
setTaskScheduler(org.springframework.scheduling.TaskScheduler)
is configured.webSocketClient
- the WebSocket client to connect withpublic WebSocketClient getWebSocketClient()
public void setTaskScheduler(@Nullable org.springframework.scheduling.TaskScheduler taskScheduler)
Also automatically sets the defaultHeartbeat
property to "10000,10000" if it is currently set to "0,0".
setTaskScheduler
in class org.springframework.messaging.simp.stomp.StompClientSupport
public void setInboundMessageSizeLimit(int inboundMessageSizeLimit)
By default this is set to 64 * 1024 (64K).
public int getInboundMessageSizeLimit()
public void setAutoStartup(boolean autoStartup)
Default is "true".
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void setPhase(int phase)
By default this is Integer.MAX_VALUE meaning that the WebSocket client is started as late as possible and stopped as soon as possible.
public int getPhase()
getPhase
in interface org.springframework.context.Phased
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> connect(String url, org.springframework.messaging.simp.stomp.StompSessionHandler handler, Object... uriVars)
StompSessionHandler
when connected on the STOMP level after the CONNECTED frame is received.url
- the url to connect tohandler
- the session handleruriVars
- the URI variables to expand into the URLpublic org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders, org.springframework.messaging.simp.stomp.StompSessionHandler handler, Object... uriVariables)
connect(String, StompSessionHandler, Object...)
that also
accepts WebSocketHttpHeaders
to use for the WebSocket handshake.url
- the url to connect tohandshakeHeaders
- the headers for the WebSocket handshakehandler
- the session handleruriVariables
- the URI variables to expand into the URLpublic org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders, @Nullable org.springframework.messaging.simp.stomp.StompHeaders connectHeaders, org.springframework.messaging.simp.stomp.StompSessionHandler handler, Object... uriVariables)
connect(String, StompSessionHandler, Object...)
that also accepts
WebSocketHttpHeaders
to use for the WebSocket handshake and
StompHeaders
for the STOMP CONNECT frame.url
- the url to connect tohandshakeHeaders
- headers for the WebSocket handshakeconnectHeaders
- headers for the STOMP CONNECT framehandler
- the session handleruriVariables
- the URI variables to expand into the URLpublic org.springframework.util.concurrent.ListenableFuture<org.springframework.messaging.simp.stomp.StompSession> connect(URI url, @Nullable WebSocketHttpHeaders handshakeHeaders, @Nullable org.springframework.messaging.simp.stomp.StompHeaders connectHeaders, org.springframework.messaging.simp.stomp.StompSessionHandler sessionHandler)
connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)
that accepts a fully prepared URI
.url
- the url to connect tohandshakeHeaders
- the headers for the WebSocket handshakeconnectHeaders
- headers for the STOMP CONNECT framesessionHandler
- the STOMP session handlerprotected org.springframework.messaging.simp.stomp.StompHeaders processConnectHeaders(@Nullable org.springframework.messaging.simp.stomp.StompHeaders connectHeaders)
processConnectHeaders
in class org.springframework.messaging.simp.stomp.StompClientSupport