Author |
Message
|
ENVYMB |
Posted: Thu Dec 19, 2013 11:52 pm Post subject: Database connection from Compute node |
|
|
Newbie
Joined: 19 Nov 2013 Posts: 7
|
Hi All,
I am using a ODBC connection to database from compute node which is working fine. Configuration is as below.
I have set a datasource name in compute node property.
I have declared shared row as below.
DECLARE v_Row SHARED ROW;
And the code is as below
IF v_Row .valid IS NULL THEN
SET v_Row .vship[] = (SELECT T.A,T.B,T.C,T.D FROM Database.table AS T );
SET v_Row .valid = TRUE;
END IF;
SET outLocalEnvRef.Variables.vShip[] = SELECT T.D FROM v_Row .vship[] AS T WHERE T.A = refIn.(XMLNSC.Attribute)A AND T.B= refIn.(XMLNSC.Attribute)BAND T.C= refIn.Extn.(XMLNSC.Attribute)C;
That means database records are fetched only if v_Row .valid is null.
now that i have tested this flow with multiple samples i have v_Row .valid = TRUE.
I recently observed that database that i am trying to connect was down and messages went to error queue.
So my question is will message flow trys to initiate databse connection even if code is not trying to fetch anything from databse? in my case v_Row.valid is TRUE. so code should fetch from v_Row .vship[] instead from database. Even in this case database being down is a problem?
Thanks,
ENVYMB |
|
Back to top |
|
 |
Esa |
Posted: Fri Dec 20, 2013 12:01 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
The problem is presumably with your test:
Code: |
IF v_Row .valid IS NULL THEN |
Test like this and you don't need the variable valid at all:
Code: |
IF NOT EXISTS(v_Row .vship[]) THEN |
|
|
Back to top |
|
 |
dogorsy |
Posted: Fri Dec 20, 2013 12:17 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
Esa wrote: |
The problem is presumably with your test:
Code: |
IF v_Row .valid IS NULL THEN |
Test like this and you don't need the variable valid at all:
Code: |
IF NOT EXISTS(v_Row .vship[]) THEN |
|
This change has nothing to do with the database.
If the message flow contains a value in the datasource, WMB will try to establish connection to that datasource, regardless of whether it is accessed by the code or not. So the answer to the OP is YES. |
|
Back to top |
|
 |
ENVYMB |
Posted: Fri Dec 20, 2013 1:32 am Post subject: |
|
|
Newbie
Joined: 19 Nov 2013 Posts: 7
|
Thank you dogorsy
So messages failing on db connectivity issue is normal even if code is not accessing db. I will not have to change anything in code.
I believe statements
IF v_Row .valid IS NULL THEN
and
IF NOT EXISTS(v_Row .vship[]) THEN
perform same action
Thanks,
ENVYMB |
|
Back to top |
|
 |
Esa |
Posted: Fri Dec 20, 2013 5:08 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
ENVYMB wrote: |
So messages failing on db connectivity issue is normal even if code is not accessing db. |
I disagree. I tested a flow where a compute node had a datasource that could not be connected. The esql code did not use the datasource. Test messages went through the flow and no exceptions were thrown.
Messages can fail if the database connection is down when the first ans subsequent message after flow restart try to populate the cache. But if the cache is populated and the values are fetched from there, a database connection that is not used when processing the message should not throw any exception.
Are you sure that the flow does not hit the database for every message? Have you verified it with user trace? |
|
Back to top |
|
 |
manoj5007 |
Posted: Mon Dec 23, 2013 12:56 am Post subject: |
|
|
 Acolyte
Joined: 15 May 2013 Posts: 64
|
@Esa
In my code data is fetched from DB. I did some modifications where the data is being read from file instead of DB and so made changes wherever connection to DB was established.
So though there is no DB connection involved within the ESQL and under DataSource I have given a invalid DSN name, I get the Datasource exception.
So I am not sure how come you didnt get any exception inspite of an invalid Datasource being mentioned. Please share your comments on scenarios where we will not be encountering such an exception with an invalid Datasource. |
|
Back to top |
|
 |
|