Page 1 of 1

Can't get the OracleAlerter to work

Posted: Mon 05 Jan 2009 14:17
by StefanL
Hi,

I'm trying to get the OracleAlerter to work. I'm on CoreLab.Oracle 4.60.33.0 (updating is not an option right now)..

Im using it like this:

_Alerter = new OracleAlerter(_Connection, "DATAUPDATE");
_Alerter.Alert += alerter_Alert;
_Alerter.Start();

On the database I'm triggering the alert like this:

sys.dbms_alert.signal('DATAUPDATE','test');

However the alerter_Alert-Method is never called. I have noticed (in the db-monitor) that no sys.dbms_alert.register or sys.dbms_alert.waitany-statements are executed.

I'm quite sure that everything's set up properly on the db, because it works with another (delphi)-component.

Can you tell me what I'm missing?

Cheers
Stefan

Posted: Tue 06 Jan 2009 13:56
by Shalex
Try setting the Timeout and Interval properties of the OracleAlerter object before calling the Start() method.
E.g.:

Code: Select all

_Alerter = new OracleAlerter(_Connection, "DATAUPDATE");
_Alerter.Alert += alerter_Alert;
_Alerter.Timeout = 1000;
_Alerter.Interval = 0;
_Alerter.Start();
Please notify us about the results.

Posted: Tue 06 Jan 2009 14:54
by StefanL
I've tried it, but unfortunately it didn't work.

Posted: Thu 08 Jan 2009 10:28
by Shalex
Have you tried to run our Alerter sample? You can get it here: Start menu | All Programs | CoreLab OraDirect .NET| Samples | General | Run Compliled Samples, the Technology demos part, the Alerter sample. Does it work normally? If yes - check our sample code (maybe, you will find it useful to resolve the issue), if not - please specify the error text.

Posted: Fri 09 Jan 2009 10:34
by StefanL
I can't get the Samples to work neither. When I click one of the two Start-buttons in the demo I get a InvalidOperationException, "cross thread operation not valid".

Stacktrace:

at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, Int32 lparam)
at System.Windows.Forms.ToolBarButton.GetPushedState()
at System.Windows.Forms.ToolBarButton.get_Pushed()
at Samples.MainFormBase.monitor_TraceEvent(Object sender, MonitorEventArgs e) in C:\Programme\CoreLab\OraDirect.NET2\Samples\WinForms\CS\MainFormBase.cs:
bei CoreLab.Common.DbMonitor.OnTraceEvent(Object sender, MonitorEventArgs e)

Is there a fixed version of the samples available that work with my CoreLab-Version?

Posted: Fri 09 Jan 2009 12:46
by Shalex
We have just checked. This exception arises in the current sample also, but it is handled. The sample works. You can disable OracleMonitor (set the Active property to false) to avoid this error.

We have also checked the 4.60.33.0 version of OraDirect .NET (as you said, it is installed on your computer now). The code you have posted earlier is working normally if the Timeout property of the OracleAlerter object is initialized properly (by default, its value is 0 - you need to change it). Please try the following code again:

Code: Select all

_Alerter = new OracleAlerter(_Connection, "DATAUPDATE");
_Alerter.Alert += alerter_Alert;
_Alerter.Timeout = 1000;
_Alerter.Interval = 0;
_Alerter.Start();
The alerter_Alert method is called after the execution of the next function on the database side:
sys.dbms_alert.signal('DATAUPDATE','test');

Posted: Tue 13 Jan 2009 11:38
by StefanL
I've tried it exactly the way you told me to, but it still does not work (the alerter_Alert-Method is not called upon sys.dbms_alert.signal). Are there other parameters (maybe properties on the OracleConnection-object) which could affect the alerter?

When you create the Alerter-object, do you see any sys.dbms_alert.register or sys.dbms_alert.waitany statements in the monitor? I don't see them, but they seem to be necessary to wire things up on the db-side.

Posted: Tue 13 Jan 2009 13:48
by Shalex
My connection string is "user id=xxx; password=xxx; server=ora1020; Direct=false;".

DBMonitor contains only record about opening connection (neither sys.dbms_alert.register nor sys.dbms_alert.waitany ).

Please check if your user has permissions for executing the SYS.DBMS_ALERT package. Does this package exist? If not, make an additional installation to your Oracle server.

Posted: Wed 14 Jan 2009 07:16
by mirkof
Hi,

the Package DBMS_ALERT Package is installed and granted to the user, who starts the alerter. We've tested it with our old delphi Clients (they are using the doa components to connect to oracle) and this works perfectly. (same database, same oracle user)

So this can't be the problem. Does your component needs any extra "rights", to use this feature ? (e.g. execute with GRANT OPTION ? )

Best regards,
Mirko

Posted: Wed 14 Jan 2009 11:15
by Shalex
To make sys.dbms_alert.register and sys.dbms_alert.waitany records visible in DBMonitor change your code in this way:

Code: Select all

[MTAThread]
static void Main() {
}
Otherwise, the inner exception is thrown in parallel thread, and it is handled.
Probably, you don't see all exceptions that take place. Enable Debug\Exceptions\CommonLanguageRuntimeExceptions and uncheck Tools\Options\Debugging\EnableJustMyCode.
What exceptions do you get in this case? Please send us the error text.