You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by contactreji <co...@gmail.com> on 2015/10/29 13:40:04 UTC

Camel Simple expressions in Groovy

Hello 

I am trying to write camel routes in groovy dsl. I just wrote a simple route
like follows. I tried using Camel simple expression inside the groovy syntax
as documented on http://camel.apache.org/simple.html but it fails to
recognize the syntax. How do we write Simple expresions in groovy
*
package com.groovy
import org.apache.camel.LoggingLevel
import org.apache.camel.builder.RouteBuilder

/**
 * Created by Z001NLH on 10/29/2015.
 */
class BasicRoutes extends RouteBuilder{
    @Override
    void configure() throws Exception {
       
from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
File").setProperty("bodyBackup",simple("${body}")).log("Done ").end()
    }
}
*


Now on running the code using main class, I get following exception.

*"C:\Program Files\Java\jdk1.8.0_51\bin\java" -Didea.launcher.port=7539
"-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA
Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath
"C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\classes\main;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\resources\main;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.3.11\f6b34997d04c1538ce451d3955298f46fdb4dbd4\groovy-all-2.3.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-core\2.15.1\5856cd06aabc0590b0b9d4c69211b0b5fa4bea4b\camel-core-2.15.1.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\c3f87d654f8d5943cd08592f3f758856544d279a\jaxb-core-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\a49ce57aee680f9435f49ba6ef427d38c93247a6\jaxb-impl-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.5\6b262da268f8ad9eff941b25503a9198f0a0ac93\slf4j-api-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.5\4a950c50bbc67fdbc908190dc8e25d7a0251f74a\slf4j-simple-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-log4j12\1.7.5\6edffc576ce104ec769d954618764f39f0f0f10d\slf4j-log4j12-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Program
Files (x86)\JetBrains\IntelliJ IDEA Community Edition
14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
com.groovy.MainRunner
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.5/4a950c50bbc67fdbc908190dc8e25d7a0251f74a/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.5/6edffc576ce104ec769d954618764f39f0f0f10d/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 starting
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 stopping
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutting down
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) uptime not started
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutdown in 0.007 seconds
Exception in thread "main" groovy.lang.MissingPropertyException: No such
property: body for class: BasicRoutes
	at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)
	at
org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:84)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
	at BasicRoutes.configure(BasicRoutes.groovy:10)
	at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:382)
	at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:323)
	at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:306)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
	at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
	at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
	at
org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:476)
	at
