Hi Claus,
I am using consumer template to for the same work in the thread as
I want a pattern based reading of file and then move the file after renaming
it with current date some thing like :
file:{{inbound_home}}/bony?include=.*_BNYM_.*txt&move={{data_home}}/${file:onlyname.noext}_${date:now:yyyyMMdd}.TXT&moveFailed={{data_home}}/errorfile&doneFileName=LOADAVAILBNYM"
My Route is like this:
<from uri="timer://foo?fixedRate=true&period=500000" />
<to uri="bean:locatesSql?method=getFileFormatDetails" />
<split>
<simple>${in.header.accounts}</simple>
<setHeader
headerName="clientFileDir"><simple>${in.body.inFileDir}</simple></setHeader>
<choice> <when>
<to id="result"
uri="bean:locatesConsumer?method=consumeBnymFile" />
<unmarshal ref="bnymAvailabilityBeanIo"
/>
<process ref="bnymAvailabilityProcessor"
/>
<to
uri="bean:locatesSql?method=processLocatesFile" />
<to
uri="bean:jobLogger?method=logJobCompleted" />
</when> </choice></split>
Here inside the camel Header(in.header.accounts) I am keeping list of
account details its type is:
com.oceanview.eai.model.Account
After this on a separate class file named Consumer template I have:
@Autowired
private ConsumerTemplate consumer;
@Autowired
private ProducerTemplate producer;
public void consumeBnymFile(Exchange arg) throws Exception {
String fileUri =
"file:{{inbound_home}}/var/tmp/locates/test/bony?fileName=TEST_BNYM.txt";
consumer.start();
while(true) {
Exchange ex = consumer.receive(fileUri, 2000);
if(ex != null) {
log.info("Fetching file: " +
ex.getIn().getHeader("CamelFileName"));
// producer.send(fileUri, ex);
arg.getIn().setHeader("CamelFileName",
ex.getIn().getHeader("CamelFileName"));
arg.getIn().setBody(ex.getIn().getBody());
}
}
I have two problems:
1)In first iteration it runs fine but in second and subsequest I am
receiving this error:
Message: com.oceanview.eai.model.Account@338bd37a. Caused by:
No type converter available to convert from type:
com.oceanview.eai.model.Account to the required type:
java.io.InputStream with value com.oceanview.eai.model.Account@338bd37a.
Exchange[Message: com.oceanview.eai.model.Account@338bd37a]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException -
No type converter available to convert from type:
com.oceanview.eai.model.Account to the required type:
java.io.InputStream with value com.oceanview.eai.model.Account@338bd37a]
2.I am not being able to use include=.*_BNYM_.*tx or move or move failed in
String fileUri =
"file:{{inbound_home}}/bony?include=.*_BNYM_.*txt&move={{data_home}}/${file:onlyname.noext}_${date:now:yyyyMMdd}.TXT&moveFailed={{data_home}}/errorfile&
Please help...
Thanks,
Sanjeev
--
View this message in context:
http://camel.465427.n5.nabble.com/combining-the-existing-content-with-a-file-having-dynamic-uri-then-moving-the-file-tp5736365p5736797.html
Sent from the Camel - Users mailing list archive at Nabble.com.