I'm using Apache Camel 2.13.1 and MongoDB 2.2.2. I have the following route:
<route id="camel-route" autoStartup="true">
<from uri="file:/dir?move=${date:now:yyyyMMdd}\processed\${file:name}&moveFailed=${date:now:yyyyMMdd}\failed\${file:name}" />
<unmarshal>
<jaxb prettyPrint="false" contextPath="com.example.model" />
</unmarshal>
<to uri="mongodb:connectionBean?database=db&collection=coll&operation=save" />
</route>
The file consumer endpoint takes an XML file and unmarshall it to a POJO that contains several fields with data type int, String and java.util.Date. It saves/insert fine but the date field is saved as type NumberLong, instead of type ISODate.
But if I save it by using the MongoDB Java driver (i.e. creating DBObject, map a key with a field "new Date()"), it will save as ISODate in MongoDB. Any way I can do this by just using camel XML DSL?
EDIT: Digging into the codes and documentation, camel-mongodb is using Jackson that first will convert it to a Map, then to a BasicDBObject. Is there a way in the XML DSL I can configure the behaviour of Jackson? Last resort would be to write a custom type converter.
write-date-as-timestamp
to false – Ondrej