org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:405)
	at org.apache.camel.main.Main.doStart(Main.java:122)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:354)
	at org.apache.camel.main.MainSupport$run$1.call(Unknown Source)
	at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at com.groovy.MainRunner.main(MainRunner.groovy:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
[Thread-1] INFO org.apache.camel.main.MainSupport$HangupInterceptor -
Received hang up - stopping the main instance.

Process finished with exit code 1*




-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
This works fine in Java DSL though. Surprised to see that the same thing
works in Java but throws error in Groovy.



-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773188.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
In Groovy, is there a way to use the power of camel simple expression along
with String concatenation as I mentioned in this  post.




-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773374.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
Wow! Thanks Claus. It worked like a charm

One more challenge I am facing now is to pick up the exchange values using
simple expressions in a log statement. I am trying to do something like
below


from("file:C:\\Users\\Z001NLH\\Desktop\\in3").setProperty("exchangeTXNNumber",simple("exchangeId"))
        .setProperty("newExchangeTXNNumber",simple("property.exchangeTXNNumber"))
        .log("Properties are "+ simple("property.exchangeTXNNumber")
+" and "+simple("property.exchangeTXNNumber")).to("log:MyLOG?showAll=true").end()

In short, I am trying to embed cappabilities of Simple Expressions along
with hardcoded custom messages.

Logs
---------------
[main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel
2.15.1 (CamelContext: camel-1) started in 4.880 seconds

[Camel (camel-1) thread #12 - file://C:%5CUsers%5CZ001NLH%5CDesktop%5Cin3]
INFO route3 - Properties are Simple: property.exchangeTXNNumber and Simple:
property.exchangeTXNNumber

[Camel (camel-1) thread #12 - file://C:%5CUsers%5CZ001NLH%5CDesktop%5Cin3]
INFO MyLOG - Exchange[Id: ID-FWLYGZ1-59642-1446355498209-0-2,
ExchangePattern: InOnly, Properties: {CamelBatchComplete=true,
CamelBatchIndex=0, CamelBatchSize=1, CamelCreatedTimestamp=Sun Nov 01
10:55:29 IST 2015,
CamelFileExchangeFile=GenericFile[C:\Users\Z001NLH\Desktop\in3\MEETING
NOTES.txt], CamelFileLockFileAcquired=true,
CamelFileLockFileName=C:\Users\Z001NLH\Desktop\in3\MEETING
NOTES.txt.camelLock,
CamelMessageHistory=[DefaultMessageHistory[routeId=route3,
node=setProperty1], DefaultMessageHistory[routeId=route3,
node=setProperty2], DefaultMessageHistory[routeId=route3, node=log3],
DefaultMessageHistory[routeId=route3, node=to3]],
CamelToEndpoint=log://MyLOG?showAll=true,
exchangeTXNNumber=ID-FWLYGZ1-59642-1446355498209-0-2,
newExchangeTXNNumber=ID-FWLYGZ1-59642-1446355498209-0-2}, Headers:
{breadcrumbId=ID-FWLYGZ1-59642-1446355498209-0-1, CamelFileAbsolute=true,
CamelFileAbsolutePath=C:\Users\Z001NLH\Desktop\in3\MEETING NOTES.txt,
CamelFileContentType=text/plain, CamelFileLastModified=1445867243036,
CamelFileLength=695, CamelFileName=MEETING NOTES.txt,
CamelFileNameConsumed=MEETING NOTES.txt, CamelFileNameOnly=MEETING
NOTES.txt, CamelFileParent=C:\Users\Z001NLH\Desktop\in3,
CamelFilePath=C:\Users\Z001NLH\Desktop\in3\MEETING NOTES.txt,
CamelFileRelativePath=MEETING NOTES.txt}, BodyType:
org.apache.camel.component.file.GenericFile, Body: [Body is file based:
GenericFile[C:\Users\Z001NLH\Desktop\in3\MEETING NOTES.txt]], Out: null: ]


On Sat, Oct 31, 2015 at 10:53 PM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n5773296h55@n5.nabble.com> wrote:

> Try with
>
> .setProperty("bodyBackup", simple("body"))
>
> On Sat, Oct 31, 2015 at 4:40 PM, contactreji <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5773296&i=0>> wrote:
>
> > Hey
> >
> > Any Groovy experts out there who has tried writing Camel Simple
> expression
> > in groovy camel routes? Can someone post an example.
> >
> > I tried
> >
> *rom("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
>
> > File").setProperty("bodyBackup",$simple{body}).log("Done ").end()*
> >
> > but its throwing exceptions
> >
> > Cheers
> > Reji
> >
> >
> >
> > -----
> > Reji Mathews
> > Sr. Developer - Middleware Integration / SOA ( Open Source - Apache
> Camel & Jboss Fuse ESB | Mule ESB )
> > LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
> > Twitter - reji_mathews
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773294.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2nd edition:
> https://www.manning.com/books/camel-in-action-second-edition
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773296.html
> To unsubscribe from Camel Simple expressions in Groovy, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5773187&code=Y29udGFjdHJlamlAZ21haWwuY29tfDU3NzMxODd8MTAwNDkxODIzMw==>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773301.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by Claus Ibsen <cl...@gmail.com>.
Try with

.setProperty("bodyBackup", simple("body"))

On Sat, Oct 31, 2015 at 4:40 PM, contactreji <co...@gmail.com> wrote:
> Hey
>
> Any Groovy experts out there who has tried writing Camel Simple expression
> in groovy camel routes? Can someone post an example.
>
> I tried
> *rom("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
> File").setProperty("bodyBackup",$simple{body}).log("Done ").end()*
>
> but its throwing exceptions
>
> Cheers
> Reji
>
>
>
> -----
> Reji Mathews
> Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
> LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
> Twitter - reji_mathews
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773294.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
Hey

Any Groovy experts out there who has tried writing Camel Simple expression
in groovy camel routes? Can someone post an example. 

I tried
*rom("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
File").setProperty("bodyBackup",$simple{body}).log("Done ").end()*

but its throwing exceptions 

Cheers
Reji



-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773294.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
Oops! Sorry

I just corrected it as follows. Kinda confused as I am new to Groovy.

*from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
File").setProperty("bodyBackup","Value of Body : $simple{body}").log("Done
").end()*

I also tried
*from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
File").setProperty("bodyBackup",$simple{body}).log("Done ").end()*

No luck :-(

However, I get exception as 

"C:\Program Files\Java\jdk1.8.0_51\bin\java" -Didea.launcher.port=7537
"-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA
Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath
"C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\classes\main;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\resources\main;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.3.11\f6b34997d04c1538ce451d3955298f46fdb4dbd4\groovy-all-2.3.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-core\2.15.1\5856cd06aabc0590b0b9d4c69211b0b5fa4bea4b\camel-core-2.15.1.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\c3f87d654f8d5943cd08592f3f758856544d279a\jaxb-core-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\a49ce57aee680f9435f49ba6ef427d38c93247a6\jaxb-impl-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.5\6b262da268f8ad9eff941b25503a9198f0a0ac93\slf4j-api-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.5\4a950c50bbc67fdbc908190dc8e25d7a0251f74a\slf4j-simple-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-log4j12\1.7.5\6edffc576ce104ec769d954618764f39f0f0f10d\slf4j-log4j12-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-script\2.15.1\f2ea49185350f5d7b7f94ff8eb533784271751ad\camel-script-2.15.1.jar;C:\Program
Files (x86)\JetBrains\IntelliJ IDEA Community Edition
14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
com.groovy.MainRunner
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.5/4a950c50bbc67fdbc908190dc8e25d7a0251f74a/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.5/6edffc576ce104ec769d954618764f39f0f0f10d/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 starting
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 stopping
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutting down
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) uptime not started
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutdown in 0.008 seconds
Exception in thread "main" groovy.lang.MissingPropertyException: *No such
property: simple for class:* BasicRoutes
	at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)
	at
org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:84)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
	at BasicRoutes.configure(BasicRoutes.groovy:10)
	at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:382)
	at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:323)
	at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:306)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
	at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
	at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
	at
org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:476)
	at
org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:405)
	at org.apache.camel.main.Main.doStart(Main.java:122)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:354)
	at org.apache.camel.main.MainSupport$run$1.call(Unknown Source)
	at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at com.groovy.MainRunner.main(MainRunner.groovy:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
[Thread-1] INFO org.apache.camel.main.MainSupport$HangupInterceptor -
Received hang up - stopping the main instance.

Process finished with exit code 1




-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773198.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by Claus Ibsen <cl...@gmail.com>.
Please read again what I write.

And see the alternative syntax box at
http://camel.apache.org/simple

On Thu, Oct 29, 2015 at 2:21 PM, contactreji <co...@gmail.com> wrote:
> Hi Claus
>
> I tried
> *from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
> File").setProperty("bodyBackup",simple(${body})).log("Done ").end()
> *
> Still it says
>
> *"C:\Program Files\Java\jdk1.8.0_51\bin\java" -Didea.launcher.port=7532
> "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA
> Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath
> "C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\classes\main;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\resources\main;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.3.11\f6b34997d04c1538ce451d3955298f46fdb4dbd4\groovy-all-2.3.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-core\2.15.1\5856cd06aabc0590b0b9d4c69211b0b5fa4bea4b\camel-core-2.15.1.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\c3f87d654f8d5943cd08592f3f758856544d279a\jaxb-core-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\a49ce57aee680f9435f49ba6ef427d38c93247a6\jaxb-impl-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.5\6b262da268f8ad9eff941b25503a9198f0a0ac93\slf4j-api-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.5\4a950c50bbc67fdbc908190dc8e25d7a0251f74a\slf4j-simple-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-log4j12\1.7.5\6edffc576ce104ec769d954618764f39f0f0f10d\slf4j-log4j12-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-script\2.15.1\f2ea49185350f5d7b7f94ff8eb533784271751ad\camel-script-2.15.1.jar;C:\Program
> Files (x86)\JetBrains\IntelliJ IDEA Community Edition
> 14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
> com.groovy.MainRunner
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.5/4a950c50bbc67fdbc908190dc8e25d7a0251f74a/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.5/6edffc576ce104ec769d954618764f39f0f0f10d/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
> SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 starting
> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 stopping
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) is shutting down
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) uptime not started
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) is shutdown in 0.006 seconds
> Exception in thread "main" groovy.lang.MissingMethodException: No signature
> of method: BasicRoutes.$() is applicable for argument types:
> (BasicRoutes$_configure_closure1) values:
> [BasicRoutes$_configure_closure1@2bbf180e]
> Possible solutions: is(java.lang.Object), any(), any(groovy.lang.Closure),
> use([Ljava.lang.Object;), wait(), body()
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:56)
>         at
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
>         at BasicRoutes.configure(BasicRoutes.groovy:10)
>         at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:382)
>         at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:323)
>         at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:306)
>         at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
>         at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
>         at
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
>         at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
>         at
> org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:476)
>         at
> org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:405)
>         at org.apache.camel.main.Main.doStart(Main.java:122)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:354)
>         at org.apache.camel.main.MainSupport$run$1.call(Unknown Source)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>         at com.groovy.MainRunner.main(MainRunner.groovy:17)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
> [Thread-1] INFO org.apache.camel.main.MainSupport$HangupInterceptor -
> Received hang up - stopping the main instance.
>
> Process finished with exit code 1
> *
>
>
> I have 2 queries here
> 1) The one already mentioned above
> 2) Whats the groovy equivalent of
> *<setProperty propertyName="stringMessage">
> <simple>Hello Mr ${body}</simple>
> </setProperty>
> *
> Suppose, I have "Reji" in the exchange body, I want property stringMessage =
> Hello Mr Reji
>
>
>
>
>
> -----
> Reji Mathews
> Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
> LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
> Twitter - reji_mathews
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773194.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition

