I'm trying to use Python with spring-integration and jython-standalone-2.7.0:
Here is my application context:
<int:inbound-channel-adapter id="in" channel="exampleChannel" >
<int:poller fixed-rate="1000" />
<int-script:script lang="python" location="script/message.py" />
</int:inbound-channel-adapter>
<int:channel id="exampleChannel" />
<int-ip:udp-outbound-channel-adapter id="udpOut" channel="exampleChannel" host="192.168.0.1" port="11111" />
Here is my script in Python:
print "Python"
message="python-message"
When I start the application, I see "Python" in the console. This must mean that my script is launched by spring-integration but nothing is sent in udp.
I see in the code that in org.spring.framework.integration.scripting.js223.AbstractScriptExecutor
:
result = scriptEngine.eval(script, new SimpleBindings(variables));
All the Python variables are in the Map variables and scriptEngine contains no reference to Python variables.
Thus, in org.spring.framework.integration.scripting.js223.PythonScriptExecutor
:
scriptEngine.get(returnVariableName);
It returns null.
Is it a problem in Jython, in Spring-integration or may be I'm doing something wrong?
This is a bug in Spring Integration; I have opened a JIRA Issue.
When the first branch of the
if
test is taken, the result variable is added to theSimpleBindings
object, and is not added to the engine scope map.Even though, in your case, variables is empty, we still call the first branch.
EDIT:
Here is a work-around until we fix the bug...
and