TOraAlerter onEvent

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JFlo
Posts: 9
Joined: Tue 23 Nov 2004 13:31

TOraAlerter onEvent

Post by JFlo » Thu 26 Feb 2015 14:49

Hopelessly trying to get a message from an oracle pipe in a console app.
I can send messages out to a pipe, but i can't receive any message, since the onEvent (nor onTimeOut) is not fired.
I use C++ XE4 upd.1 and ODAC 9.0.2.

Is there something i have to notice when using ODAC TOraAlerter in a console app?

This is an extract of my code:
#include <vcl.h>
#include <windows.h>
#include <tchar.h>
#pragma hdrstop

#include <stdio.h>
#include <iostream.h>

#include <ora.hpp>
#include <OraAlerter.hpp>
#include <OraSQLMonitor.hpp>

TOraSession *dbSession;

class TetkPIP {
private:
TOraAlerter *oraPipe;

void __fastcall onEvent(TObject *Sender, UnicodeString Event, UnicodeString Message)
{
_tprintf(_T("Got: %s/%s"), Event.c_str(), Message.c_str());
}

public:
TetkPIP::TetkPIP() {
try {
oraPipe = new TOraAlerter(NULL);
oraPipe->Session = dbSession;
oraPipe->EventType = etPipe;
oraPipe->AutoCommit = true;
oraPipe->Events = _T("TEST_PIPE");
oraPipe->OnEvent = onEvent;
oraPipe->Start();
}
catch (const Exception &err) {
_tprintf(err.Message.c_str());
}
}
TetkPIP::~TetkPIP(void) {
if (oraPipe->Active) oraPipe->Stop();
}
}; /* TetkPIP */

#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
TetkPIP *pip;

dbSession = new TOraSession(NULL);
dbSession->ConnectString = _T("username/password@service"); // or argv[1]
dbSession->Options->Direct = false;
dbSession->Options->UseOCI7 = false;
dbSession->AutoCommit = false;
dbSession->ThreadSafety = false;
dbSession->Connect();
pip = new TetkPIP(dbSession);
while (true);
delete pip;
dbSession->Disconnect();
delete dbSession;
}

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraAlerter onEvent

Post by AlexP » Mon 02 Mar 2015 11:33

Hello,

A console application doesn't work with Windows message sequence, and since a message sequence is used in OraAlerter, the event won't trigger.

P.S. You can try using Application.ProcessMessages in a while (true) loop;

Post Reply