Problem:
How to run a jython having main function in Mule application?
Issue:
I have a simple Jython code invoked by mule flow.
Flow:
<mule xmlns:...
<flow name="wfileFlow1" doc:name="wfileFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<logger message="===\n START ===" level="INFO" doc:name="Logger"/>
<scripting:component doc:name="Python">
<scripting:script engine="jython" file="src/main/java/com/test/Test1.py"/>
</scripting:component>
<logger message="===\n END ===" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Test1.py
def add(a,b):
return a+b
def addFixedValue(a):
y = 5
return y +a
print add(1,2)
print addFixedValue(1)
output:
===\n START ===
3
6
===\n END ===
if I run with main, then no output i.e it doesn't print anything.
Test1.py
def add(a,b):
return a+b
def addFixedValue(a):
y = 5
return y +a
if __name__ == '__main__':
print add(3,4)
print addFixedValue(1)
It prints no jython values:
===\n START ===
===\n END ===
Note here no jython values are printed.
Issue is, since second one run as main program in Java, but how do I run a main program from mule application if my above flow is wrong?