For thoses who still face the problem with the logging, you have to set the log level of org.mongodb.driver to something higher like WARN or ERROR. The class com.mongodb is not used anymore even if it is still written in the logs.
I created a new module in the marketplace and I load it in the Ignition Gateway. This module is a module with a mongodb jar driver.
This is my module in ignition:
Name Version License Status
MongoDB Driver 2.9.1 (b0) Free Loaded
I created a script in the value changed of one tag:
Value ChangedError executing script.Traceback (most recent call last): File "", line 16, in valueChangedImportError: No module named mongodb ERROR
This error comes out ONLY in the value changed of one tag and in global/shared script.
I tried also in the shared script but I have the same error (I enclose a picture)
Hello everyone,
I have seen that the MongoDB Input/Output steps in PDI CE 9.4 use the mongodb plugin pentaho-mongodb-plugin-9.4.0.0-343 which in its turns it's using the mongo-java-driver-3.12.10. This driver is quite old and is based on the legacy API. Simply replacing the mongo-dava-driver-3.12.10.jar with a newer release (4.4 and above) is not working because it seems to me that some code must be migrated.
Do you know if there is a quick option (plug and play) to update the Mongo java driver? If not, which are the steps to go through in order to migrate the pentaho-mongodb-plugin such that it is compatible with the newer mongodb java driver?
Thank you
thank you for your reply. The problem is not the compatibility of PDI 9.4 CE with MongoDB server itself. The question is related to the upgrade of the mongodb java driver that is wrapped in the pentaho mongodb plugin. Currently this plugin wraps mongodb java driver version 3.12 that implements the old MongoDB API.
While at MongoDB World 2016 I was involved in multiple conversations about unit testing and test driven developmentof data access objects that wrap the MongoDB Java driver. Not two days after returning to work from MongoDB Worldone of the teams I work with was complaining that the 3.x Java driver broke a lot of their testing patterns and thatthey were having difficulties mocking out the driver. I had a few meetings canceled so I decided to sit down andcreate a testing pattern that could be easily implemented and extended using the Mockito libraries.
A side note before we get started. If you are mocking at the driver layer you may want to take a step back andconsider why you are doing it and much of the following code violates the principle of 'Do no mock types you don't own'. However, while I am not going to dive deep into the philosophy of unit testing, I think these testing patterns may be of use to some. My general rule ofthumb is to only test logic, avoid the file system, and assume that the external systems work as advertised. Avoidthe pitfalls of only testing mocks for the sake of testing and make sure you set up integration layers to verifythat the external systems do, in fact, work as advertised. That being said, all the code for the following examplesmay be found here.
This concludes my basic implementation of using Mockito to test implementations of the MongoDB Java driver. I hope you have found it useful. There are some other patterns and tests in the source code that I am working on and my publish more on this later.
Java driver for MongoDB does not provide any utility classes that could help with building update queries. If you wantto create a query to update or increment field values, you usually have to use BasicDBObjectBuilder. This is intuitiveapproach, but queries defined in such a way are quite hard to read and maintain.
The behavior is different than the mongo shell or other drivers which validate the UTF-8 before persistence and use replacement characters such as '?' or U+FFFD to ensure the DB only contains valid UTF-8 strings.
The following compatibility matrix summarizes Spring Data versions to MongoDB driver/database versions.Database versions show the highest supported server version that pass the Spring Data test suite.You can use newer server versions unless your application uses functionality that is affected by changes in the MongoDB server.
Depending on the application one of the mongodb-driver-sync, mongodb-driver-reactivestreams artifacts is is required next to the mandatory mongodb-driver-core.It is possible to combine the sync and reactive drivers in one application if needed.
For most tasks, you should use MongoTemplate or the Repository support, which both leverage the rich mapping functionality. MongoTemplate is the place to look for accessing functionality such as incrementing counters or ad-hoc CRUD operations. MongoTemplate also provides callback methods so that it is easy for you to get the low-level API artifacts, such as com.mongodb.client.MongoDatabase, to communicate directly with MongoDB. The goal with naming conventions on various API artifacts is to copy those in the base MongoDB Java driver so you can easily map your existing knowledge onto the Spring APIs.
One of the first tasks when using MongoDB and Spring is to create a com.mongodb.client.MongoClient object using the IoC container. There are two main ways to do this, either by using Java-based bean metadata or by using XML-based bean metadata. Both are discussed in the following sections.
While com.mongodb.client.MongoClient is the entry point to the MongoDB driver API, connecting to a specific MongoDB database instance requires additional information, such as the database name and an optional username and password. With that information, you can obtain a com.mongodb.client.MongoDatabase object and access all the functionality of a specific MongoDB database instance. Spring provides the org.springframework.data.mongodb.core.MongoDatabaseFactory interface, shown in the following listing, to bootstrap connectivity to the database:
If you need to configure additional options on the com.mongodb.client.MongoClient instance that is used to create a SimpleMongoClientDbFactory, you can refer to an existing bean by using the mongo-ref attribute as shown in the following example. To show another common usage pattern, the following listing shows the use of a property placeholder, which lets you parametrize the configuration and the creation of a MongoTemplate:
The MongoTemplate class implements the interface MongoOperations. In as much as possible, the methods on MongoOperations are named after methods available on the MongoDB driver Collection object, to make the API familiar to existing MongoDB developers who are used to the driver API. For example, you can find methods such as find, findAndModify, findAndReplace, findOne, insert, remove, save, update, and updateMulti. The design goal was to make it as easy as possible to transition between the use of the base MongoDB driver and MongoOperations. A major difference between the two APIs is that MongoOperations can be passed domain objects instead of Document. Also, MongoOperations has fluent APIs for Query, Criteria, and Update operations instead of populating a Document to specify the parameters for those operations.
When in development, it is handy to either log or throw an exception if the com.mongodb.WriteResult returned from any MongoDB operation contains an error. It is quite common to forget to do this during development and then end up with an application that looks like it runs successfully when, in fact, the database was not modified according to your expectations. You can set the WriteResultChecking property of MongoTemplate to one of the following values: EXCEPTION or NONE, to either throw an Exception or do nothing, respectively. The default is to use a WriteResultChecking value of NONE.
You can use the MongoAction argument to determine the WriteConcern value or use the value of the Template itself as a default. MongoAction contains the collection name being written to, the java.lang.Class of the POJO, the converted Document, the operation (REMOVE, UPDATE, INSERT, INSERT_LIST, or SAVE), and a few other pieces of contextual information. The following example shows two sets of classes getting different WriteConcern settings:
df19127ead