| Namespace | http://www.mulesoft.org/schema/mule/mongo |
|---|---|
| Schema Location | http://www.mulesoft.org/schema/mule/mongo/2.0/mule-mongo.xsd |
| Version | 2.0 |
| Minimum Mule Version | 3.2 |
A Mongo Connector Facade
| Configuration | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Configure an instance of this module
| |||||||||||
| Message Processors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Counts the number of objects that match the given query.
| |||||||||||
Counts the number of objects that match the given query.
| |||||||||||
Creates a new collection.
| |||||||||||
Creates a new GridFSFile in the database, saving the given content, filename,
contentType, and extraData, and answers it.
| |||||||||||
Creates a new index
| |||||||||||
Deletes a collection and all the objects it contains.
| |||||||||||
Drops an existing index
| |||||||||||
Answers if a collection exists given its name
| |||||||||||
Lists all the files that match the given query
| |||||||||||
Lists all the files that match the given query
| |||||||||||
Finds all objects that match a given query.
| |||||||||||
Finds all objects that match a given query.
| |||||||||||
Answers the first file that matches the given query.
| |||||||||||
Answers the first file that matches the given query.
| |||||||||||
Finds the first object that matches a given query.
| |||||||||||
Finds the first object that matches a given query.
| |||||||||||
Answers an inputstream to the contents of the first file that matches the
given query.
| |||||||||||
Answers an inputstream to the contents of the first file that matches the
given queryAttributes.
| |||||||||||
Inserts an object in a collection, setting its id if necessary.
| |||||||||||
Inserts an object in a collection, setting its id if necessary.
| |||||||||||
Lists names of collections available at this database
| |||||||||||
Lists all the files that match the given query, sorting them by filename.
| |||||||||||
Lists all the files that match the given query, sorting them by filename.
| |||||||||||
List existent indices in a collection
| |||||||||||
Transforms a collection into a collection of aggregated groups, by applying a
supplied element-mapping function to each element, that transforms each one
into a key-value pair, grouping the resulting pairs by key, and finally
reducing values in each group applying a suppling 'reduce' function.
| |||||||||||
Removes all the files that match the given query.
| |||||||||||
Removes all the files that match the given query.
| |||||||||||
Removes all the objects that match the a given optional query.
| |||||||||||
Removes all the objects that match the a given optional query.
| |||||||||||
Inserts or updates an object based on its object _id.
| |||||||||||
Inserts or updates an object based on its object _id.
| |||||||||||
Updates objects that matches the given query.
| |||||||||||
Updates objects that matches the given query.
| |||||||||||
| Transformers | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Convert a BasicBSONList into Json.
| |||||||||||
Convert a DBObject into Map.
| |||||||||||
Convert DBObject to Json.
| |||||||||||
Convert JSON to DBObject.
| |||||||||||
Convert a BasicBSONList into Json.
| |||||||||||
To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mongo
http://www.mulesoft.org/schema/mule/mongo/2.0/mule-mongo.xsd">
<!-- here goes your flows and configuration elements -->
</mule>
This module is configured using the config element. This element must be placed outside of your flows and at the root of your Mule application. You can create as many configurations as you deem necesary as long as each carries its own name.
Each message processor, message source or transformer carries a config-ref attribute that allows the invoker to specify which configuration to use.
| Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | Name | Default Value | Description | Optional. Give a name to this configuration so it can be later referenced. | |||||||
| test | Optional. The database name of the Mongo server | ||||||||||
| localhost | Optional. The host of the Mongo server | ||||||||||
| 27017 | Optional. The port of the Mongo server | ||||||||||
This connector offers automatic connection management via the use of a connection pool. The pool will act a storage mechanism for all the connections that are in-use by the user of this connector.
Prior to execution of a processor, the connector will attempt to lookup an already established connection and if one doesn't exists it will create one. That lookup mechanism is done in the connection pool via the use of connection variables declared as keys.
The user of the connector can configure the pool by adding a connection-pooling-profile to the connector configuration like this:
<mongo:connection-pooling-profile maxActive="10" maxIdle="10"
exhaustedAction="WHEN_EXHAUSTED_GROW" maxWait="120"/>
The following is a list of connection attributes, each connection attribute can be configured at the config element level or they can also be added to each processor. If they are used at the processor level they get the benefit of full expression resolution.
| Connection Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Name | Description | ||||||||||
| The username to use in case authentication is required |
|||||||||||
| The password to use in case authentication is required, null
if no authentication is desired |
|||||||||||
Also this connector offers automatic retry for certain operations. There are a couple of situations in which a retry may solve the problem at hand, like for example if the system is currently busy or if the session has expired. Those kind of situations are solvable by reacquiring a connection and retrying the operation.
By default, the connector will automatically attempt to retry the operation only once. You can at your choosing specify a greater ammount of retries by using the retryMax attribute on each operation.
... retryMax="3"/>
Counts the number of objects that match the given query. If no query is passed, returns the number of elements in the collection
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| Optional. The optional DBObject query for counting objects. Only objects matching it will be counted. If unspecified, all objects are counted. |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Counts the number of objects that match the given query. If no query is passed, returns the number of elements in the collection
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| Optional. The optional query for counting objects. Only objects
matching it will be counted. If unspecified, all objects are
counted. |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Creates a new collection. If the collection already exists, a MongoException will be thrown.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection to create |
||
| Optional. If the collection will be capped |
||
| Optional. The maximum number of documents the new collection is able
to contain |
||
| Optional. The maximum size of the new collection
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Creates a new GridFSFile in the database, saving the given content, filename, contentType, and extraData, and answers it.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The mandatory content of the new gridfs file. It may be a
java.io.File, a byte[] or an InputStream. |
||
| The mandatory name of new file. |
||
| Optional. The optional content type of the new file |
||
| Optional. The optional DBObject metadata of the new content type |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
| IOException |
|---|
Creates a new index
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection where the index will be created |
||
| The name of the field which will be indexed |
||
| Optional. The indexing order
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Deletes a collection and all the objects it contains. If the collection does not exist, does nothing.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection to drop
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Drops an existing index
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection where the index is |
||
| The name of the index to drop
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Answers if a collection exists given its name
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Lists all the files that match the given query
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. A DBObject query the optional query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Lists all the files that match the given query
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. The optional query attributes |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Finds all objects that match a given query. If no query is specified, all objects of the collection are retrieved. If no fields object is specified, all fields are retrieved.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| Optional. The optional DBObject query object. If unspecified, all documents are returned. |
||
| Optional. Alternative way of passing fields as a literal List |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Finds all objects that match a given query. If no query is specified, all objects of the collection are retrieved. If no fields object is specified, all fields are retrieved.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| Optional. The optional query object. If unspecified, all
documents are returned. |
||
| Optional. Alternative way of passing fields as a literal List |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Answers the first file that matches the given query. If no object matches it, a MongoException is thrown.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The DBObject mandatory query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Answers the first file that matches the given query. If no object matches it, a MongoException is thrown.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The mandatory query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Finds the first object that matches a given query. Throws a
MongoException if no one matches the given query
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| The mandatory DBObject query object that the returned object matches. |
||
| Optional. Alternative way of passing fields as a literal List |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Finds the first object that matches a given query. Throws a
MongoException if no one matches the given query
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The target collection |
||
| The mandatory query object that the returned object
matches. |
||
| Optional. Alternative way of passing fields as a literal List |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Answers an inputstream to the contents of the first file that matches the given query. If no object matches it, a MongoException is thrown.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The DBObject mandatory query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Answers an inputstream to the contents of the first file that matches the given queryAttributes. If no object matches it, a MongoException is thrown.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The mandatory query attributes |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Inserts an object in a collection, setting its id if necessary.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection where to insert the given object |
||
| A DBObject instance. |
||
| Optional. The optional write concern of insertion |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Inserts an object in a collection, setting its id if necessary.
A shallow conversion into DBObject is performed - that is, no conversion is performed to its values.INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection where to insert the given object |
||
| Optional. Alternative way of specifying the element as a
literal Map inside a Mule Flow |
||
| Optional. The optional write concern of insertion |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Lists names of collections available at this database
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Lists all the files that match the given query, sorting them by filename. If no query is specified, all files are listed.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. The DBObject optional query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Lists all the files that match the given query, sorting them by filename. If no query is specified, all files are listed.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. The optional query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
List existent indices in a collection
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Transforms a collection into a collection of aggregated groups, by applying a supplied element-mapping function to each element, that transforms each one into a key-value pair, grouping the resulting pairs by key, and finally reducing values in each group applying a suppling 'reduce' function.
Each supplied function is coded in JavaScript. Note that the correct way of writing those functions may not be obvious; please consult MongoDB documentation for writing them.INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection to map and reduce |
||
| A JavaScript encoded mapping function |
||
| A JavaScript encoded reducing function |
||
| Optional. The name of the output collection to write the
results, replacing previous collection if existed, mandatory when
results may be larger than 16MB. If outputCollection is
unspecified, the computation is performed in-memory and not
persisted. |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Removes all the files that match the given query. If no query is specified, all files are removed
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. The DBObject optional query |
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Removes all the files that match the given query. If no query is specified, all files are removed
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| Optional. The optional query
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Removes all the objects that match the a given optional query. If query is not specified, all objects are removed. However, please notice that this is normally less performant that dropping the collection and creating it and its indices again
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The collection whose elements will be removed |
||
| The optional DBObject query object. Objects that match it will be removed. |
||
| Optional. The write concern used to remove the object
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Removes all the objects that match the a given optional query. If query is not specified, all objects are removed. However, please notice that this is normally less performant that dropping the collection and creating it and its indices again
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The collection whose elements will be removed |
||
| The query object. Objects that match it will be
removed. |
||
| Optional. The write concern used to remove the object
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Inserts or updates an object based on its object _id.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The collection where to insert the object |
||
| The mandatory DBObject object to insert. |
||
| Optional. The write concern used to persist the object
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Inserts or updates an object based on its object _id.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The collection where to insert the object |
||
| The mandatory object to insert. |
||
| Optional. The write concern used to persist the object
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Updates objects that matches the given query. If parameter multi is set to false, only the first document matching it will be updated. Otherwise, all the documents matching it will be updated.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection to update |
||
| The DBObject query object used to detect the element to update. |
||
| The DBObject mandatory object that will replace that one which matches the query. |
||
| Optional. If the database should create the element if it does not exist |
||
| Optional. If all or just the first object matching the query will be
updated |
||
| Optional. The write concern used to update
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |
Updates objects that matches the given query. If parameter multi is set to false, only the first document matching it will be updated. Otherwise, all the documents matching it will be updated.
INCLUDE_ERROR
| Optional. Specify which configuration to use. | ||
| The name of the collection to update |
||
| The query object used to detect the element to update. |
||
| The mandatory object that will replace that one which
matches the query. |
||
| Optional. If the database should create the element if it does not exist |
||
| Optional. If all or just the first object matching the query will be
updated |
||
| Optional. The write concern used to update
|
||
| 1 | Optional. Specify how many times this operation can be retried automatically | |
| Optional. The username to use in case authentication is required |
||
| Optional. The password to use in case authentication is required, null
if no authentication is desired |