|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
receiveExit for newbie |
« View previous topic :: View next topic » |
Author |
Message
|
samsam007 |
Posted: Thu Dec 11, 2008 7:16 pm Post subject: receiveExit for newbie |
|
|
 Centurion
Joined: 30 Oct 2008 Posts: 107
|
Hi,
I wish this exit code is for a newbie whom want to implement their receive exit. It is copied from the mqchexit.c code. Since that code is *too complicated* and its compilation involved VisualAge C++, I never able to get the this code to work. I would like to hear anyone who can get this code to work with WMB v6 or v7 and how do you setup your channel.
At the moment, I installed this code for the server-connection channel at the MQ server end (receiver end), and compile with a .bat file
Here is the C code:
Code: |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmqc.h>
#include <cmqxc.h>
void write_log(char *msg)
{
FILE *fPtr = NULL
fPtr = fopen( "c:\\myexit1.log", "a+")
fprintf(fPtr,"%s\n",msg)
fclose(fPtr)
}
void MQENTRY ReceiveMessageExit (PMQVOID channelExitParms,
PMQVOID channelDef,
PMQLONG dataLength,
PMQLONG agBufLength,
PMQVOID agBuf,
PMQLONG exitBufLength, PMQPTR exitBufAddr)
{
PMQCXP pChlExParms = (PMQCXP) channelExitParms
PMQCD pChDef = (PMQCD) channelDef
unsigned char *buf
unsigned int bufLen
int status
switch (pChlExParms->ExitReason) {
case MQXR_INIT:
write_log ("init")
break
case MQXR_TERM:
write_log ("term")
pChlExParms->ExitResponse = MQXCC_OK
pChlExParms->ExitResponse2 = MQXCC_OK
pChlExParms->Feedback = 0L
break
case MQXR_MSG:
write_log ("msg")
break
case MQXR_XMIT:
write_log ("xmit")
switch (pChDef->ChannelType) {
case MQCHT_SENDER:
write_log ("sender");
break;
case MQCHT_SERVER:
write_log ("server");
break;
case MQCHT_SVRCONN:
write_log ("svrconn");
break;
case MQCHT_RECEIVER:
write_log ("receiver");
if (*dataLength < 300) {
pChlExParms->ExitResponse = MQXCC_OK;
pChlExParms->ExitResponse2 = MQXR2_USE_AGENT_BUFFER;
break;
}
buf = 0;
if (status == 0) {
if (buf) {
*exitBufAddr = buf;
*exitBufLength = bufLen;
*dataLength = bufLen;
write_log ("buf is not null");
pChlExParms->ExitResponse = MQXCC_OK;
pChlExParms->ExitResponse2 = MQXR2_USE_EXIT_BUFFER;
}
else {
pChlExParms->ExitResponse = MQXCC_OK;
pChlExParms->ExitResponse2 = MQXR2_USE_AGENT_BUFFER;
write_log ("buf is null");
}
}
break;
case MQCHT_REQUESTER:
write_log ("requester");
break;
case MQCHT_CLNTCONN:
write_log ("clntconn");
break;
default:
write_log ("default");
}
break;
case MQXR_SEC_MSG:
write_log ("sec_msg");
break;
case MQXR_INIT_SEC:
write_log ("init_sec");
break;
case MQXR_RETRY:
write_log ("retry");
break;
default:
write_log ("default");
}
}
|
Here is the .bat file to compile /link the code into DLL:
$ cat mms_rcvexit.bat
Code: |
cl -MT -c mms_rcvexit.c /DWIN32 /DWIN32_SHM /DHNLUP
link /DLL -out:mms_rcvexit.DLL mms_rcvexit.obj mqm.lib "c:\program files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib\advapi32.lib" "c:\program files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib\ws2_32.lib"
copy mms_rcvexit.DLL "C:\program files\ibm\websphere mq\exits"
|
|
|
Back to top |
|
 |
samsam007 |
Posted: Mon Dec 15, 2008 4:48 pm Post subject: Error with dll. |
|
|
 Centurion
