1

How to invoke a method from spring integration EXPRESSION :

<int:chain input-channel="service.activator.out">
           <int:header-enricher>
              <int:header name="LIST_DATA"
             expression="**HERE NEEDS TO CALL A METHOD OF CLASS BY PASSING PAYLOAD**"/>     
         </int:header-enricher>
</int:chain>
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118

1 Answers1

8

If that method in on some bean you should use beanReference:

expression="@foo.method(payload, headers.bar)"

If it is a static method you should use typeReference:

expression="T(com.my.proj.Foo).method(headers.baz, payload.bar)"

And provide appropriate parameters based on Message as root object of expression evaluation context.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • How do we code this call if the method is in current class expression="@someMethod(payload.someproperty)" , something like this but this does not work. – Mark1234 May 20 '22 at 20:57
  • 1
    What is "current class"? There is no concept like that in SpEL. you can call `static` methods via specif `T` operator. You can call methods from beans. You can call methods from the root evaluation object. You also can use SpEL functions. Nothing more than explained in docs is possible: https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#expressions – Artem Bilan May 20 '22 at 21:00