ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » Message Exit accessing MS SQL database

Post new topic  Reply to topic
 Message Exit accessing MS SQL database « View previous topic :: View next topic » 
Author Message
angka
PostPosted: Mon Jul 17, 2006 5:02 am    Post subject: Message Exit accessing MS SQL database Reply with quote

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
View user's profile Send private message
Mr Butcher
PostPosted: Mon Jul 17, 2006 5:36 am    Post subject: Reply with quote

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
View user's profile Send private message
angka
PostPosted: Mon Jul 17, 2006 6:03 am    Post subject: Reply with quote

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
View user's profile Send private message
angka
PostPosted: Mon Jul 17, 2006 7:40 pm    Post subject: Reply with quote

Chevalier

Joined: 20 Sep 2005
Posts: 406

Hi all,

Anyone tried inserting to MS SQL server in exit before?? Thanks

Rgds
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Jul 17, 2006 8:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
angka
PostPosted: Tue Jul 18, 2006 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message
angka
PostPosted: Tue Jul 18, 2006 3:04 am    Post subject: Reply with quote

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
View user's profile Send private message
RogerLacroix
PostPosted: Wed Jul 19, 2006 9:19 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Hi,

MQ Exit programming is an 'Advanced Level' subject. Have you read the following?
http://www.mqseries.net/phpBB2/viewtopic.php?t=20523

angka wrote:
Do you have any link that uses C to call the dll. sorry for the trouble cos i cant find any...

You're kidding right!?!

Google??? Or even better for Windows programmers, Microsoft's MSDN is FREE!!! You can lookup all Windows API calls including LoadLibrary at MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
angka
PostPosted: Thu Jul 20, 2006 1:58 am    Post subject: Reply with quote

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
View user's profile Send private message
wschutz
PostPosted: Thu Jul 20, 2006 2:05 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » Message Exit accessing MS SQL database
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.