0
votes

I need to poll data from MongoDB, process the data, while it is being processed, I must update that status of the data in DB as "PROCESSED" using MongoDB outbound channel.

When I query the MongoDB using the inbound channel, I get a list of Objects.

I use a transformer which traverses this list and updates the status as "PROCESSING".

When I pass this updated list, wrapped as payload, to the outbound MongoDB channel, hoping it would update status if all the elements in the DB, I get an exception.

BasicDBObject can not be cast to BasicDBList

how to proceed here?

1

1 Answers

0
votes

You know, sounds like a bug in the Spring Data MongoDB. We have there a code like in the MongoTemplate.toDocument():

 if (!(objectToSave instanceof String)) {
        Document dbDoc = new Document();
        writer.write(objectToSave, dbDoc);

And after that we jump to the MappingMongoConverter.writeInternal():

    if (Collection.class.isAssignableFrom(entityType)) {
        writeCollectionInternal((Collection<?>) obj, ClassTypeInformation.LIST, (BasicDBList) bson);
        return;
    }

Where we indeed can't cast to the BasicDBList because our original bson is just that Document.

You can consider to use Splitter before modifying each entity and storing them into DB back individually, not as a list.