Annotation Interface TrackSelf


@Retention(RUNTIME) @Target(TYPE) @Inherited @Documented @Component @Scope("prototype") public @interface TrackSelf
Indicates that a message payload class can handle itself as a message handler.

When this annotation is present on a class (or its interface), Flux will automatically register a handler for any implementation of that type. The resulting handler behaves like a standard external consumer: the message is first published to the appropriate message log and then tracked and processed via the configured consumer infrastructure.

Without this annotation, a payload class with handler methods (e.g., HandleCommand) would be treated as a local handler. That means it would be executed immediately, bypassing the message log and any tracking.

You may also annotate the class with Consumer to configure message consumption in an isolated consumer. If no @Consumer annotation is present, the handler will be assigned to the application's default consumer.

Spring integration: When using Spring, types annotated with @TrackSelf will be automatically detected and registered as handlers via component scanning. When not using Spring, or when testing using an asynchronous TestFixture, you must register the class manually.

See Also: