Message Bus Adapter

maikeljmaikelj Member Posts: 50
edited 2003-10-07 in Navision Attain
Hi there, I've got the following problem:

What must I do to get a connection with a MS Queue Server?
With the following code I always get an error:

OnRun()
...
...
CREATE(MQBus);
CREATE(CC2);
MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0); :cry:
CC2.AddBusAdapter(MQBus,1);
...
...

The error occurs on the line with the smiley.
Who can help me.

MaikelJ

Comments

  • andre_jackandre_jack Member Posts: 14
    I've used the same code and it works well; which kind of error do you receive ?
    Try to invert the last 2 lines: first AddBusAdapter and then OpenReceiveQueue.

    Andrea
  • maikeljmaikelj Member Posts: 50
    I must first install MMQS before doing anything else.
    The only problem is how to do this?

    MaikelJ
  • andre_jackandre_jack Member Posts: 14
    MSMQ is a part of Win2000 OS.
    Go to Control PAnel, Add/Remove Programs, Add/Remove Windows Components, then scroll down to 'Message Queuing Services' and chek it.
    That's it.

    Andrea
  • maikeljmaikelj Member Posts: 50
    Hi Andrea,

    I've checked the 'Message Queuing Services' and the service is started.
    So far so good.
    And then when I just the code with line 'MQBus.OpenReceiveQueue('MyMessageQueueServer\comcom2_queue',0,0');' I get the following error: The call to member OpenReceiveQueue falied.MSMQQueueInfo returned the following message: The remote computer is not available.

    Then I used the line 'MQBus.OpenReceiveQueue(MyMessageQueueServer\MyQueue\comcom2_queue',0,0');' I get the following error: The call to member OpenReceiveQueue falied.MSMQQueueInfo returned the following message: An invalid parameter was passed to a function.

    What am I doing wrong??? :shock:

    MaikelJ
  • andre_jackandre_jack Member Posts: 14
    What kind of Queue did you create? I defined a Private Queue on a Win2000 server (not a Domain Controller).
    The correct code is the first you mentioned, but instead of 'comcom2_queue' you have to use you queue path (i have a setup table where I define this path as '\\server_name\queue').

    Andrea
  • maikeljmaikelj Member Posts: 50
    Sorry I ask Andrea, but how can I create such a queue? :oops:

    MaikelJ
  • andre_jackandre_jack Member Posts: 14
    Administrative Tools --> Computer Management --> expand Services and Applications --> Message Queuing --> right click on Private Queues --> New --> Private Queue.
    Be sure to check the Security settings in the Properties of your queue.

    Andrea
  • maikeljmaikelj Member Posts: 50
    The part with the queue works, but I've got another question.
    I have a document with an example how to receive a message and send a reply.
    The code is as followed:
    CC2::MessageReceived(VAR InMessage:Automation)
    InMsg := InMessage;
    IF (InMsg.ExpectReply) THEN
    BEGIN
    InS := InMsg.GetStream();
    InS.READ(Txt);
    MESSAGE(Txt);
    OutMsg := InMsg.CreateReply();
    OutS := OutMsg.GetStream();
    OutS.WRITE('blablabla');
    OutMsg.Send(0);
    END;
    InMsg.CommitMessage();

    My questions are:

    How can I create such a function?
    Because when I create a function with the name CC2, NA says it already exists with such a name.

    Is this the only function I need, or must I create another function before I can run CC2::MessageReceived.

    MaikelJ
  • andre_jackandre_jack Member Posts: 14
    You don't have to create a new function; you have to change a property of the CC2 automation object:
    WithEvents --> YES
    and the function CC2::MessageReceived is created

    by the way, where is Asenray ??

    Andrea
  • maikeljmaikelj Member Posts: 50
    Andrea, I've changed the property WithEvents to Yes,

    But when I run the Codeunit it only processes the OnRun() trigger.
    It doesn't processes the function CC2::MessageReceived.

    Asenray is a place in the south of the Netherlands.
    Near a city called Roermond (near the german border).

    MaikelJ
  • andre_jackandre_jack Member Posts: 14
    The function CC2::MessageReceived is processed whenever a message arrives into the queue. Check the queue to see if messages do arrive:

    Administrative Tools --> Computer Management --> expand Services and Applications --> Message Queuing --> Private Queues --> 'your queue' --> Queue Messages

    when the message arrives you should be able to see it, otherwise you have to investigate why no message is posted.

    Andrea
  • kirnekirne Member Posts: 6
    Hi!
    I too are trying to set up a message queue poller. I have managed to get it running in a form, but with NAS, the message queue never gets polled.
    I tried "debuggin" using MESSAGE() to write to the event log when the eventhandler triggered, but it never did.

    Should I set up some sort of a timer to keep the codeunit running?

    :cry:
    /Kirne
    / Kirne
  • andre_jackandre_jack Member Posts: 14
    Hi Kirne,

    there is no timer to keep a codeunit running. In order to obtain this you have to set the property SINGLEINSTANCE of the codeunit to TRUE. This makes the CU running till you close the client or open another company.
  • kirnekirne Member Posts: 6
    That works for cphanlder.dll !

    But any other dll trying to run as a service ignores this as well...

    Has anyone succeeded in running their own service in NAS?
    / Kirne
Sign In or Register to comment.