We are using WLS servers, on which we configure data sources (DS) and managed servers.
For failover reasons, our main application is depolyed on two separate managed servers (lets call them app_1 and app_2) - but both of those servers use the same data source.
The data source is a JDBC data source to an Oracle DB.
+-----------------------------+
| WLS Domain |
|-----------------------------|
|+------------+ +------------+|
|| | | ||
|| app_1 | | app_2 ||
|| | | ||
|+-----|------+ +-----|------+|
|+-----v--------------v------+|
|| Data Source ||
|+-------------|-------------+|
+--------------|--------------+
|
+-----V-----+
| | session1, session2, session3, ...
| ORACLE DB |
| | ~is session1 from app_1 or app_2?
+-----------+
Now our issue:
- We would like to be able to identify, on the DB side, on which managed server a certain DB session originates (i.e. app_1 or app_2).
The problem is:
As both manged servers access the same data source, the DB sessions which are opened on the DB are (so far) indistinguishable. Is this a problem that can be solved? Or is the way WLS managed servers use a domain configured data source just set up in a way that makes the managed server totally invisibly to the DB backend?
We already tried adding session meta information to the Oracle DB session using the 'init SQL' mechanism. But as the data source is setup in a server-agnostic way the init SQL cannot contain any info concerning the managed server that will eventually use it.
If your managed servers are on the same host, I believe there is no native way to find this out. If they're on different hosts, you can use the machine column on v$session on Oracle side to identify where it's coming from.
The other option is to use some monitoring/profiling tool. I'm not sure which ones would tell you the session id on the database but they can definitely tell you what was done on the database. Tools I have used that can do this are: - Oracle Enterprise Manager with JVM Diagnostics installed; - CA IntroScope (now called CA APM I believe); - Compuware Dynatrace; - AppDynamics.
I'm sure there are many more.