public void process(Exchange exchange) throws Exception {
    MongoDbOperation operation = endpoint.getOperation();
    Object header = exchange.getIn().getHeader(MongoDbConstants.OPERATION_HEADER);
    if (header != null) {
      LOG.debug("Overriding default operation with operation specified on header: {}", header);
      try {
        if (header instanceof MongoDbOperation) {
          operation = ObjectHelper.cast(MongoDbOperation.class, header);
        } else {
          // evaluate as a String
          operation =
              MongoDbOperation.valueOf(
                  exchange.getIn().getHeader(MongoDbConstants.OPERATION_HEADER, String.class));
        }
      } catch (Exception e) {
        throw new CamelMongoDbException(
            "Operation specified on header is not supported. Value: " + header, e);
      }
    }

    try {
      invokeOperation(operation, exchange);
    } catch (Exception e) {
      throw MongoDbComponent.wrapInCamelMongoDbException(e);
    }
  }
 /**
  * Sets the operation this endpoint will execute against MongoDB. For possible values, see {@link
  * MongoDbOperation}.
  *
  * @param operation name of the operation as per catalogued values
  * @throws CamelMongoDbException
  */
 public void setOperation(String operation) throws CamelMongoDbException {
   try {
     this.operation = MongoDbOperation.valueOf(operation);
   } catch (IllegalArgumentException e) {
     throw new CamelMongoDbException("Operation not supported", e);
   }
 }