Navision and MS Queue

fcassoli
Member Posts: 16
I tried to develop a codeunit, using Navision Application Server 4.0, to read and answer commands coming from MS Queue, but I can't make it work properly.
I followed what presented in MSDN document: Talking with Navision: Say Hello to Navision and Expect Navision to Be Polite, but the trigger doesn't fire when a message is sent to the queue.
I tried using standard Microsoft DLL but the result is the same.
I tried also to place the code in a form, without using NAS, but it still doesn't work.
I wrote a small program in VB.NET to test the functionality of the queues, but VB.NET fires the trigger correctly.
Can someone help me?
Thanks,
Federico
I followed what presented in MSDN document: Talking with Navision: Say Hello to Navision and Expect Navision to Be Polite, but the trigger doesn't fire when a message is sent to the queue.
I tried using standard Microsoft DLL but the result is the same.
I tried also to place the code in a form, without using NAS, but it still doesn't work.
I wrote a small program in VB.NET to test the functionality of the queues, but VB.NET fires the trigger correctly.
Can someone help me?
Thanks,
Federico
0
Comments
-
Hi Fedrico,
Make sure that the SingleInstance property for the codeunit is set to Yes.
/Bruno0 -
Thanks Bruno,
the property is correctly set. I tried also using a Form, without Application Server, leaving the form opened, but it still doesn't work.
Federico0 -
Did you set the WithEvents propertyon your automation variable that catches the event to the Yes value?
Regards,Now, let's see what we can see.
...
Everybody on-line.
...
Looking good!0 -
Yes: I see the trigger function (its header is automatically created when I set Yes to the WithEvents property)...0
-
Which part of your application doesn't work: the outgoing or the incoming part?
Could you give us some code?Now, let's see what we can see.
...
Everybody on-line.
...
Looking good!0 -
Make sure that you have code in the NASHandler trigger of codeunit 1 to handle your NAS. You can have all the instances of NAS running, but if the NASHandler trigger doesn't know about it, it won't do anything.0
-
In the Codeunit 1, function NASHandler, into the CASE statement, I placed the following code:
'NAVCOMM': NavComm.RUN;
NavComm points to the Codeunit 50000, which follows:OBJECT Codeunit 50000 NAS Communication { OBJECT-PROPERTIES { Date=01/04/05; Time=15.48.58; Modified=Yes; Version List=NAS_COMM; } PROPERTIES { SingleInstance=Yes; OnRun=VAR i@1000000000 : Integer; BEGIN NASCommunication.GET; CREATE(MQBus); CREATE(CC2); CREATE(XMLDom); CC2.AddBusAdapter(MQBus, 1); MQBus.OpenReceiveQueue('.\private$\toNavision', 0, 0); END; } CODE { VAR MQBus@1000000000 : Automation "{B8BD635A-E191-47EF-84A0-02921E2A44A6} 1.0:{CD49794B-0E84-4A2E-9522-C518C825D390}:'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter"; CC2@1000000001 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{01018FA5-E4B4-413C-A47C-AD34B0CC2647}:'Navision Communication Component version 2'.CommunicationComponent" WITHEVENTS; InMsg@1000000002 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{D184D0AC-61C9-4AC1-B537-0D28C277FEDE}:'Navision Communication Component version 2'.InMessage"; InS@1000000003 : InStream; XMLDom@1000000004 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v3.0'.DOMDocument"; XMLNode@1000000005 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v3.0'.IXMLDOMNode"; OutMsg@1000000006 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{6CB9762C-E61C-4F96-BA34-8B20D3A5B46E}:'Navision Communication Component version 2'.OutMessage"; OutS@1000000007 : OutStream; EVENT CC2@1000000001::MessageReceived@1(VAR InMessage@1000000000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH"); BEGIN // Get the message InMsg := InMessage; InS := InMsg.GetStream(); // Load the message into an XML document and find a node XMLDom.load(InS); XMLNode := XMLDom.selectSingleNode('string'); // Open the response queue and create a new message MQBus.OpenWriteQueue('.\private$\fromNavision', 0, 0); OutMsg := CC2.CreateoutMessage('Message queue://' + '.\private$\fromNavision'); OutS := OutMsg.GetStream(); // Build the contents of your message - BUSINESS LOGIC XMLNode.text := UPPERCASE(XMLNode.text); // Fill the message and send it OutS.WRITE(XMLDom.xml); OutMsg.Send(0); END; EVENT XMLDom@1000000004::ondataavailable@198(); BEGIN END; EVENT XMLDom@1000000004::onreadystatechange@-609(); BEGIN END; BEGIN { } END. } }
I don't think the problem is about the Application Server, because the same situation (the function CC2::MessageReceived is never executed) happens when I create a Form and keep it running while sending a message on the queue.
Thanks,
Federico
[/code]0 -
The bus adapter will only pick up messages with this label:Navision MSMQ-BA
Jorge_________________
“This posting is provided "AS IS" with no warranties, and confers no rights.”0 -
Thank you very much,
that was the problem!
I created the message using a VB.NET program I wrote, and I used a different label.
Now it works!
Thanks again,
Federico0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions