Author |
Message
|
angka |
Posted: Mon Jul 17, 2006 5:02 am Post subject: Message Exit accessing MS SQL database |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
I am trying to log all incoming and outgoing messages to the MS SQL so my exit will call and pass in the parameter to be logged to C coded database function. However, I encountered a problem. The return code I got from SQLConnect is -1. I compiled the similiar function to .exe and it works. What additional configuration I need to make it work on exit. BTW the platform I working on is Windows. Thanks alot. |
|
Back to top |
|
 |
Mr Butcher |
Posted: Mon Jul 17, 2006 5:36 am Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
do you also get a reason code? maybe a security problem? (is the userid the mca is running on allowed to access the database?) _________________ Regards, Butcher |
|
Back to top |
|
 |
angka |
Posted: Mon Jul 17, 2006 6:03 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Can't get the SQLstate working. Btw the userid i specified is mqm. it run normally on the .exe but not in the exit. Thanks |
|
Back to top |
|
 |
angka |
Posted: Mon Jul 17, 2006 7:40 pm Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi all,
Anyone tried inserting to MS SQL server in exit before?? Thanks
Rgds |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Jul 17, 2006 8:50 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
Try separating your code into 2 separate DLLs: 1 DLL (A) for Message Exit and another DLL (B) for the database updates. Then have DLL (A) call DLL (B) to do the work.
I have found issues when you put certain external function calls into an MQ exit.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
angka |
Posted: Tue Jul 18, 2006 1:01 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi Roger,
Thanks. Do you have any link that uses C to call the dll. sorry for the trouble cos i cant find any...
Thanks |
|
Back to top |
|
 |
angka |
Posted: Tue Jul 18, 2006 3:04 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi all,
This is my code.
switch(pMQCXP -> ExitId)
{
case MQXT_CHANNEL_MSG_EXIT:
switch(pMQCXP->ExitReason)
{
.....
case MQXR_MSG:
if ((fp=fopen("c:\\Test\\qclamp.log","a")) == NULL)
{}
else
{
........
// Allocate memory for ODBC Environment handle
SQLAllocEnv (&hEnv);
// Allocate memory for the connection handle
SQLAllocConnect (hEnv, &hDBC);
fprintf(fp,"Testing start1\n");
// Connect to the data source "db97" using userid and password.
retcode = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPasswd, SQL_NTS);
fprintf(fp, "1 => * %d * --\n", retcode);
//here I get the retcode as -1
fclose(fp);
}
break;
case MQXR_TERM:
break;
}
break;
case MQXT_CHANNEL_SEND_EXIT:
break;
case MQXT_CHANNEL_RCV_EXIT:
break;
case MQXT_CHANNEL_SEC_EXIT:
break;
default:
break;
}
Please help.. Thanks |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Jul 19, 2006 9:19 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
|
Back to top |
|
 |
angka |
Posted: Thu Jul 20, 2006 1:58 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Sorry I know tt is some basic question. I doing exit for a few projects but never try using .lib file before. thanks. Btw no one in the forum did access database using exit before?? |
|
Back to top |
|
 |
wschutz |
Posted: Thu Jul 20, 2006 2:05 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
I wouldn't do it that way. If you do the insert directly in the exit (or even a called DLL), you are creating a dependency on MS/SQL in your MQ programs. If it were me, I'd have the exits write a copy of the message to a seperate queue (you can even use mirrorq to do this) and then have a stand-alone program remove the messages from that queue and insert the rows into the MS/SQL database. _________________ -wayne |
|
Back to top |
|
 |
|