In this example, we use a single instance codeunit to initialize the Navision Communication Component, establish contact to a Navision MS-Message Queue Bus Adapter, open the bus adapter's receive queue and, finally, read the message that is received.
For the purpose 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 |
|
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(MQBus);
CREATE(CC2);
CC2.AddBusAdapter(MQBus,1);
MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0);
CC2::MessageReceived(VAR InMessage : Automation)
InMsg := InMessage;
InS := InMsg.GetStream();
InS.READ(Txt);
MESSAGE(Txt);
InMsg.CommitMessage();