Joined: 30 Oct 2008 Posts: 107
|
Hi,
I found the compiled dll has some missing libraries and errors.
Here is my further findings:
At the MQ server, I used cygwin command to check the linked libraries of the dll files, which is shown below.
Code: |
Administrator@itsmms-test /cygdrive/c/Program Files/IBM/WebSphere MQ/exits
$ cygcheck ./mms_rcvexit.dll
.\mms_rcvexit.dll
C:\WINDOWS\system32\KERNEL32.dll
C:\WINDOWS\system32\ntdll.dll
Administrator@itsmms-test /cygdrive/c/Program Files/IBM/WebSphere MQ/exits
$ ls /cygdrive/
Administrator@itsmms-test /cygdrive/c/Program Files/IBM/WebSphere MQ/exits
$ cygcheck ./BlockIP2.DLL
.\BlockIP2.DLL
c:\Program Files\IBM\WebSphere MQ\bin\MQM.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQXCS2.dll
c:\Program Files\IBM\WebSphere MQ\bin\amqxcsn.DLL
C:\WINDOWS\system32\USER32.dll
C:\WINDOWS\system32\ntdll.dll
C:\WINDOWS\system32\KERNEL32.dll
C:\WINDOWS\system32\GDI32.dll
C:\WINDOWS\system32\ADVAPI32.dll
C:\WINDOWS\system32\RPCRT4.dll
C:\WINDOWS\system32\Secur32.dll
C:\WINDOWS\system32\NETAPI32.dll
C:\WINDOWS\system32\msvcrt.dll
Error: could not find MSVCR80.dll
C:\WINDOWS\system32\dbghelp.dll
C:\WINDOWS\system32\VERSION.dll
C:\WINDOWS\system32\WS2_32.dll
C:\WINDOWS\system32\WS2HELP.dll
Error: could not find MSVCR80.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQZST.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQZC.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQLDATN.dll
Error: could not find MSVCR80.dll
Error: could not find MSVCR80.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQVWAA2.dll
c:\Program Files\IBM\WebSphere MQ\bin\MQMVXD.dll
Error: could not find MSVCR80.dll
Error: could not find MSVCR80.dll
c:\Program Files\IBM\WebSphere MQ\bin\amqmtmgr.dll
C:\WINDOWS\system32\WINMM.dll
Error: could not find MSVCR80.dll
C:\WINDOWS\system32\ole32.dll
C:\WINDOWS\system32\OLEAUT32.dll
c:\Program Files\IBM\WebSphere MQ\bin\AMQZTM.dll
Error: could not find MSVCR80.dll
Error: could not find MSVCR80.dll
c:\Program Files\IBM\WebSphere MQ\bin\amqzsai.dll
Error: could not find MSVCR80.dll
Error: could not find MSVCR80.dll
|
The BlockIP2.dll is working fine, but with more DLLs linked with, and some errors; while the mms_rcvexit.dll code has only KERNEL32.dll and nt.dll linked.
The event viewer also shown the other error message regarding to this problem:
Code: |
The system could not dynamically load the library C:\Program Files\IBM\WebSphere MQ\exits\mms_rcvexit.dll due to a problem with the dll. The errno was 536895880. The queue manager will continue without this module.
This message applies to Windows NT and Windows 2000 systems only. The dynamically loadable file C:\Program Files\IBM\WebSphere MQ\exits\mms_rcvexit.dll failed to load correctly due to a problem with the dll.
|
Thank you in advance for any suggestion and help.
Thanks |
|
Back to top |
|
 |
samsam007 |
Posted: Tue Dec 16, 2008 4:30 pm Post subject: |
|
|
 Centurion
Joined: 30 Oct 2008 Posts: 107
|
Here is how I solved the dll problem.
I have to export the function name from the dll program in order to make it callable by the MQ:
#if defined (WIN32)
__declspec (dllexport) void MQENTRY ReceiveMessageExit (
PMQCXP channelExitParams,
PMQCD channelDef,
PMQLONG dataLength,
PMQLONG agentBufferLength,
PMQBYTE agentBuf,
PMQLONG exitBufferLength,
PMQPTR exitBufferAddr);
#endif
/*
* This is the function for the receive message exit
*/
extern void MQENTRY ReceiveMessageExit (PMQVOID channelExitParms,
PMQVOID channelDef,
PMQLONG dataLength,
PMQLONG agBufLength,
PMQVOID agBuf,
PMQLONG exitBufLength, PMQPTR exitBufAddr)
{
....
Just my 3 cents. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Dec 17, 2008 4:11 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
samsam007 wrote: |
Here is how I solved the dll problem.
I have to export the function name from the dll program in order to make it callable by the MQ: |
Yes, it is documented in chapter 34 "Channel-exit Programs" of the WMQ Intercommunication manual.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|