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");