|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Data Conversion Exit not working please Help |
« View previous topic :: View next topic » |
Author |
Message
|
xabhijit |
Posted: Tue Apr 08, 2003 6:31 am Post subject: Data Conversion Exit not working please Help |
|
|
Newbie
Joined: 04 Apr 2003 Posts: 6
|
1)My DLL is being invoked when I invoke MQPUT from my application and I have set my channel with data conv true.But when I execute
myfile.write("pInBuffer: ", sizeof ("pInBuffer: "));
the file shows some junk chars and not the input my MQPUT receives.So have I written the correct entry point??
2)I have tried to add few chars to the input data using
strcat ((char *)*out_cursor, "Hello");
and then wrote it in file.The data does change as reflected in the file but the content written to the queue does not change.
Am I changing the correct buffer as received by my MQPUT application??
Here is the code which I have tried for the message conversion >>>>>
#include <cmqc.h> /* For MQI datatypes */
#include <cmqxc.h> /* For MQI exit-related definitions */
#include <amqsvmha.h> /* For sample macro definitions */
#include <fstream.h>
ofstream myfile; //global file
MQLONG Convert_mymsg
(
PMQBYTE *,
PMQBYTE *,
PMQBYTE ,
PMQBYTE ,
MQHCONN ,
MQLONG ,
MQLONG ,
MQLONG ,
MQLONG ,
MQLONG ,
MQLONG ,
MQLONG
);
MQDATACONVEXIT MessageExit;
void /*_Export*/ MQENTRY MessageExit(
PMQDXP pDataConvExitParms, /* Data-conversion exit parameter */
/* block */
PMQMD pMsgDesc, /* Message descriptor */
MQLONG InBufferLength, /* Length in bytes of InBuffer */
PMQVOID pInBuffer, /* Buffer containing the unconverted */
/* message */
MQLONG OutBufferLength, /* Length in bytes of OutBuffer */
PMQVOID pOutBuffer) /* Buffer containing the converted */
/* message */
{
PMQCXP pParms = (PMQCXP)pDataConvExitParms;
//PMQCD pChDef = (PMQCD)pChannelDefinition;
MQLONG ReturnCode = MQRC_NONE;
MQHCONN hConn = pDataConvExitParms->Hconn;
MQLONG opts = pDataConvExitParms->AppOptions;
PMQBYTE in_lastbyte = (PMQBYTE)pInBuffer + InBufferLength - 1;
PMQBYTE out_lastbyte = (PMQBYTE)pOutBuffer + OutBufferLength - 1;
MQLONG MsgEncoding = pMsgDesc->Encoding;
MQLONG ReqEncoding = pDataConvExitParms->Encoding;
MQLONG MsgCCSID = pMsgDesc->CodedCharSetId;
MQLONG ReqCCSID = pDataConvExitParms->CodedCharSetId;
MQLONG CompCode = pDataConvExitParms->CompCode;
MQLONG Reason = pDataConvExitParms->Reason;
PMQBYTE in_cursor = (PMQBYTE)pInBuffer;
PMQBYTE out_cursor = (PMQBYTE)pOutBuffer;
myfile.open("Myfile.cfg", ios::app);
myfile.write("pInBuffer: ", sizeof ("pInBuffer: "));
myfile.write((char *)pInBuffer,sizeof (pInBuffer));
myfile.put('\n');
myfile.write("pOutBuffer: ", sizeof ("pOutBuffer: "));
myfile.write((char *)pOutBuffer,sizeof (pOutBuffer));
myfile.put('\n');
/******************************************************************/
/* Insert calls to the code fragments to convert the format's */
/* structure(s) here. */
/******************************************************************/
//switch (pParms->ExitId) {
//case MQXT_CHANNEL_MSG_EXIT:
ReturnCode = Convert_mymsg(
&in_cursor,
&out_cursor,
in_lastbyte,
out_lastbyte,
hConn,
opts,
MsgEncoding,
ReqEncoding,
MsgCCSID,
ReqCCSID,
CompCode,
Reason);
if ((ReturnCode == MQRC_NONE) ||
(ReturnCode == MQRC_TRUNCATED_MSG_ACCEPTED))
{
pDataConvExitParms->ExitResponse = MQXDR_OK;
pDataConvExitParms->DataLength = out_cursor
- (PMQBYTE)pOutBuffer;
}
else
{
pDataConvExitParms->ExitResponse = MQXDR_CONVERSION_FAILED;
}
if (Reason != MQRC_TRUNCATED_MSG_ACCEPTED)
{
pDataConvExitParms->Reason = ReturnCode;
if (ReturnCode == MQRC_NONE)
{
pDataConvExitParms->CompCode = MQCC_OK;
}
else
{
pDataConvExitParms->CompCode = MQCC_WARNING;
}
}
//break;
//default:;
//printf ("Channel message exit started \n");
//break;
//}/* endswitch ExitType */
myfile.put('\n');
myfile.close();
return;
}
/********************************************************************/
/* Insert the functions produced by the data conversion exit */
/* utility program(ie CRTMQCVX). */
/********************************************************************/
//TEST is the user defined structure
MQLONG Convert_mymsg(
PMQBYTE *in_cursor, //sourceC
PMQBYTE *out_cursor, //dest
PMQBYTE in_lastbyte,
PMQBYTE out_lastbyte,
MQHCONN hConn,
MQLONG opts,
MQLONG MsgEncoding,//sourceL
MQLONG ReqEncoding,//destL
MQLONG MsgCCSID, //sourceC type
MQLONG ReqCCSID, //destC type
MQLONG CompCode,
MQLONG Reason)
{
MQLONG ReturnCode = MQRC_NONE;
unsigned int bn = 5;
MQLONG rc0 = 0L;
myfile.write("Inside Convert_mymsg",sizeof ("Inside Convert_mymsg"));
myfile.put('\n');
//CheckSpace(bn, 1, rc0);
CheckSpace(bn, 1, rc0);
memcpy(*out_cursor, *in_cursor, sizeof (*in_cursor)); //original
strcat ((char *)*out_cursor, "Hello");
myfile.write("Input: ", sizeof ("Input: "));
myfile.write((char *)*in_cursor,sizeof (*in_cursor));
myfile.put('\n');
myfile.write("OutputStream: ",sizeof ("OutputStream: "));
myfile.write((char *)*out_cursor,sizeof (*out_cursor));
myfile.put('\n');
if (rc0 != MQRC_NONE) //not enough space
{
ReturnCode = rc0;
goto Fail;
}
Fail:
return(ReturnCode);
}
Thanx,
Abhijit. |
|
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
|
|
|
|