Interface StompServerHandler
- All Superinterfaces:
Handler<ServerFrame>
STOMP server handler implements the behavior of the STOMP server when a specific event occurs. For instance, if
let customize the behavior when specific STOMP frames arrives or when a connection is closed. This class has been
designed to let you customize the server behavior. The default implementation is compliant with the STOMP
specification. In this default implementation, not acknowledge frames are dropped.
- Author:
- Clement Escoffier
-
Method Summary
Modifier and TypeMethodDescriptionabortHandler(Handler<ServerFrame> handler) Configures the action to execute when aABORTframe is received.ackHandler(Handler<ServerFrame> handler) Configures the action to execute when aACKframe is received.authProvider(AuthenticationProvider handler) Configures theAuthenticationProviderto be used to authenticate the user.beginHandler(Handler<ServerFrame> handler) Configures the action to execute when aBEGINframe is received.bridge(BridgeOptions options) Configures the STOMP server to act as a bridge with the Vert.x event bus.closeHandler(Handler<StompServerConnection> handler) Configures the action to execute when a connection with the client is closed.commitHandler(Handler<ServerFrame> handler) Configures the action to execute when aCOMMITframe is received.connectHandler(Handler<ServerFrame> handler) Configures the action to execute when aCONNECTframe is received.static StompServerHandlerCreates an instance ofStompServerHandlerusing the default (compliant) implementation.destinationFactory(DestinationFactory factory) Configures theDestinationFactoryused to createDestinationobjects.disconnectHandler(Handler<ServerFrame> handler) Configures the action to execute when aDISCONNECTframe is received.getDestination(String destination) Gets the destination with the given name.getOrCreateDestination(String destination) Gets aDestinationobject if existing, or create a new one.getUserBySession(String session) Provides for authorization matches on a destination level, this will return the User created by theAuthenticationProvider.nackHandler(Handler<ServerFrame> handler) Configures the action to execute when aNACKframe is received.onAck(StompServerConnection connection, Frame subscribe, List<Frame> messages) Method called by single message (client-individual policy) or a set of message (client policy) are acknowledged.onAckHandler(Handler<Acknowledgement> handler) Configures the action to execute when messages are acknowledged.onAuthenticationRequest(StompServerConnection connection, String login, String passcode) Called when the client connects to a server requiring authentication.voidonClose(StompServerConnection connection) Called when the connection is closed.onNack(StompServerConnection connection, Frame subscribe, List<Frame> messages) Method called by single message (client-individual policy) or a set of message (client policy) are not acknowledged.onNackHandler(Handler<Acknowledgement> handler) Configures the action to execute when messages are not acknowledged.pingHandler(Handler<StompServerConnection> handler) Allows customizing the action to do when the server needs to send a `PING` to the client.receivedFrameHandler(Handler<ServerFrame> handler) Configures a handler that get notified when a STOMP frame is received by the server.sendHandler(Handler<ServerFrame> handler) Configures the action to execute when aSENDframe is received.stompHandler(Handler<ServerFrame> handler) Configures the action to execute when aSTOMPframe is received.subscribeHandler(Handler<ServerFrame> handler) Configures the action to execute when aSUBSCRIBEframe is received.unsubscribeHandler(Handler<ServerFrame> handler) Configures the action to execute when aUNSUBSCRIBEframe is received.
-
Method Details
-
create
Creates an instance ofStompServerHandlerusing the default (compliant) implementation.- Parameters:
vertx- the vert.x instance to use- Returns:
- the created
StompServerHandler
-
receivedFrameHandler
Configures a handler that get notified when a STOMP frame is received by the server. This handler can be used for logging, debugging or ad-hoc behavior.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
connectHandler
Configures the action to execute when aCONNECTframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
stompHandler
Configures the action to execute when aSTOMPframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
subscribeHandler
Configures the action to execute when aSUBSCRIBEframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
unsubscribeHandler
Configures the action to execute when aUNSUBSCRIBEframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
sendHandler
Configures the action to execute when aSENDframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
closeHandler
Configures the action to execute when a connection with the client is closed.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
onClose
Called when the connection is closed. This method executes a default behavior and must calls the configuredcloseHandler(Handler)if any.- Parameters:
connection- the connection
-
commitHandler
Configures the action to execute when aCOMMITframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
abortHandler
Configures the action to execute when aABORTframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
beginHandler
Configures the action to execute when aBEGINframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
disconnectHandler
Configures the action to execute when aDISCONNECTframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
ackHandler
Configures the action to execute when aACKframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
nackHandler
Configures the action to execute when aNACKframe is received.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
onAuthenticationRequest
Future<Boolean> onAuthenticationRequest(StompServerConnection connection, String login, String passcode) Called when the client connects to a server requiring authentication. It invokes theAuthenticationProviderconfigured usingauthProvider(AuthenticationProvider).- Parameters:
connection- server connection that contains session IDlogin- the loginpasscode- the password- Returns:
- a future notified with the authentication result
-
getUserBySession
Provides for authorization matches on a destination level, this will return the User created by theAuthenticationProvider.- Parameters:
session- session ID for the server connection.- Returns:
- null if not authenticated.
-
authProvider
Configures theAuthenticationProviderto be used to authenticate the user.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler
-
getDestinations
List<Destination> getDestinations()- Returns:
- the list of destination managed by the STOMP server. Don't forget the STOMP interprets destination as opaque Strings.
-
getDestination
Gets the destination with the given name.- Parameters:
destination- the destination- Returns:
- the
Destination,nullif not existing.
-
onAck
Method called by single message (client-individual policy) or a set of message (client policy) are acknowledged. Implementations must call the handler configured usingonAckHandler(Handler).- Parameters:
connection- the connectionsubscribe- theSUBSCRIBEframemessages- the acknowledge messages- Returns:
- the current
StompServerHandler
-
onNack
Method called by single message (client-individual policy) or a set of message (client policy) are not acknowledged. Not acknowledgment can result from aNACKframe or from a timeout (noACKframe received in a given time. Implementations must call the handler configured usingonNackHandler(Handler).- Parameters:
connection- the connectionsubscribe- theSUBSCRIBEframemessages- the acknowledge messages- Returns:
- the current
StompServerHandler
-
onAckHandler
Configures the action to execute when messages are acknowledged.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler - See Also:
-
onNackHandler
Configures the action to execute when messages are not acknowledged.- Parameters:
handler- the handler- Returns:
- the current
StompServerHandler - See Also:
-
pingHandler
Allows customizing the action to do when the server needs to send a `PING` to the client. By default it send a frame containingEOL(specification). However, you can customize this and send another frame. However, be aware that this may requires a custom client. The handler will only be called if the connection supports heartbeats.- Parameters:
handler- the action to execute when a `PING` needs to be sent.- Returns:
- the current
StompServerHandler
-
getOrCreateDestination
Gets aDestinationobject if existing, or create a new one. The creation is delegated to theDestinationFactory.- Parameters:
destination- the destination- Returns:
- the
Destinationinstance, may have been created.
-
destinationFactory
Configures theDestinationFactoryused to createDestinationobjects.- Parameters:
factory- the factory- Returns:
- the current
StompServerHandler.
-
bridge
Configures the STOMP server to act as a bridge with the Vert.x event bus.- Parameters:
options- the configuration options- Returns:
- the current
StompServerHandler. - See Also:
-