Top Description Methods
org.springframework.messaging.handler.annotation

public @Interface MessageMapping

extends Annotation
Annotations
@Target:TYPE, METHOD
@Retention:RUNTIME
@Documented
@Reflective:MessageMappingReflectiveProcessor
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, org.springframework.aot.hint.annotation.Reflective, org.springframework.messaging.Message

Annotation for mapping a Message onto a message-handling method by matching the declared patterns to a destination extracted from the message. The annotation is supported at the type-level too, as a way of declaring a pattern prefix (or prefixes) across all class methods.

@MessageMapping methods support the following arguments:

Return value handling depends on the processing scenario:

Specializations of this annotation include @SubscribeMapping (e.g. STOMP subscriptions) and @ConnectMapping (e.g. RSocket connections). Both narrow the primary mapping further and also match against the message type. Both can be combined with a type-level @MessageMapping that declares a common pattern prefix (or prefixes).

For further details on the use of this annotation in different contexts, see the following sections of the Spring Framework reference:

Note

When using controller interfaces (e.g. for AOP proxying), make sure to consistently put all your mapping annotations - such as @MessageMapping and @SubscribeMapping - on the controller interface rather than on the implementation class.

Author
Rossen Stoyanchev
Since
4.0
See Also
org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler, org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler

Method Summary

Modifier and TypeMethod and Description
public String[]
value()

Destination-based mapping expressed by this annotation.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String[] value()

Destination-based mapping expressed by this annotation.

For STOMP over WebSocket messages this is AntPathMatcher-style patterns matched against the STOMP destination of the message.

for RSocket this is either AntPathMatcher or PathPattern based pattern, depending on which is configured, matched to the route of the stream request.

If no patterns are configured, the mapping matches all destinations.