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;
}
TOraAlerter onEvent
Re: TOraAlerter onEvent
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;
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;