Class MethodInvokingMessageProcessor<T>

Type Parameters:
T - the expected payload type.
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, MessageProcessor<T>, ManageableLifecycle

public class MethodInvokingMessageProcessor<T> extends AbstractMessageProcessor<T> implements ManageableLifecycle
A MessageProcessor implementation that invokes a method on a target Object. The Method instance or method name may be provided as a constructor argument. If a method name is provided, and more than one declared method has that name, the method-selection will be dynamic, based on the underlying SpEL method resolution. Alternatively, an annotation type may be provided so that the candidates for SpEL's method resolution are determined by the presence of that annotation rather than the method name.
Since:
2.0
  • Constructor Details

    • MethodInvokingMessageProcessor

      public MethodInvokingMessageProcessor(Object targetObject, Method method)
    • MethodInvokingMessageProcessor

      public MethodInvokingMessageProcessor(Object targetObject, String methodName)
    • MethodInvokingMessageProcessor

      public MethodInvokingMessageProcessor(Object targetObject, String methodName, boolean canProcessMessageList)
    • MethodInvokingMessageProcessor

      public MethodInvokingMessageProcessor(Object targetObject, Class<? extends Annotation> annotationType)
  • Method Details

    • setConversionService

      public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
      Overrides:
      setConversionService in class AbstractExpressionEvaluator
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
      Description copied from class: AbstractExpressionEvaluator
      Specify a BeanFactory in order to enable resolution via @beanName in the expression.
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Overrides:
      setBeanFactory in class AbstractExpressionEvaluator
    • setUseSpelInvoker

      public void setUseSpelInvoker(boolean useSpelInvoker)
      A boolean flag to use SpEL Expression evaluation or InvocableHandlerMethod for target method invocation.
      Parameters:
      useSpelInvoker - to use SpEL Expression evaluation or not.
      Since:
      5.0
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Specified by:
      start in interface ManageableLifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Specified by:
      stop in interface ManageableLifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface ManageableLifecycle
    • processMessage

      @Nullable public T processMessage(org.springframework.messaging.Message<?> message)
      Description copied from interface: MessageProcessor
      Process the Message and return a value (or null).
      Specified by:
      processMessage in interface MessageProcessor<T>
      Specified by:
      processMessage in class AbstractMessageProcessor<T>
      Parameters:
      message - The message to process.
      Returns:
      The result.