Click here to Skip to main content
Rate this: bad
good
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 7:04am
Edited 3-Nov-11 7:30am
(no name)253.4K
v2
Comments
RaisKazi at 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
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2014
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