Annotation Interface StompSubscriber
Annotation to mark a class as a STOMP subscriber.
Instances of classes annotated with @StompSubscriber can contain methods annotated with Topic
to handle messages from specific STOMP destinations. The destinationPrefix element allows
specifying a common prefix for all destinations handled by the subscriber. This prefix will be prepended
to the destination values defined in the @Topic annotations on the subscriber's methods.
To register a subscriber with a StompClient, pass an instance of the subscriber method
to the client's StompClient.subscribe(Object) method.
To unregister the subscriber and unsubscribe from all its topics, pass the same instance
to the client's StompClient.unsubscribe(Object) method.
The hash code of the subscriber instance may change. This has no effect on subscription management, as the client uses identity comparison to track subscribers.
Methods annotated with Topic in a subscriber class must be instance methods
(non-static) and have a single parameter representing the message payload type.
The message payload will be deserialized to the parameter type before invoking the method.
The return type of the method is ignored. It is recommended to use void return type.
- Since:
- 1.0.0
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe common destination prefix for all topics handled by this subscriber.
-
Element Details
-
destinationPrefix
String destinationPrefixThe common destination prefix for all topics handled by this subscriber. This prefix will be prepended to the destination values defined in the
Topicannotations on the subscriber's methods.Default is an empty string, meaning no prefix is applied.
- Returns:
- the destination prefix string
- Since:
- 1.0.0
- Default:
""
-