Package io.vertx.ext.stomp
Interface StompServerHandler
-
- All Superinterfaces:
Handler<ServerFrame>
public interface StompServerHandler extends 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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description StompServerHandler
abortHandler(Handler<ServerFrame> handler)
Configures the action to execute when aABORT
frame is received.StompServerHandler
ackHandler(Handler<ServerFrame> handler)
Configures the action to execute when aACK
frame is received.StompServerHandler
authProvider(AuthenticationProvider handler)
Configures theAuthenticationProvider
to be used to authenticate the user.StompServerHandler
beginHandler(Handler<ServerFrame> handler)
Configures the action to execute when aBEGIN
frame is received.StompServerHandler
bridge(BridgeOptions options)
Configures the STOMP server to act as a bridge with the Vert.x event bus.StompServerHandler
closeHandler(Handler<StompServerConnection> handler)
Configures the action to execute when a connection with the client is closed.StompServerHandler
commitHandler(Handler<ServerFrame> handler)
Configures the action to execute when aCOMMIT
frame is received.StompServerHandler
connectHandler(Handler<ServerFrame> handler)
Configures the action to execute when aCONNECT
frame is received.static StompServerHandler
create(Vertx vertx)
Creates an instance ofStompServerHandler
using the default (compliant) implementation.StompServerHandler
destinationFactory(DestinationFactory factory)
Configures theDestinationFactory
used to createDestination
objects.StompServerHandler
disconnectHandler(Handler<ServerFrame> handler)
Configures the action to execute when aDISCONNECT
frame is received.Destination
getDestination(String destination)
Gets the destination with the given name.List<Destination>
getDestinations()
Destination
getOrCreateDestination(String destination)
Gets aDestination
object if existing, or create a new one.User
getUserBySession(String session)
Provides for authorization matches on a destination level, this will return the User created by theAuthenticationProvider
.StompServerHandler
nackHandler(Handler<ServerFrame> handler)
Configures the action to execute when aNACK
frame is received.StompServerHandler
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.StompServerHandler
onAckHandler(Handler<Acknowledgement> handler)
Configures the action to execute when messages are acknowledged.Future<Boolean>
onAuthenticationRequest(StompServerConnection connection, String login, String passcode)
Called when the client connects to a server requiring authentication.void
onClose(StompServerConnection connection)
Called when the connection is closed.StompServerHandler
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.StompServerHandler
onNackHandler(Handler<Acknowledgement> handler)
Configures the action to execute when messages are not acknowledged.StompServerHandler
pingHandler(Handler<StompServerConnection> handler)
Allows customizing the action to do when the server needs to send a `PING` to the client.StompServerHandler
receivedFrameHandler(Handler<ServerFrame> handler)
Configures a handler that get notified when a STOMP frame is received by the server.StompServerHandler
sendHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSEND
frame is received.StompServerHandler
stompHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSTOMP
frame is received.StompServerHandler
subscribeHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSUBSCRIBE
frame is received.StompServerHandler
unsubscribeHandler(Handler<ServerFrame> handler)
Configures the action to execute when aUNSUBSCRIBE
frame is received.
-
-
-
Method Detail
-
create
static StompServerHandler create(Vertx vertx)
Creates an instance ofStompServerHandler
using the default (compliant) implementation.- Parameters:
vertx
- the vert.x instance to use- Returns:
- the created
StompServerHandler
-
receivedFrameHandler
StompServerHandler receivedFrameHandler(Handler<ServerFrame> handler)
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
StompServerHandler connectHandler(Handler<ServerFrame> handler)
Configures the action to execute when aCONNECT
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
stompHandler
StompServerHandler stompHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSTOMP
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
subscribeHandler
StompServerHandler subscribeHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSUBSCRIBE
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
unsubscribeHandler
StompServerHandler unsubscribeHandler(Handler<ServerFrame> handler)
Configures the action to execute when aUNSUBSCRIBE
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
sendHandler
StompServerHandler sendHandler(Handler<ServerFrame> handler)
Configures the action to execute when aSEND
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
closeHandler
StompServerHandler closeHandler(Handler<StompServerConnection> handler)
Configures the action to execute when a connection with the client is closed.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
onClose
void onClose(StompServerConnection connection)
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
StompServerHandler commitHandler(Handler<ServerFrame> handler)
Configures the action to execute when aCOMMIT
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
abortHandler
StompServerHandler abortHandler(Handler<ServerFrame> handler)
Configures the action to execute when aABORT
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
beginHandler
StompServerHandler beginHandler(Handler<ServerFrame> handler)
Configures the action to execute when aBEGIN
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
disconnectHandler
StompServerHandler disconnectHandler(Handler<ServerFrame> handler)
Configures the action to execute when aDISCONNECT
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
ackHandler
StompServerHandler ackHandler(Handler<ServerFrame> handler)
Configures the action to execute when aACK
frame is received.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
-
nackHandler
StompServerHandler nackHandler(Handler<ServerFrame> handler)
Configures the action to execute when aNACK
frame 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 theAuthenticationProvider
configured usingauthProvider(AuthenticationProvider)
.- Parameters:
connection
- server connection that contains session IDlogin
- the loginpasscode
- the password- Returns:
- a future notified with the authentication result
-
getUserBySession
User getUserBySession(String session)
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
StompServerHandler authProvider(AuthenticationProvider handler)
Configures theAuthenticationProvider
to 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
Destination getDestination(String destination)
Gets the destination with the given name.- Parameters:
destination
- the destination- Returns:
- the
Destination
,null
if not existing.
-
onAck
StompServerHandler 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. Implementations must call the handler configured usingonAckHandler(Handler)
.- Parameters:
connection
- the connectionsubscribe
- theSUBSCRIBE
framemessages
- the acknowledge messages- Returns:
- the current
StompServerHandler
-
onNack
StompServerHandler 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. Not acknowledgment can result from aNACK
frame or from a timeout (noACK
frame received in a given time. Implementations must call the handler configured usingonNackHandler(Handler)
.- Parameters:
connection
- the connectionsubscribe
- theSUBSCRIBE
framemessages
- the acknowledge messages- Returns:
- the current
StompServerHandler
-
onAckHandler
StompServerHandler onAckHandler(Handler<Acknowledgement> handler)
Configures the action to execute when messages are acknowledged.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
- See Also:
onAck(StompServerConnection, Frame, List)
-
onNackHandler
StompServerHandler onNackHandler(Handler<Acknowledgement> handler)
Configures the action to execute when messages are not acknowledged.- Parameters:
handler
- the handler- Returns:
- the current
StompServerHandler
- See Also:
onNack(StompServerConnection, Frame, List)
-
pingHandler
StompServerHandler pingHandler(Handler<StompServerConnection> handler)
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
Destination getOrCreateDestination(String destination)
Gets aDestination
object if existing, or create a new one. The creation is delegated to theDestinationFactory
.- Parameters:
destination
- the destination- Returns:
- the
Destination
instance, may have been created.
-
destinationFactory
StompServerHandler destinationFactory(DestinationFactory factory)
Configures theDestinationFactory
used to createDestination
objects.- Parameters:
factory
- the factory- Returns:
- the current
StompServerHandler
.
-
bridge
StompServerHandler bridge(BridgeOptions options)
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:
Vertx.eventBus()
-
-