Adapter for MongoDB 9.12 | webMethods Adapter for MongoDB Documentation | webMethods Adapter for MongoDB Installation and User’s Guide Documentation | Adapter for MongoDB Connections | Dynamically Changing a Service's Connection at Run Time
 
Dynamically Changing a Service's Connection at Run Time
You can run a service using a connection other than the default connection that was associated with the service when the service was created.
Important:
At run time, you can change either the credentials (user name and password) or the connection name associated with a specific service, but not both at the same time. If you override both the credentials and the connection name, Adapter for MongoDB takes into account only the connection name override.
To override the default connection, you must code your flow to pass a value through the pipeline into a service's $connectionName field.
For example, you have a flow whose primary purpose is to update a production database. However, you want the flow to have the capability to update a test database, with the decision of which database to update to be made programmatically at runtime. The output signature of the flow's first service contains a field called Target. The flow could branch based on the value in Target. If Target contains the value Production, the second service in the flow would ignore $connectionName, thus using its default connection to connect to (and then update) the production database. However, if Target contains the value Test, the second service in the flow would use the value in the $connectionName from the pipeline and connect to (and then update) the test database.