webMethods

 View Only

 Borrow a connection from the _webMethods Integration Server_'s Connection Manager

Jump to  Best Answer
Feng Sian's profile image
Feng Sian posted Wed March 26, 2025 03:47 PM

The question is how to borrow an [adapter] connnection from the webMethods Integration Server's Connection Manager (in my current case, I'm looking for a MongoDB connection), and later, return the connection back?

Why I'm looking for this?

It would be nice (an probably simplify the checklist process) that when a package (that depends on for ex. database objects) loads, it performs some verifications - checking whether some indexes are there and so on.

The idea of being able to borrow and return connections from the Connection Manager - is to automate the process, without having to require additional connection configurations.

-- update --

Initially, this question arised due to a issue (how to ensure that some indexes (MongoDB) were in place), and I was not aware that such kind of info could be fetched using 'Dynamic Query Executor' MongoDB Adapter Services.

As @Theo Ezell pointed out, this adapter, along with the structure the input `query` must comply (refer his post marked as 'best answer' and, if needed, to the https://www.mongodb.com/docs/manual/reference/command/nav-administration/ ), can fetch the information sought.

Therefore, the original question does not need to be answered anymore since there is another way oput to accomplish the same goal.

Thanks for your time, @Theo Ezell.

Theo Ezell's profile image
Theo Ezell  Best Answer

@Feng Sian - I don't have an environment to test on, but I have a couple of techniques you could try.

  1. The MongoDB adapter has a Dynamic Query Executor service template. The query gets passed as a JSON document. So, you could try something like:

  {
      listIndexes: "<collection-name>",
      cursor: { batchSize: <int> },
      comment: <any>
   }

2. If using the JDBC adapter, then you could try using the DynamicSQL (or CustomSQL if you don't need to pass in parameters) with the following.

db.runCommand (
   {
      listIndexes: "<collection-name>",
      cursor: { batchSize: <int> },
      comment: <any>
   }
)

Rupinder Singh's profile image
Rupinder Singh

Can you explain what you mean by borrow a connection ? The only thing that you can do with a connection is to use it. So if you invoke a service that uses the connection, essentially you are borrowing it and returning it to the pool afterwards. So some clarity on the use case would be helpful

Engin Sarlak's profile image
Engin Sarlak

Are you referring to the connections in Settings -> JDBC pools or webMethods Adapter for JDBC? Please provide a screenshot for the connections you are referring to. Also I agree, I am not sure what you mean by barrowing a connection. If you use JDBC adapter services, it takes a connection from the pools in webMethods Adapter for JDBC, and then it returns it back.

Feng Sian's profile image
Feng Sian

@Rupinder Singh, by "borrowing an [adapter] connection" I actually meant borrowing a connection from a Adaprter Connection Pool, managed by the IS's Connection Manager.

This connection can be a MongoDB Connection or a JDBC Connection - hence I used the more generic term "Adapter Connection", as it could be any kind of connection - depending on the type of check.

The reasoning behind it this is to check whether the expected database components are in place. This might seem to be an overkill (or over-engineering), but such sanity-check is necessary, as we are always "short of hands" to check why things go "not as expected". And access to he underlying database is not something quick, hence anything that eases these kinds of check is welcome.

@Engin Sarlak The "Adapter Connection" I'm referring to are the adapter connnections set up using the IS Admin > Adapters > webMethods Adapter for <whatever adapter in there, it could be JDBC, MongoDB, etc.)>.

Rupinder Singh's profile image
Rupinder Singh

I still don't understand. Lets assume you can borrow a connection. What would you specifically do with it. That would help me understand what you mean.

engin sarlak's profile image
engin sarlak

I didn't understand what you mean either. You can write a simple custom query or use select adapter services to check if the table and the connection are still there, and when you run it it will get a connection from the pool and it will return it to the pool after running the query. I am also not sure about what you are trying to detect. What do you expect to go wrong that needs a sanity check? DBs are usually very stable. If your tables are disappearing or something, that means you have some critical permission issues in your DB. I don't think the integration layer is the right place for this task. Are your tables managed by code? Is that what you are looking for? 

Theo Ezell's profile image
Theo Ezell

I'm not sure if this answers your question, but both MongoDB and JDBC adapter services take an optional input called $connectionName. You can pass in the fully qualified name of the connection you want to test, and it will use that connection for the call. This allows you have a generic test service that maybe takes in a connection name, a collection name and the expected indexes, and checks if the expected indexes are there. 

Feng Sian's profile image
Feng Sian

@Rupinder Singh,the idea is to issue db commands. Perhaps some clarifications here.

On a relational database, we can access some the "object catalog" for checkeing whether the conditions are met (whether the index X is there or not). And such action can be done using a usual SELECT (eg SELECT * FROM USEROBJECTS et all).

However, on MongoDB, the things are not so easy: in order to get the index list, we need to issue commands that aren't available as adapter services. Eg. getting the list of indexes a collection sports would be like (using `mongosh`) `db.collection.getIndexes()`. However, such command is not available as an adapter service (at least not on IS 10.11).

@Engin Sarlak, you're absolutely right. However, these concepts remain true only if you have dependable and good-quality providers, that can watch and respond quickly when things go wrong. 

Feng Sian's profile image
Feng Sian

@Theo Ezell, that _would work_ - but, since "my pain" is actually with MongoDB and there is no adapter service available for running commands like the "db.collection.getIndexes()", this won't work for me...

Rupinder Singh's profile image
Rupinder Singh

The JDBC adapter also has the ExecuteService template that allows you to use a JDBC connection in your own java service.

Feng Sian's profile image
Feng Sian

@Theo Ezell thanks for the examples! I tested the MongoDB-related portion, and it works!

And I wonder what are the other commands that I could employ - perhaps some sort of `createIndex`?

Theo Ezell's profile image
Theo Ezell

If listIndexes works, I would thin createIndexes would too. Here's a reference for you:

Administration Commands - Database Manual v8.0 - MongoDB Docs