You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David Delbecq <de...@meteo.be> on 2012/02/09 12:38:46 UTC
Can not get a simple example to run
Hello,
i am trying to run a simple example where i generate a text message and try to store it in a file. Here is my spring config file (i tried both with this logger and with file:///D:/blabla )
<camel:camelContext id="mycamel" autoStartup="true">
<camel:endpoint id="test" uri="log:org.apache.camel.example?level=ERROR" pattern="OutOnly"/>
</camel:camelContext>
<bean class="mypackage.TransfertJob" p:location="0414475060_{0,date,ddMMyy}_v1.csv" p:destination-ref="test"/>
The job code:
try {
ProducerTemplate template = camelContext.createProducerTemplate();
template.sendBodyAndHeader(destination,"Hello", Exchange.FILE_NAME, MessageFormat.format(location,new Date()));
System.out.println("Current folder is "+new File(".").getCanonicalPath());
} catch (Exception e) {
log.error("Could not send file",e);
}
and the test code:
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:/springtest.xml");
TransfertJob job = ctx.getBean(TransfertJob.class);
job.execute();
However, i do not get neither the log message nor the output file. I get no exception what so ever and the println show me correct informations. What did i miss?
David Delbecq
Re: Can not get a simple example to run
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
Here is no any camel route definition in the Spring configuration.
On 2/9/12 7:38 PM, David Delbecq wrote:
> Hello,
>
> i am trying to run a simple example where i generate a text message and try to store it in a file. Here is my spring config file (i tried both with this logger and with file:///D:/blabla )
>
>
>
> <camel:camelContext id="mycamel" autoStartup="true">
> <camel:endpoint id="test" uri="log:org.apache.camel.example?level=ERROR" pattern="OutOnly"/>
> </camel:camelContext>
> <bean class="mypackage.TransfertJob" p:location="0414475060_{0,date,ddMMyy}_v1.csv" p:destination-ref="test"/>
>
> The job code:
>
> try {
> ProducerTemplate template = camelContext.createProducerTemplate();
> template.sendBodyAndHeader(destination,"Hello", Exchange.FILE_NAME, MessageFormat.format(location,new Date()));
> System.out.println("Current folder is "+new File(".").getCanonicalPath());
> } catch (Exception e) {
> log.error("Could not send file",e);
> }
>
> and the test code:
> GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:/springtest.xml");
> TransfertJob job = ctx.getBean(TransfertJob.class);
> job.execute();
>
> However, i do not get neither the log message nor the output file. I get no exception what so ever and the println show me correct informations. What did i miss?
>
> David Delbecq
>
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: Can not get a simple example to run
Posted by David Delbecq <de...@meteo.be>.
Hello again,
yes, but springsource was autocompleting it with "inonly" so i guessed this was default value. I made a test with email endpoint and it worked. Seems my file location was incorrect and file was written in some unknown place i still have to find. And the logger never displayed anything :/
Problem solve by using correct file location, sorry :)
----- Mail original -----
De: "Claus Ibsen" <cl...@gmail.com>
À: users@camel.apache.org
Envoyé: Jeudi 9 Février 2012 12:59:51
Objet: Re: Can not get a simple example to run
Hi
You dont need the pattern attribute at all. Camel will figure it out
for you as its a logger so it only logs the message.
On Thu, Feb 9, 2012 at 12:38 PM, David Delbecq <de...@meteo.be> wrote:
> Hello,
>
> i am trying to run a simple example where i generate a text message and try to store it in a file. Here is my spring config file (i tried both with this logger and with file:///D:/blabla )
>
>
>
> <camel:camelContext id="mycamel" autoStartup="true">
> <camel:endpoint id="test" uri="log:org.apache.camel.example?level=ERROR" pattern="OutOnly"/>
> </camel:camelContext>
> <bean class="mypackage.TransfertJob" p:location="0414475060_{0,date,ddMMyy}_v1.csv" p:destination-ref="test"/>
>
> The job code:
>
> try {
> ProducerTemplate template = camelContext.createProducerTemplate();
> template.sendBodyAndHeader(destination,"Hello", Exchange.FILE_NAME, MessageFormat.format(location,new Date()));
> System.out.println("Current folder is "+new File(".").getCanonicalPath());
> } catch (Exception e) {
> log.error("Could not send file",e);
> }
>
> and the test code:
> GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:/springtest.xml");
> TransfertJob job = ctx.getBean(TransfertJob.class);
> job.execute();
>
> However, i do not get neither the log message nor the output file. I get no exception what so ever and the println show me correct informations. What did i miss?
>
> David Delbecq
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Can not get a simple example to run
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You dont need the pattern attribute at all. Camel will figure it out
for you as its a logger so it only logs the message.
On Thu, Feb 9, 2012 at 12:38 PM, David Delbecq <de...@meteo.be> wrote:
> Hello,
>
> i am trying to run a simple example where i generate a text message and try to store it in a file. Here is my spring config file (i tried both with this logger and with file:///D:/blabla )
>
>
>
> <camel:camelContext id="mycamel" autoStartup="true">
> <camel:endpoint id="test" uri="log:org.apache.camel.example?level=ERROR" pattern="OutOnly"/>
> </camel:camelContext>
> <bean class="mypackage.TransfertJob" p:location="0414475060_{0,date,ddMMyy}_v1.csv" p:destination-ref="test"/>
>
> The job code:
>
> try {
> ProducerTemplate template = camelContext.createProducerTemplate();
> template.sendBodyAndHeader(destination,"Hello", Exchange.FILE_NAME, MessageFormat.format(location,new Date()));
> System.out.println("Current folder is "+new File(".").getCanonicalPath());
> } catch (Exception e) {
> log.error("Could not send file",e);
> }
>
> and the test code:
> GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:/springtest.xml");
> TransfertJob job = ctx.getBean(TransfertJob.class);
> job.execute();
>
> However, i do not get neither the log message nor the output file. I get no exception what so ever and the println show me correct informations. What did i miss?
>
> David Delbecq
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/