Re: Camel Simple expressions in Groovy

Posted by contactreji <co...@gmail.com>.
Hi Claus

I tried 
*from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
File").setProperty("bodyBackup",simple(${body})).log("Done ").end()
*
Still it says 

*"C:\Program Files\Java\jdk1.8.0_51\bin\java" -Didea.launcher.port=7532
"-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA
Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath
"C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program
Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\classes\main;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\resources\main;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.3.11\f6b34997d04c1538ce451d3955298f46fdb4dbd4\groovy-all-2.3.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-core\2.15.1\5856cd06aabc0590b0b9d4c69211b0b5fa4bea4b\camel-core-2.15.1.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\c3f87d654f8d5943cd08592f3f758856544d279a\jaxb-core-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\a49ce57aee680f9435f49ba6ef427d38c93247a6\jaxb-impl-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.5\6b262da268f8ad9eff941b25503a9198f0a0ac93\slf4j-api-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.5\4a950c50bbc67fdbc908190dc8e25d7a0251f74a\slf4j-simple-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-log4j12\1.7.5\6edffc576ce104ec769d954618764f39f0f0f10d\slf4j-log4j12-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-script\2.15.1\f2ea49185350f5d7b7f94ff8eb533784271751ad\camel-script-2.15.1.jar;C:\Program
Files (x86)\JetBrains\IntelliJ IDEA Community Edition
14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
com.groovy.MainRunner
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.5/4a950c50bbc67fdbc908190dc8e25d7a0251f74a/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.5/6edffc576ce104ec769d954618764f39f0f0f10d/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 starting
[main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 stopping
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutting down
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) uptime not started
[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
(CamelContext: camel-1) is shutdown in 0.006 seconds
Exception in thread "main" groovy.lang.MissingMethodException: No signature
of method: BasicRoutes.$() is applicable for argument types:
(BasicRoutes$_configure_closure1) values:
[BasicRoutes$_configure_closure1@2bbf180e]
Possible solutions: is(java.lang.Object), any(), any(groovy.lang.Closure),
use([Ljava.lang.Object;), wait(), body()
	at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:56)
	at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:78)
	at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
	at BasicRoutes.configure(BasicRoutes.groovy:10)
	at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:382)
	at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:323)
	at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:306)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
	at
