camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Okello Nelson <cn.oke...@gmail.com>
Subject Exchanges Aggregation for batch loading to database
Date Mon, 27 May 2013 12:08:17 GMT
Hi Guys,

I have the following Java DSL:

from(queuePrefix + fileType + "_ValidQ?concurrentConsumers=100")
.routeId(fileType + "_ValidQ-To-DB")
.onException(Exception.class).redeliveryPolicyRef("redeliverypolicy")
.to(queuePrefix + fileType + "_DBLoading_ErrorQ").end()
.aggregate(header("CRBOriginalFileName"))
.completionSize(5000)
.parallelProcessing()
.groupExchanges()
.to("bean:keBouncedChequeLoader");

The destination is a bean. The bean is as shown below:

public void process(Exchange exchange) throws Exception {
List<Exchange> exchanges = exchange.getProperty(Exchange.GROUPED_EXCHANGE,
List.class);
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
Transaction tx = session.beginTransaction();
 for(int i = 0; i < exchanges.size(); i++) {
KEBouncedCheque bc = (KEBouncedCheque) exchanges.get(i).getIn().getBody();
session.save(exchanges.get(i));
FileUtils.writeStringToFile(new File("C:/tmp/bc.txt"), bc.getClientNumber()
+ "\n", true);
if( i % 20 == 0) {
session.flush();
session.clear();
}
}
 tx.commit();
session.close();
 }

The message doesn't seem to reach this bean. In ActiveMQ, I'm seeing the
error

"Unknown message type [org.apache.activemq.command.ActiveMQMessage]"...

I'm not sure what I'm doing wrong. Any assistance will be appreciated very
much.

Kind Regards,
Okello Nelson.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message