I am wondering if there is a good option for getting ISODates or any of the
other built-in MongoDB types to work within the context of Spring. For
example, given a very simple document:

/{ "time" : ISODate("2016-02-19T17:37:57.673+0000") }/

How might one get the ISODate to properly work with camel-mongo? I have been
round and round with variations with no success. It appears according to the
camel-mongo docs that I can send in a string and that string will be
converted to a DBObject, but that does not appear to work with built-in
types unless I am missing something obvious.

/<convertBodyTo type="String" />
<to
uri="mongodb:mongoBean?database=PMA&amp;collection=Elmah&amp;writeResultAsHeader=true&amp;operation=insert"
/>/

*Error received:*
/org.apache.camel.RuntimeCamelException:
org.apache.camel.component.mongodb.CamelMongoDbException: MongoDB operation
= insert, Body is not conversible to type DBObject nor List<DBObject>/

I have also attempted to convert to a string and then unmarshall using the
Jackson parser, but the parser chokes on the ISODate as I suspect that it
really does not understand the mongo built-in types. 

We do not code in Java and really do everything via Spring DSL. I can likely
manipulate the JSON prior to sending on the exchange to camel-mongo, but
still not sure what that manipulation might look like.

I attempted to change it to this based on my very loose understanding that
this was a possible solution:
/{ "time" : { "$date" : "2016-02-19T17:37:57.673+0000" }}/

But that still did not work as I got the same error as mentioned above. I
could try to get the Object --> DBObject conversion to work, but honestly I
am not sure how to get the JSON string into the form of an Object within
Spring before passing on the exchange to camel-mongo.

Any advice / suggestions are VERY much appreciated.

Thank you!





--
View this message in context: 
http://camel.465427.n5.nabble.com/MongoDB-Jackson-Date-Mapping-Option-tp5727548p5778438.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to