org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
	at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
	at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
	at
org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:476)
	at
org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:405)
	at org.apache.camel.main.Main.doStart(Main.java:122)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:354)
	at org.apache.camel.main.MainSupport$run$1.call(Unknown Source)
	at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
	at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at com.groovy.MainRunner.main(MainRunner.groovy:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
[Thread-1] INFO org.apache.camel.main.MainSupport$HangupInterceptor -
Received hang up - stopping the main instance.

Process finished with exit code 1
*


I have 2 queries here
1) The one already mentioned above
2) Whats the groovy equivalent of 
*<setProperty propertyName="stringMessage">
<simple>Hello Mr ${body}</simple>
</setProperty>
*
Suppose, I have "Reji" in the exchange body, I want property stringMessage =
Hello Mr Reji





-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187p5773194.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Simple expressions in Groovy

Posted by Claus Ibsen <cl...@gmail.com>.
Try with "$simple{body}" as ${ } is groovy string that may interfere with that.



On Thu, Oct 29, 2015 at 1:40 PM, contactreji <co...@gmail.com> wrote:
> Hello
>
> I am trying to write camel routes in groovy dsl. I just wrote a simple route
> like follows. I tried using Camel simple expression inside the groovy syntax
> as documented on http://camel.apache.org/simple.html but it fails to
> recognize the syntax. How do we write Simple expresions in groovy
> *
> package com.groovy
> import org.apache.camel.LoggingLevel
> import org.apache.camel.builder.RouteBuilder
>
> /**
>  * Created by Z001NLH on 10/29/2015.
>  */
> class BasicRoutes extends RouteBuilder{
>     @Override
>     void configure() throws Exception {
>
> from("file:C:\\Users\\Mathews\\Desktop\\in").log(LoggingLevel.INFO,"BasicRouteLogger","Received
> File").setProperty("bodyBackup",simple("${body}")).log("Done ").end()
>     }
> }
> *
>
>
> Now on running the code using main class, I get following exception.
>
> *"C:\Program Files\Java\jdk1.8.0_51\bin\java" -Didea.launcher.port=7539
> "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA
> Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath
> "C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\rt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program
> Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\classes\main;C:\Users\Z001NLH\Desktop\loaders\camel-groovydsl\build\resources\main;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all\2.3.11\f6b34997d04c1538ce451d3955298f46fdb4dbd4\groovy-all-2.3.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.apache.camel\camel-core\2.15.1\5856cd06aabc0590b0b9d4c69211b0b5fa4bea4b\camel-core-2.15.1.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\c3f87d654f8d5943cd08592f3f758856544d279a\jaxb-core-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\a49ce57aee680f9435f49ba6ef427d38c93247a6\jaxb-impl-2.2.11.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.5\6b262da268f8ad9eff941b25503a9198f0a0ac93\slf4j-api-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.5\4a950c50bbc67fdbc908190dc8e25d7a0251f74a\slf4j-simple-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-log4j12\1.7.5\6edffc576ce104ec769d954618764f39f0f0f10d\slf4j-log4j12-1.7.5.jar;C:\Users\Z001NLH\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Program
> Files (x86)\JetBrains\IntelliJ IDEA Community Edition
> 14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
> com.groovy.MainRunner
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.5/4a950c50bbc67fdbc908190dc8e25d7a0251f74a/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/C:/Users/Z001NLH/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.5/6edffc576ce104ec769d954618764f39f0f0f10d/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
> SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 starting
> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.15.1 stopping
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) is shutting down
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) uptime not started
> [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1
> (CamelContext: camel-1) is shutdown in 0.007 seconds
> Exception in thread "main" groovy.lang.MissingPropertyException: No such
> property: body for class: BasicRoutes
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:51)
>         at
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:84)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
>         at BasicRoutes.configure(BasicRoutes.groovy:10)
>         at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:382)
>         at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:323)
>         at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:306)
>         at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
>         at
> org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
>         at
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
>         at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
>         at
> org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:476)
>         at
> org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:405)
>         at org.apache.camel.main.Main.doStart(Main.java:122)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:150)
>         at org.apache.camel.main.MainSupport.run(MainSupport.java:354)
>         at org.apache.camel.main.MainSupport$run$1.call(Unknown Source)
>         at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>         at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>         at com.groovy.MainRunner.main(MainRunner.groovy:17)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
> [Thread-1] INFO org.apache.camel.main.MainSupport$HangupInterceptor -
> Received hang up - stopping the main instance.
>
> Process finished with exit code 1*
>
>
>
>
> -----
> Reji Mathews
> Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
> LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
> Twitter - reji_mathews
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Simple-expressions-in-Groovy-tp5773187.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition