-
1. Re: Fuse Integration Designer - Groovy
oisin Jun 6, 2009 5:18 AM (in response to jcornell)Hi jcornell
FID does allow you to enter groovy expressions as part of patterns that use such things - for example the choices of a Content-Based Router.
However, I think that you are after more than that, am I right? Do you want to write custom Camel processors in Groovy?
One more thing - we should be having this discussion over on the Tools forum - http://fusesource.com/forums/forum.jspa?forumID=7
-
2. Re: Fuse Integration Designer - Groovy
jcornell Jun 29, 2009 10:42 AM (in response to oisin)You are correct.... I would like to use groovy to transform my message before and after it passes through my cxf service. How is this performed in FID? Thanks
-
3. Re: Fuse Integration Designer - Groovy
oisin Jun 30, 2009 5:10 AM (in response to jcornell)I think that a Message Translator with a Groovy language expression might do the trick here.
Here's an example - a trivial one, just to illustrate the approach. Consider the following Message Translator setup.
In the properties view, click on the ... button to bring up the expression editor. Then, from the Language drop-down, choose groovy. Then, type in your Groovy transformation expression in the Expression Value text box.
There's no language checking in that expression text, so we can't tell you if have made any errors at this stage.
Of course, you will need the relevant Groovy jars on the classpath and in the classpath of the Run configuration.
-
simpleXform.png 46.6 KB
-
groovyExpr.png 32.1 KB
-
-
4. Re: Fuse Integration Designer - Groovy
jcornell Jul 1, 2009 9:08 AM (in response to oisin)Oisin -
Thank you for that detailed and informative post. Along with that thread... I have a groovy file which I have inserted into my spring-bean.xml I have referenced the groovy file using the Camel Processor Bean component. My groovy file simply changes the NormalizedMessage (outMessage) and should pass it to my file out component. I know I have a valid groovy script because I can test it with my gunit test and run a sample message... it does the trick... Do I need to use one of the endpoints to reference the bean in the workflow to integrate this functionality I am seeking.
Your last post was indeed informative but I would like to keep my groovy script file separate and not have it integrated into the IDE... I am not sure how I would go about unit testing my groovy methods if they are integrated into the IDE.
Thanks
-
flow.JPG 6.0 KB
-
-
5. Re: Fuse Integration Designer - Groovy
oisin Jul 1, 2009 11:09 AM (in response to jcornell)I have referenced the groovy file using the Camel Processor Bean component. deleted Do I need to use one of the endpoints to reference the bean in the workflow to integrate this functionality I am seeking.
Ok, I'm not 100% clear exactly what you are up to, but here is a picture anyway
In this picture, I've put a Bean Processor on the canvas between two endpoints and then linked that processor to a Spring bean called MyBean. Basically, the route will just call the particular method on an instance of that bean. Is this the kind of thing that might be useful?
I don't know if you can share any of your project, but it would be a cool example if you could!
Your last post was indeed informative but I would like to keep my groovy script file separate and not have it integrated into the IDE... I am not sure how I would go about unit testing my groovy methods if they are integrated into the IDE.
That's a good point - a nice improvement to the Expression Editor would be to somehow link a file that lives in the workspace, rather than having to copy it or type it in as the Expression Value. I added an improvement JIRA for that:
-
groovybean.png 25.6 KB
-
-
6. Re: Fuse Integration Designer - Groovy
jcornell Jul 1, 2009 11:51 AM (in response to jcornell)Current Work around is ...
Solved issue in previous post... I referenced my groovy script in my spring-bean.xml then droped the Camel Processor Bean on my eip_diagram. Then reference the method in my groovy script. Here is the sample code....
spring-bean.xml
1.) needed to add
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd to your xsi:scemaLocation
2.)
camel-context.xml
1.)
Edited by: jcornell on Jul 1, 2009 3:51 PM
-
7. Re: Fuse Integration Designer - Groovy
cokebloom Dec 23, 2010 2:23 AM (in response to jcornell)hi!
my question is a bit irrelevant. but i need your help. i have some problems in my script in php...actually in AJAX. problem is almost same...how can i solve it
-
8. Re: Fuse Integration Designer - Groovy
cokebloom Dec 23, 2010 2:25 AM (in response to jcornell)FID does allow you to enter groovy expressions as part of patterns that use such things - for example the choices of a Content-Based Router. by the way which tool you are using? you may experience to change tool for solving your problem