You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Gnanaguru S <gn...@wipro.com> on 2011/07/05 15:20:32 UTC

File reading and writing issue

Hi 

This code was successful.  

<from uri="file://inputdir/"/>
<to uri="activemq:queue:inputQueue"/>

But here , when i place a xml file in inputdirectory, it is moving out of
that folder !. I want it just to copied or the to be just read and move to
the queue.

Also from the output queue, i want the contents to be written in a peculiar
file namely: output.xml. 
( " <from uri="activemq:queue:outputQueue"/>
                 <to uri="file://outputdir/"/> " )

Since tried with this code, it didnt worked ( <to
uri="file:target?fileName=output.xmll"/> )

Kindly help me out



Cheers
Guru



-----
Cheers
 Guru
--
View this message in context: http://servicemix.396122.n5.nabble.com/File-reading-and-writing-issue-tp4553223p4553223.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: File reading and writing issue

Posted by Gnanaguru S <gn...@wipro.com>.
Hi 

This is my code... in this finally the contents from the queue is not
written as otherwise.xml but start.xml is rewritten there with transformed
code.

<?xml version="1.0" encoding="UTF-8"?>
<blueprint
     xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
       http://www.osgi.org/xmlns/blueprint/v1.0.0
       http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
     <camelContext xmlns="http://camel.apache.org/schema/blueprint"
trace="true">
	     
	  <route>    
	     
		  <from uri="file://inputdir/"/>
		  <to uri="activemq:queue:inputQueue"/>
	</route>
	   
	    <route> 
		    <from uri="activemq:queue:inputQueue"/>
		    <to
uri="xslt:file:C:\ESB\Fuse_ESB_4.4\apache-servicemix-4.4.0-fuse-00-27\design.xsl"/>
		    <to uri="activemq:queue:outputQueue"/>
	</route>
	 <route>
		 <from uri="activemq:queue:outputQueue"/>

		 <to uri="file:/outputdir?fileName=otherwise.xml"/> 
	</route>

     
     </camelContext>
</blueprint> 

-----
Cheers
 Guru
--
View this message in context: http://servicemix.396122.n5.nabble.com/File-reading-and-writing-issue-tp4553223p4560048.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: File reading and writing issue

Posted by Marcelo Jabali <mj...@fusesource.com>.
Any exceptions reported?

Here is a very simple Camel route just in case.

<?xml version="1.0" encoding="UTF-8" standalone="no"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
    <route id="myRoute">
        <from uri="file:/Users/Marcelo/src/data?noop=true"/>
        <choice id="choice1">
            <when id="whenLondon">
                <language language="xpath">/person/city='London'</language>
                <to uri="file:/Users/Marcelo/target/messages/uk"/>
            </when>
            <when id="whenTampa">
                <language language="xpath">/person/city='Tampa'</language>
                <to uri="file:/Users/Marcelo/target/messages/us"/>
            </when>
            <otherwise id="Otherwise">
                <to uri="file:/Users/Marcelo/target/messages/others?fileName=otherwise.xml"/>
            </otherwise>
        </choice>
    </route>
</camelContext>

</beans>


You specify the directory name in the URI. Something like this:
file:directoryName[?options]
file://directoryName[?options

Hope this helps,

-Marcelo


On Jul 5, 2011, at 11:18 PM, Gnanaguru S wrote:

> Hi
> 
> Thanks.
> 
> I tried this: <to uri="file:target?fileName=output.xml"/> 
> 
> Its not showing any expection also its not creating the file, 
> by the way can we specify the directory where it should get generated ?
> 
> Like , <to uri="file:target?fileName=/outputdirectory/output.xml"/> 
> 
> -----
> Cheers
> Guru
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/File-reading-and-writing-issue-tp4553223p4555851.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

--
Marcelo Jabali
Sr. Solutions Consultant
FuseSource
M: 978 729 6239
O: 619 464 2595
Web: fusesource.com
Skype/Twitter: mjabali
Blog: http://marcelojabali.blogspot.com





Re: File reading and writing issue

Posted by Gnanaguru S <gn...@wipro.com>.
Hi

Thanks.

I tried this: <to uri="file:target?fileName=output.xml"/> 

Its not showing any expection also its not creating the file, 
by the way can we specify the directory where it should get generated ?

Like , <to uri="file:target?fileName=/outputdirectory/output.xml"/> 

-----
Cheers
 Guru
--
View this message in context: http://servicemix.396122.n5.nabble.com/File-reading-and-writing-issue-tp4553223p4555851.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: File reading and writing issue

Posted by Marcelo Jabali <mj...@fusesource.com>.
Hi Guru,

If you want to keep files untouched try using the noop option like  <from uri="file:src/messages?noop=true"/>
Here is the reference to the File component: http://camel.apache.org/file2.html

And then, for writing files to the file system you should have something like this: <to uri="file:target?fileName=output.xml"/>

What kind of exception do you get when trying that code?

Hope this helps,

-Marcelo

On Jul 5, 2011, at 6:20 AM, Gnanaguru S wrote:

> 
> Hi 
> 
> This code was successful.  
> 
> <from uri="file://inputdir/"/>
> <to uri="activemq:queue:inputQueue"/>
> 
> But here , when i place a xml file in inputdirectory, it is moving out of
> that folder !. I want it just to copied or the to be just read and move to
> the queue.
> 
> Also from the output queue, i want the contents to be written in a peculiar
> file namely: output.xml. 
> ( " <from uri="activemq:queue:outputQueue"/>
>                 <to uri="file://outputdir/"/> " )
> 
> Since tried with this code, it didnt worked ( <to
> uri="file:target?fileName=output.xmll"/> )
> 
> Kindly help me out
> 
> 
> 
> Cheers
> Guru
> 
> 
> 
> -----
> Cheers
> Guru
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/File-reading-and-writing-issue-tp4553223p4553223.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

--
Marcelo Jabali
Sr. Solutions Consultant
FuseSource
M: 978 729 6239
O: 619 464 2595
Web: fusesource.com
Skype/Twitter: mjabali