Interceptor for specified type only?

Hello,
is it possible to register interceptor for specified types only?

class SystemObjectTypeInterceptor<T extends CommandMessage<CreateObjectTypeCommand>> implements MessageDispatchInterceptor<T> {
   

   @Override
   public BiFunction<Integer, T, T> handle(List<T> messages) {
      return (index, message) -> {
         ...
      };
   }
}

I mean if I create interceptor like above I’d like to intercept only messages of type CreateObjectTypeCommand not for all messages. Currently all messages types pass-through this interceptor. I know that I can check the type of incoming message with my message type but shouldn’t this be handled by framework? Or am I creating interceptors incorrectly?

Thanks

Lukas

Hi Lukas,

Interceptors capture all messages that pass through the component it was registered to.
We’ve been thinking of allowing annotation based interceptors, which would only invoke methods if the message matches the required parameters.

Until then, simply return the messages that you didn’t plan to intercept directly.

Cheers,

Allard