Hi there, I've got the following problem:
What must I do to get a connection with a MS Queue Server?
With the following code I always get an error:
OnRun()
...
...
CREATE(MQBus);
CREATE(CC2);
MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0);
CC2.AddBusAdapter(MQBus,1);
...
...
The error occurs on the line with the smiley.
Who can help me.
MaikelJ
Comments
Try to invert the last 2 lines: first AddBusAdapter and then OpenReceiveQueue.
Andrea
The only problem is how to do this?
MaikelJ
Go to Control PAnel, Add/Remove Programs, Add/Remove Windows Components, then scroll down to 'Message Queuing Services' and chek it.
That's it.
Andrea
I've checked the 'Message Queuing Services' and the service is started.
So far so good.
And then when I just the code with line 'MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0');' I get the following error: The call to member OpenReceiveQueue falied.MSMQQueueInfo returned the following message: The remote computer is not available.
Then I used the line 'MQBus.OpenReceiveQueue(MyMessageQueueServer\MyQueue\comcom2_queue',0,0');' I get the following error: The call to member OpenReceiveQueue falied.MSMQQueueInfo returned the following message: An invalid parameter was passed to a function.
What am I doing wrong??? :shock:
MaikelJ
The correct code is the first you mentioned, but instead of 'comcom2_queue' you have to use you queue path (i have a setup table where I define this path as '\\server_name\queue').
Andrea
MaikelJ
Be sure to check the Security settings in the Properties of your queue.
Andrea
I have a document with an example how to receive a message and send a reply.
The code is as followed:
CC2::MessageReceived(VAR InMessage:Automation)
InMsg := InMessage;
IF (InMsg.ExpectReply) THEN
BEGIN
InS := InMsg.GetStream();
InS.READ(Txt);
MESSAGE(Txt);
OutMsg := InMsg.CreateReply();
OutS := OutMsg.GetStream();
OutS.WRITE('blablabla');
OutMsg.Send(0);
END;
InMsg.CommitMessage();
My questions are:
How can I create such a function?
Because when I create a function with the name CC2, NA says it already exists with such a name.
Is this the only function I need, or must I create another function before I can run CC2::MessageReceived.
MaikelJ
WithEvents --> YES
and the function CC2::MessageReceived is created
by the way, where is Asenray ??
Andrea
But when I run the Codeunit it only processes the OnRun() trigger.
It doesn't processes the function CC2::MessageReceived.
Asenray is a place in the south of the Netherlands.
Near a city called Roermond (near the german border).
MaikelJ
Administrative Tools --> Computer Management --> expand Services and Applications --> Message Queuing --> Private Queues --> 'your queue' --> Queue Messages
when the message arrives you should be able to see it, otherwise you have to investigate why no message is posted.
Andrea
I too are trying to set up a message queue poller. I have managed to get it running in a form, but with NAS, the message queue never gets polled.
I tried "debuggin" using MESSAGE() to write to the event log when the eventhandler triggered, but it never did.
Should I set up some sort of a timer to keep the codeunit running?
/Kirne
there is no timer to keep a codeunit running. In order to obtain this you have to set the property SINGLEINSTANCE of the codeunit to TRUE. This makes the CU running till you close the client or open another company.
But any other dll trying to run as a service ignores this as well...
Has anyone succeeded in running their own service in NAS?