Quantcast
Channel: TechBlog » MSMQ
Viewing all articles
Browse latest Browse all 2

MSMQ and Navision

$
0
0

From Navision it is possible to read and write to a MSMQ using the automation Microsoft Message Queue 3.0 Object Library. This is however not my preferred way, because you have to handle Messages IDs by yourself. Which means, if you don’t have to answer back with the same message id, this is an ok way to handle the queues, else you have to program your own ID handling or use a 3′d part application for this purpose.

To send messages through the MSMQs do the following:

First create the QueueInfo instans and open the Queue with send access

CREATE(QueueInfo);
QueueInfo.PathName := '.\private$\testqueue';
Queue := QueueInfo.Open(2,0); //2=MS_SEND_ACCESS, 0 = MQ_DENY_NONE

Then create the Message

CREATE(MSMQ_Message);
MSMQ_Message.Label := ‘Test Message’;
MSMQ_Message.Body := ‘This is a test’;

Send the Message to the Queue

MSMQ_Message.Send(Queue);

and finally close the queue

Queue.Close;
CLEAR(MSMQ_Message);
CLEAR(Queue);

To read messages do the following:

First create the QueueInfo instans and open the Queue with receive access

CREATE(QueueInfo);
QueueInfo.PathName := '.\private$\queue_request';
Queue := QueueInfo.Open(1,0); //1=MS_RECEIVE_ACCESS, 0 = MQ_DENY_NONE

Then Create the Message Instans and read (purge) the first message:

CREATE(MSMQ_Message);
MSMQ_Message := Queue.Receive;
Body := MSMQ_Message.Body;

and finally close the queue

Queue.Close;
CLEAR(MSMQ_Message);
CLEAR(Queue);

In both examples the following variables was used:

  • Queue is the automation 'Microsoft Message Queue 3.0 Object Library'.MSMQQueue
  • MSMQ_Message is the automation 'Microsoft Message Queue 3.0 Object Library'.MSMQMessage
  • QueueInfo is the automation 'Microsoft Message Queue 3.0 Object Library'.MSMQQueueInfo

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images