0

How can i use registered beans in

For example like this:

<chain>
<si-groovy:script>
def check = myCheckBean.checkPayload(payload)
myLogBean.log(paylod)
if (check==null) throws new Exception("Verify falt")
</si-groovy:script>
<chain>

1 Answer 1

1

First of all your config looks bad. Should be something like this:

<chain>
   <service-activator>
       <si-groovy:script>
              def check = myCheckBean.checkPayload(payload)
              myLogBean.log(paylod)
              if (check==null) throws new Exception("Verify falt")
       </si-groovy:script>
   <service-activator>
<chain>

Starting with Spring Integration 3.0 Groovy Scripts have access to BeanFactory, so you can use any bean from the Context by its bean name. So, your code is compatible with Spring Integration 3.0.

If you use previous version of Spring Integration we strongly recommend to upgrade, as long as they are EOL already.

Sign up to request clarification or add additional context in comments.

2 Comments

Usefully tip. For future processing need to add return payload
If it's OK, why don't follow with rule 'Accept Asnwer'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.