Information about the source of an incoming Message?

chrmuellerchrmueller Member Posts: 9
edited 2003-09-23 in Navision Attain
Hello,

has somebody expiriences with the NAS and the ComCom in this way?:

With the Communication Component 2 of Navision it is possible to add more than one Adapter (even different kind of Adapters: e.g. a MessageQueue-, a NamedPipe- and a Socket-Adapter) to one instance of a Communication Component. But I only have one event (the event from the Component "MessageReceived") to catch incoming messages.

Here's my question: How can I decide from which Adaptor this message comes? Does anybody have a code example?

Thanks
Christian

Comments

  • LG_HellströmLG_Hellström Member Posts: 13
    I haven't verified it but did you try InMessage.Source() (a string) to see if that can be used to sort out who's sending you the message?

    (as soon as I get rid of my irritating active directory error I'll try to verify this little interesting issue)
    Did I commit today?
  • chrmuellerchrmueller Member Posts: 9
    Hello LG,

    yes, I've tried that one... The Method .source() only works with the SocketAdapter. You can get the IP-Adress where the request comes from. But that isn't enough. There's no information about the socket-port or the instance-no.

    But thank you as well!!!

    Greetz
    Christian
  • LG_HellströmLG_Hellström Member Posts: 13
    ouch... bad bad bad :)

    I guess you need to get the message itself tagged with ID, like the first 10 characters, but that might be hard to do if you don't have ownership of the creating instance..
    :?
    Did I commit today?
  • LG_HellströmLG_Hellström Member Posts: 13
    note:

    I use 3 chars in each message to ID what is arriving.
    Following is a complete codeunit (SingleInstance) and I use a Form with two buttons sending either text or a xml-doc (resp. function).

    On the other hand I create the message in this example :S, a feature we all not necessary have :D
    Documentation()
    
    OnRun()
    IF ISCLEAR(DOM3) THEN
      CREATE(DOM3);
    IF ISCLEAR(NCC2) THEN
      CREATE(NCC2);
    IF ISCLEAR(MSMQBus) THEN
      CREATE(MSMQBus);
    NCC2.AddBusAdapter(MSMQBus,1);
    
    MSMQBus.OpenReceiveQueue('.\ncc2_queue',0,2);
    
    SendHelloWorld()
    MSMQBus.OpenWriteQueue('.\ncc2_queue',0,2);
    NCC2OutMsg := NCC2.CreateoutMessage('Message queue://');
    OutStr := NCC2OutMsg.GetStream();
    OutStr.WRITETEXT('TXT');
    OutStr.WRITETEXT('Hello World');
    NCC2OutMsg.Send(0);
    
    SendXML()
    DOM3.load('c:\Add.xml');
    MSMQBus.OpenWriteQueue('.\ncc2_queue',0,2);
    NCC2OutMsg := NCC2.CreateoutMessage('Message queue://');
    OutStr := NCC2OutMsg.GetStream();
    OutStr.WRITETEXT('XML');
    DOM3.save(OutStr);
    NCC2OutMsg.Send(0);
    
    NCC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
    
    NCC2InMsg := InMessage;
    InStr := NCC2InMsg.GetStream();
    InStr.READTEXT(Str,3);
    CASE Str OF
      'TXT': BEGIN
        InStr.READTEXT(Str,MAXSTRLEN(Str));
        MESSAGE(Str);
      END;
      'XML': BEGIN
        IF DOM3.load(InStr) THEN
          MESSAGE(COPYSTR(DOM3.documentElement().baseName(),1,100));
        DOM3.save('c:\Add2.xml');
      END;
    ELSE
      MESSAGE('Unknown Message')
    END;
    NCC2InMsg.CommitMessage();
    
    Did I commit today?
Sign In or Register to comment.