Hello, Mark & Oleg,
I've tried to use the new implementation of GroovyScriptExecuting when my script was inline and i've added to him the customizer.
In my case the script is very simple: it invokes the hibernate named query with parameter from payload and transform result to new outbound payload.
This is sample:
So, I added the Hibernate Session to Script context from SpringContext as Bean via implementation of GroovyObjectCustomizer.HTML Code:<service-activator input-channel="input" output-channel="response"> <groovy:script customizer="hibernateSessionGroovyObjectCustomizer"> <![CDATA[ import com.my.project.model.ResData import static org.hibernate.Hibernate.INTEGER as Hibernate_INTEGER def result = hibernateSession.getNamedQuery('getInfo') .setParameter('pageNo', payload != '' ? payload.pageNo : null, Hibernate_INTEGER) .list() if (result.empty) return '' def firstRecord = result[0] return new ResData( records: result, nextPageNo: firstRecord.nextPageNo ) ]]> </groovy:script> </service-activator>
When I received the Exception in script evaluation, in my case it was an SqlException during Hibernate execution, I found the problem in
org.springframework.integration.util.MessagingMeth odInvokerHelper.processInternal, where the candidates for my payload are processMessage from AbstractScriptExecutingMessageProcessor and GroovyScriptExecutingMessageProcessor.setCustomize r
So, When first called processMessage, and an Exception occurs, then called setCustomizer with my payload(!!!).
At the end I receive the Exception of invoking method with invalid arguments.
I'm confused. Whether this mechanism generally works?
Why candidate method attempts to be selected by type Message when I have clearly come pyaload?
Thoroughly investigate the problem I can't: too much complicated architecture of the project.
Oh, and the question is not on the topic: why not use the tag variable along with inline script, anyway it all comes down ScriptSource?
Thank you,
Artem Bilan


Reply With Quote
