You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Welly Hong (Jira)" <ji...@apache.org> on 2020/10/07 14:47:00 UTC
[jira] [Commented] (CAMEL-15646) camel-mongodb - Batch insert does
not work
[ https://issues.apache.org/jira/browse/CAMEL-15646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17209594#comment-17209594 ]
Welly Hong commented on CAMEL-15646:
------------------------------------
The issue only happened in Camel Spring boot project. The insert object returns null in the camel java project but not in Camel Spring boot project.
After debugged, I found exchange.getContext() is using org.apache.camel.spring.boot package in the Camel Spring boot project. But in the Camel java project, exchange.getContext() is using org.apache.camel.impl package.
logger.info(exchange.getContext().getClass().getPackageName());
> camel-mongodb - Batch insert does not work
> ------------------------------------------
>
> Key: CAMEL-15646
> URL: https://issues.apache.org/jira/browse/CAMEL-15646
> Project: Camel
> Issue Type: Bug
> Components: camel-mongodb
> Reporter: Claus Ibsen
> Priority: Major
> Fix For: 3.6.0
>
>
> Can somebody help to create a jira for this because I don't have the permission?
> Please use below codes to reproduce.
> @Named("ConvertType")
> @Log4j2
> public class ConvertType implements Processor { private static final Logger logger = LoggerFactory.getLogger(ConvertType.class); @Override
> public void process(Exchange exchange) {
> Document a = new Document(MongoDbConstants.MONGO_ID, "testInsert1");
> a.append("MyId", 1).toJson();
> Document b = new Document(MongoDbConstants.MONGO_ID, "testInsert2");
> b.append("MyId", 2).toJson();
> Document c = new Document(MongoDbConstants.MONGO_ID, "testInsert3");
> c.append("MyId", 3).toJson();
> List<Document> taxGroupList = new ArrayList<Document>();
> taxGroupList.add(a);
> taxGroupList.add(b);
> taxGroupList.add(c);
> exchange.getIn().setBody(taxGroupList);
> // From MongoDbProducer.java#L428
> // https://github.com/apache/camel/blob/af7e383e9fc1d25ce9665f74d33672cc5b507952/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java#L428
> Object insert = exchange.getContext().getTypeConverter().tryConvertTo(Document.class, exchange, exchange.getIn().getBody());
> if (insert == null)
> logger.info(Document.class.getTypeName() + " mismatched with " + exchange.getIn().getBody().getClass().getTypeName());
> else
> logger.info(Document.class.getTypeName() + " matched with " + exchange.getIn().getBody().getClass().getTypeName());
> } }
> from(fromKafka) .process("ConvertType");
--
This message was sent by Atlassian Jira
(v8.3.4#803005)