Jackson is not MongoDB-specific and therefore doesn't recognise $date types.

The camel-mongodb component uses MongoDB's JSON class to parse Strings,
which does recognise Mongo-specific types:
http://api.mongodb.org/java/2.6.5/com/mongodb/util/JSON.html.

Can you try sending the JSON string directly to the endpoint, with no
Jackson marshal/unmarshalling?

Cheers,

*Raúl Kripalani*
PMC & Committer @ Apache Ignite, Apache Camel | Integration, Big Data and
Messaging Engineer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
Blog: raul.io | twitter: @raulvk <https://twitter.com/raulvk>

On Fri, Mar 4, 2016 at 9:43 PM, gramanero <graman...@gmail.com> wrote:

> Thank you for the response and information. I believe I tried what is
> recommended in the link that you provided. Below is a copy from the Logs
> via
> the Karaf console. I hope the formatting is not too terrible. I can try and
> provide it another way if necessary.
>
> Pretty much the same result as I was seeing before as I believe I already
> tried this approach. Here is the document that I used: /{ "time" : {
> "$date"
> : "2016-02-19T17:37:57.673+0000" } }/
>
> Here is what is going on in the route (the reason for the tracing is that I
> wanted to see what type the body was being converted to and from...I was
> toying around with different conversions to see if I could come up with
> some
> magic incantation that would work):
> /      <convertBodyTo type="String" />
>       <log message="[TRACE] Before unmarshall - ${body}"/>
>       <unmarshal ref="jsonMarshaller" />
>       <log message="[TRACE] After unmarshall - ${body}"/>
>       <to
>
> uri="mongodb:mongoBean?database=PMA&amp;collection=Elmah&amp;writeResultAsHeader=true&amp;operation=insert"
> />/
>
> And the jsonMarshaller dataformat definition is this:
> /    <dataFormats>
>       <json id="jsonMarshaller" library="Jackson"
> disableFeatures="FAIL_ON_UNKNOWN_PROPERTIES,WRITE_DATES_AS_TIMESTAMPS"/>
>     </dataFormats>
> /
>
> And the Mongo bean definition:
> /  <bean id="mongoBean" class="com.mongodb.Mongo">
>     <constructor-arg index="0">
>       <bean class="com.mongodb.MongoURI">
>         <constructor-arg index="0"
>
> value="mongodb://DEVVLMONGORPLLOGS00.oecapplications.dev:27018/?replicaSet=rsLOGS&amp;connectTimeoutMS=30000&amp;wtimeoutMS=30000&amp;w=1&amp;journal=true"
> />
>       </bean>
>     </constructor-arg>
>   </bean>/
>
>
> Hope this information is helpful. I certainly appreciate someone looking
> into this. We are not Java developers here, but at the moment it feels like
> my next course of action is to write some Java code to customize the
> serializer.
>
> *From the Logs available via the Karaf Console:*
> *3/4/2016, 4:29:33 PM   WARN*   /Execution of JMS message listener failed.
> Caused by: [org.apache.camel.RuntimeCamelException -
> org.apache.camel.component.mongodb.CamelMongoDbException: MongoDB operation
> = insert, Body is not conversible to type DBObject nor List<DBObject>]
> camel-core      org.apache.camel.RuntimeCamelException:
> org.apache.camel.component.mongodb.CamelMongoDbException: MongoDB operation
> = insert, Body is not conversible to type DBObject nor List<DBObject>/
>
> *3/4/2016, 4:29:33 PM   ERROR*  /Failed delivery for (MessageId:
> ID:devvlapifuse01-42307-1456773862280-9:8:3:1:1 on ExchangeId:
> ID-devvlapifuse01-49834-1456773865165-1-9). Exhausted after delivery
> attempt: 1 caught:
> org.apache.camel.component.mongodb.CamelMongoDbException:
> MongoDB operation = insert, Body is not conversible to type DBObject nor
> List<DBObject> Message History
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId ProcessorId Processor Elapsed (ms) [oec.common.logger.]
> [oec.common.logger.] [activemq://queue:oec.common.logger.elmah.request ] [
> 2] [oec.common.logger.] [validate4 ]
> [validate[simple{${in.header.MongoDatabase}}] ] [ 0] [oec.common.logger.]
> [validate5 ] [validate[simple{${in.header.MongoCollection}}] ] [ 0]
> [oec.common.logger.] [log2 ] [log ] [ 0] [oec.common.logger.]
> [convertBodyTo1 ] [convertBodyTo[String] ] [ 0] [oec.common.logger.] [log3
> ]
> [log ] [ 1] [oec.common.logger.] [log4 ] [log ] [ 0] [oec.common.logger.]
> [to1 ]
>
> [mongodb:mongoBean?database=PMA&collection=Elmah&writeResultAsHeader=true&opera]
> [ 1] Exchange
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> Exchange[ Id ID-devvlapifuse01-49834-1456773865165-1-9 ExchangePattern
> InOnly Headers {Accept=*/*, Accept-Encoding=gzip, deflate,
> Accept-Language=en-US,en;q=0.8, AppKey=NfQFDRu7Ogq4xF4hZpMGV0CxdgQCnDPW,
> breadcrumbId=ID-devvlapifuse01-49834-1456773865165-1-8,
> CamelRedelivered=false, CamelRedeliveryCounter=0,
> CamelServletContextPath=/private/common/logger/elmah, Content-Length=59,
> Content-Type=application/json, JMSCorrelationID=null,
> JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2,
> JMSDestination=queue://oec.common.logger.elmah.request, JMSExpiration=0,
> JMSMessageID=ID:devvlapifuse01-42307-1456773862280-9:8:3:1:1,
> JMSPriority=4,
> JMSRedelivered=false, JMSReplyTo=null, JMSTimestamp=1457126973022,
> JMSType=null, JMSXGroupID=null, JMSXUserID=null, MongoCollection=Elmah,
> MongoDatabase=PMA,
> Origin=chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop,
> Postman-Token=fc4ab341-5fbb-fb41-d0ad-c30cc7c3c30a, TestType=2} BodyType
> String Body { "time" : { "$date" : "2016-02-19T17:37:57.673+0000" } }
>  ] Stacktrace
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> camel-core      org.apache.camel.component.mongodb.CamelMongoDbException:
> MongoDB
> operation = insert, Body is not conversible to type DBObject nor
> List<DBObject>/
>
>
> *3/4/2016, 4:29:33 PM   WARN*   /Conversion has fallen back to generic
> Object ->
> DBObject, but unable to convert type org.apache.camel.impl.DefaultMessage.
> Returning null.         camel-mongodb/
>
>
> *3/4/2016, 4:29:33 PM   INFO*   /[TRACE] After unmarshall - { "time" : {
> "$date"
> : "2016-02-19T17:37:57.673+0000" } }
>                 camel-core      /
>
>
> *3/4/2016, 4:29:33 PM   INFO*   /[TRACE] Before unmarshall - { "time" : {
> "$date" : "2016-02-19T17:37:57.673+0000" } }
>                 camel-core      /
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-insert-Date-String-as-date-in-MongoDB-tp5778310p5778652.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to