You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ramana <po...@gmail.com> on 2014/04/23 12:01:47 UTC

camel file moving after process to default .camel or .done,

when i'm not use noop=true, the file moving default folders .camel  but my
execution going continusely
 also delete=true geeting same problem   pls help me.......


<camel:route id="employeeDBServiceCall">
 <camel:from
uri="file:D:/CAMELCXFRDWORKSPACE/CXF_BOOK_EXAMPLES/EmployeeDBWebServiceCall/input?delay=2000&amp;delete=true"/>
          <camel:to
uri="file:D:/CAMELCXFRDWORKSPACE/CXF_BOOK_EXAMPLES/EmployeeDBWebServiceCall/csvfile"/>
          <camel:process ref="fileProcess"/>
          </camel:route> 

                             *FileProcessors.java*

public class FileProcessors implements Processor {

	@Override
	public void process(Exchange exchange) throws Exception {
		// TODO Auto-generated method stub
		File file = exchange.getIn().getBody(File.class);
		System.out.println("CVS FILE NAME : "+file);
		MessageFactory factory;
        SOAPMessage soapMsg;
        SOAPPart part = null;
        SOAPEnvelope envelope;          
        SOAPHeader header ; 
        SOAPBody body ;           
        SOAPBodyElement element ;
		try{

            
            
            
    		BufferedReader br = null;
    		String line = "";
    		String cvsSplitBy = ",";
    		br = new BufferedReader(new FileReader(file));
    		
			while ((line = br.readLine()) != null) {
				String[] record = line.split(cvsSplitBy);
				 factory = MessageFactory.newInstance();
	             soapMsg = factory.createMessage();
	             part = soapMsg.getSOAPPart();
	            String serverURI = "http://employee.contract.example.org/";
	            
	             envelope = part.getEnvelope();
	            envelope.addNamespaceDeclaration("emp", serverURI);
	           
	             header = envelope.getHeader();
	            
	             body = envelope.getBody();
	            
	             element =
body.addBodyElement(envelope.createQName("addEmployee","emp"));
	             SOAPElement soapElement= element.addChildElement("arg0");
				
	            
soapElement.addChildElement("EmployeeId").addTextNode(record[0]);
	            
soapElement.addChildElement("LastName").addTextNode(record[1]);
	            
soapElement.addChildElement("FirstName").addTextNode(record[2]);
	             soapElement.addChildElement("Gender").addTextNode(record[3]);
	            
soapElement.addChildElement("DepartmentId").addTextNode(record[4]);
	            
soapElement.addChildElement("Hiredate").addTextNode(record[5]);
	             soapElement.addChildElement("Salary").addTextNode(record[6]);
        
            
            
           System.out.println("SOAP msg created");
           Date date=Calendar.getInstance().getTime();
           FileOutputStream fOut = new
FileOutputStream("D:/CAMELCXFRDWORKSPACE/CXF_BOOK_EXAMPLES/EmployeeDBWebserviceCall/SOAPReqMsgs/SoapReqMessage"+date.getTime()+".xml");
           soapMsg.writeTo(fOut);
           Thread.sleep(3000);
			}
        }catch(Exception e){

            e.printStackTrace();
        }

	}

}


*output*
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created
CVS FILE NAME :
D:\CAMELCXFRDWORKSPACE\CXF_BOOK_EXAMPLES\EmployeeDBWebServiceCall\input\CamelTest.csv
SOAP msg created
SOAP msg created..................



--
View this message in context: http://camel.465427.n5.nabble.com/camel-file-moving-after-process-to-default-camel-or-done-tp5750482.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel file moving after process to default .camel or .done,

Posted by ramana <po...@gmail.com>.
i able to solve.....


When using files on windows, make sure that if you use any custom code 
that read the file using a stream ,such af FileInputStream, etc. you 
must close the stream. 

On windows the file cannot be moved/deleted if that occurs. So double 
check your own code first. 




--
View this message in context: http://camel.465427.n5.nabble.com/camel-file-moving-after-process-to-default-camel-or-done-tp5750482p5751735.html
Sent from the Camel - Users mailing list archive at Nabble.com.