Options

Navision and MS Queue

fcassolifcassoli 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

Comments

  • Options
    bruno77bruno77 Member Posts: 62
    Hi Fedrico,

    Make sure that the SingleInstance property for the codeunit is set to Yes.

    /Bruno
  • Options
    fcassolifcassoli Member Posts: 16
    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.

    Federico
  • Options
    GoMaDGoMaD Member Posts: 313
    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!
  • Options
    fcassolifcassoli Member Posts: 16
    Yes: I see the trigger function (its header is automatically created when I set Yes to the WithEvents property)...
  • Options
    GoMaDGoMaD Member Posts: 313
    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!
  • Options
    DenSterDenSter Member Posts: 8,304
    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.
  • Options
    fcassolifcassoli Member Posts: 16
    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]
  • Options
    jorgecphjorgecph Member Posts: 26
    The bus adapter will only pick up messages with this label:
    Navision MSMQ-BA
    . Make certain that whatever application that is feeding the messages is labeling with exactly this label. If the feeder is another MSMQ Bus Adapter, it should be label accordingly, and then you have some other problem.

    Jorge
    _________________
    “This posting is provided "AS IS" with no warranties, and confers no rights.”
  • Options
    fcassolifcassoli Member Posts: 16
    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,
    Federico
Sign In or Register to comment.