Need help about NAS

subhastersubhaster Member Posts: 64
Hi ,
i came across a very strange problem . i have generated a system where from MSMQ the NAS is going to respond to upcoming of any new message(an xml file) and every time a new message comes , it is going to increase the ENTRYNO field(type int ) of a table called 'Cheque Messages'. But in inspite of all the steps that are to be taken for a successful operation of NAS, NAS is failing to detect any new message in MSMQ.
I have used in the trigger 99 (NASHandler) of Codeunit 1 , a variable called NavCom which points to a codeunit to carry out the above step (i.e. increamenting the ENTRYNo). I lalso have ticked up the SingleInstance poroperty to yes for the codeunits.
Also the NAS is working properly as is being showed by the Event-Log.
Can anyone suggest , what is wrong with the system ?
Subhasish Chakraborty,
Systems Analyst,
MBS Dynamics.

Answers

  • kinekine Member Posts: 12,562
    Do not forget that the message in MSMQ must have correct header to be catch by NAV. Search the forum for more info. Second thing is that you can check the message queue for waiting messages through Computer Management.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • subhastersubhaster Member Posts: 64
    yes, i have used the proper header i.e. 'Navision MSMQ-BA' as lablel to the message.
    Tell me one thing, do I need to install the Navision Business notification Server as well , so as to make the NAS know that there is a new message in the MSMQ ?
    I have used the proper parameter , and also the Application Log is showing that the NAS is operating correctly.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • danlindstromdanlindstrom Member Posts: 130
    In your own codeunit are you using the
    Automation 'Navision Timer 1.0'.Timer, 'CP Timer'.cTimer, 'CP Handler'.CQueueHandler or similar with WithEvents=Yes
    if WithEvents=Off(default) the codeunit does only one round of instructions (see codeunit 5065,6208,6221)
    Regards
    Dan Lindström
    NCSD Navision 2.00 since 1999 (Navision Certified Solution Developer)
    MBSP Developer for Microsoft Dynamics NAV 2009
  • kinekine Member Posts: 12,562
    subhaster wrote:
    yes, i have used the proper header i.e. 'Navision MSMQ-BA' as lablel to the message.
    Tell me one thing, do I need to install the Navision Business notification Server as well , so as to make the NAS know that there is a new message in the MSMQ ?
    I have used the proper parameter , and also the Application Log is showing that the NAS is operating correctly.

    BN is not needed for that functionality.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • subhastersubhaster Member Posts: 64
    Thanks Kine, I thought that I might be needing Business Notification for this functionality.
    But I am using a codeunit called 'Message Recieve' , where I used a communication Component , and have ticked the with events property to yes.
    But still the NAS is failing to check out for a new message in the MSMQ and the Event Log is showing that NAS is fucntioning properly !
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • kinekine Member Posts: 12,562
    Can you post the C/AL code which you are using to open the MSMQ?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • subhastersubhaster Member Posts: 64
    yes Kine , this is the code that handles the XML from MSMQ:


    OnRun()
    CLEAR(CC2);
    CLEAR(MQBus);
    CREATE(MQBus);
    CREATE(CC2);
    CLEAR(XMLDom);
    CREATE (XMLDom);

    CC2.AddBusAdapter(MQBus,1);
    MQBus.OpenReceiveQueue('.\Private$\toNavision',0,0);

    DecodeXml(XmlDom : Automation "'Microsoft XML, v3.0'.DOMDocument")
    IF ISCLEAR(CurrNode) THEN
    CREATE(CurrNode);
    IF ISCLEAR(ReturnedNode) THEN
    CREATE(ReturnedNode);
    CurrNode := XmlDom.documentElement;
    WITH XMLDomMgt DO BEGIN
    IF FindNode(CurrNode,'Action',ReturnedNode) THEN
    BEGIN
    IF STRLEN(ReturnedNode.text) > 0 THEN
    vStrAxn:=(ReturnedNode.text);
    END;
    END;
    WITH XMLDomMgt DO BEGIN
    IF FindNode(CurrNode,'Entity',ReturnedNode) THEN
    BEGIN
    IF STRLEN(ReturnedNode.text) > 0 THEN
    vStrEntity:=(ReturnedNode.text);
    END;
    END;

    IF (vStrAxn='Create')AND(vStrEntity='Item') THEN
    BizLayerItem.ParseXmlDocument(XmlDom);

    CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
    InMsg := InMessage;
    InS := InMsg.GetStream();
    XMLDom.load (InS);
    DecodeXml(XMLDom);

    here i have marked , the single-instance property to yes.
    and CC2's with event is also set to yes.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • DenSterDenSter Member Posts: 8,307
    Four things to check:

    1: Your message queue must be a private queue.

    2: Your message queue must be non-transactional. The comcom and the MQBA do not know how to deal with transactional message queues. Messages will just disappear or your code will behave in an unpredictable manner.

    3: MSMQ Active Directory support must not be installed, this has screwed up MSMQ monitors in my experience.

    4: The messages must be in single byte encoding. The second hex number in double byte characters is the same as the EOS marker in single byte characters, and that screws up the MSBA. If you don't have a choice, you will have to program MSMQ communication directly using its own object model
  • subhastersubhaster Member Posts: 64
    Thanks Daniel, I have checked all hthe points, excepting the last one, where you say
    The messages must be in single byte encoding. The second hex number in double byte characters is the same as the EOS marker in single byte characters, and that screws up the MSBA. If you don't have a choice, you will have to program MSMQ communication directly using its own object model
    .

    Can you please explain this in more details? It was not very clear to me.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • kinekine Member Posts: 12,562
    I am using this construction to read the message from queue (I do not know, if it can have some impact to functionality...):
    InMsg := InMessage;
    InStreamQueue := InMsg.GetStream();
    REPEAT
      InStreamQueue.READTEXT(XMLChar);
      XMLText := XMLText + XMLChar;
    UNTIL InStreamQueue.EOS;
    CREATE(XMLDoc);
    XMLDoc.loadXML(XMLText);
    

    and may be you can try to open the message queue with lowercase name ".\private$\tonavision". Be sure, that NAS has enough permissions on the queue to read and delete messages from it.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,307
    Search Google for encoding details, I can't find it on my computer right now. Inside the machine, each character is represented by a hexadecimal number. Single byte characters have one set of hex numbers, double byte characters have two of them. The way that single byte characters are represented in a double byte encoding scheme is to add a second 'dummy' set of numbers. The problem is that that dummy set of hex numbers in double byte encoding just happens to be the same hex number that represents EOS (which stands for End Of Stream) in the single byte encoding scheme that is used by the standard NAV communication components. So the first time the MQBA runs into a character it sees the EOS character and thinks that is the end of the string, and commits the message. In reality it is only the first character, and it will look like it missed the whole thing.

    Also, the Windows user that is set up as the user for NAS must be a valid user in NAV.
  • subhastersubhaster Member Posts: 64
    Thanks Dan. But I have checked the MSMQ , each time after I have sent the message from a web service. The Message if being properly detected by NAS , should'nt have been in the Queue left, it would have been picked up and consumed by NAV. But I found the message to be in Queue.This means the MessageRecieved trigger is not geting triggered , each time a new message comes to the MSMQ.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • subhastersubhaster Member Posts: 64
    Thanks everyone .... i did it ! All the while i was putiing a wrong label for the message in MSMQ. I should have been 'Navision MSMQ-BA', but I was using 'Navision msmq-ba' !!!
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • DenSterDenSter Member Posts: 8,307
    Good catch :mrgreen: Could you put [solved] in the title please?
Sign In or Register to comment.