Click here to Skip to main content
15,888,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MQSendMessage throwing exception for simple "hello world" example. I am trying to write a simple send/receive for a private queue, nothing fancy.(non-transactional, events, etc) just simple strings. Queue is created successfully

code:
C++
int sendMsg(std::string message, QUEUEHANDLE queuePtr)
{
	HRESULT status;

		MQMSGPROPS msgProperties;
		const int NUMBEROFPROPERTIES = 2;
		WCHAR tmpBodyMsg[] = L"RISQ first message";

		MSGPROPID msgPropertyID[NUMBEROFPROPERTIES];
		MQPROPVARIANT msgPropertyVariant[NUMBEROFPROPERTIES];
		HRESULT msgStatus[NUMBEROFPROPERTIES];


		int propIndex = 0;

		DWORD bodyType = VT_BSTR;
		msgPropertyID[propIndex] = PROPID_M_BODY_TYPE;
		msgPropertyVariant[propIndex].vt = VT_UI4;
		msgPropertyVariant[propIndex].ulVal = bodyType;
		propIndex++;

		msgPropertyID[propIndex] = PROPID_M_BODY;
		msgPropertyVariant[propIndex].vt = VT_VECTOR | VT_UI1;
		msgPropertyVariant[propIndex].caub.pElems = (LPBYTE)tmpBodyMsg;
		msgPropertyVariant[propIndex].caub.cElems =	sizeof(tmpBodyMsg);
		propIndex++;		


		// intialize MQQUEUEPROPS structure
		msgProperties.cProp = propIndex;
		msgProperties.aPropID = msgPropertyID;
		msgProperties.aPropVar = msgPropertyVariant;
		msgProperties.aStatus = msgStatus;


		status = MQSendMessage(queuePtr, &msgProperties, NULL);
		if(status != MQ_OK)
Posted
Updated 3-Nov-11 6:30am
v2
Comments
RaisKazi 4-Nov-11 4:32am    
Error Details?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900