In this example, we use a codeunit to initialize the Navision Communication Component, establish contact to the Navision MS-Message Queue Bus Adapter, send a document and wait for a reply. This example does not include error handling.
For the purposes of this example, we have defined the following variables:
Variable Name |
Data Type |
Subtype |
Length |
MQBus |
Automation |
'Navision MS-Message Queue Bus Adapter '.MSMQBusAdapter |
|
CC2 |
Automation |
'Navision Communication Component version 2'.CommunicationComponent |
|
OutMsg |
Automation |
'Navision Communication Component version 2'.OutMessage |
|
OutS |
OutStream |
|
|
InMsg |
Automation |
'Navision Communication Component version 2'.InMessage |
|
InS |
InStream |
|
|
Txt |
Text |
|
100 |
Note that in the following example, you can use .\MyQueue (instead of MyMessageQueueServer\MyQueue) if you have installed the Microsoft Message Queue Server on your local machine.
OnRun()
CREATE(CC2);
CREATE(MQBus);
CC2.AddBusAdapter(MQBus,1);
MQBus.OpenWriteQueue('MyMessageQueueServer\comcom2_queue',0,0);
MQBus.OpenReplyQueue('MyMessageQueueServer\notify_queue',0,0);
MQBus.SenderAuthenticationLevel:= 3;
OutMsg := CC2.CreateoutMessage('Message queue://MyMessageQueueServer\XML-requests');
OutS:= OutMsg.GetStream();
OutS.WRITE('Hello world!');
InMsg:= OutMsg.SendWaitForReply(3000);
IF ISCLEAR(InMsg) THEN
MESSAGE('InMsg not received')
ELSE
BEGIN
InS:= InMsg.GetStream();
InS.READ(Txt);
MESSAGE(Txt);
END;