Click here to Skip to main content
12,400,183 members (56,649 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MSMQ
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:
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 3-Nov-11 6:04am
Updated 3-Nov-11 6:30am
Mehdi Gholam314.5K
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100