Problem with Microsoft Message Queue

Hi Friends,

As per example from Application Designer I have created 2 code units for sending and receiving messages in Navision.

For that I hv installed “Communication Componant/Bus Adapter”.“Navision SDK”.

As per App. Disgn. instruction m running Message Receiving codeunit 1st and from second session on the same client while running Send message codeunit am getting bellow error -

The call to member GetStream failed. SocketBusAdapter.SocketBusAdapter.1 returned the following message: Failed to connect to 127.0.0.1 on port 8079

Am also posting here sending code unit’s codes

Code:

IF ISCLEAR(CC2) THEN
CREATE(CC2);

IF ISCLEAR(SBA) THEN
CREATE(SBA);

CC2.AddBusAdapter(SBA,0);
OutMsg := CC2.CreateoutMessage(‘Sockets://localhost:8079’);

OutS := OutMsg.GetStream();
OutS.WRITE(‘My Message’);

Is this problem because of Port code : 8079. If yes then which port no. need to give here and how to get port no of any client.

Do I need to install Application Server for that…?

Also if u hv code sample which run successfully please give me here.

Please help my friends.

Sanjeev

Do you have message Queing set up on your machine?

Go to Control panel, Add/Remove Programs, Windows components and look to see if the component is installed.

T

Again… you are using the socket bus adapter. For Message queue communication, you need the Message Queue bus adapter. Find the ‘devguide.chm’ file on your product cd and read the code examples. If you follow those instructions, you WILL have a working sample.

Hi

The second codeunit (the receiving codeunit) you created has to be a single instance codeunit and it need to be running when you execute the first codeunit.

The code in the receiving codeunit should be (copied from ‘devguide.chm’):

Variable Name

Data Type

Subtype

Length

CC2

Automation

‘Navision Communication Component version 2’.CommunicationComponent

SBA

Automation

‘Navision Socket Bus Adapter’.SocketBusAdapter

InMsg

Automation

‘Navision Communication Component version 2’.InMessage

InS

InStream

txt

Text

1000

The WithEvents property for the CC2 variable is set to Yes. The socket server uses port 8079 on the local machine.

Example

OnRun()

IF ISCLEAR(CC2) THEN

CREATE(CC2);

IF ISCLEAR(SBA) THEN

CREATE(SBA);

CC2.AddBusAdapter(SBA, 0);

SBA.OpenSocket(8079, ‘’);

CC2::MessageReceived(VAR InMessage : Automation)

InMsg:= InMessage;

InS:= InMsg.GetStream();

WHILE NOT (InS.EOS) DO

BEGIN

InS.READ(txt);

MESSAGE(txt);

END;

InMsg.CommitMessage();

I have just tried this and it works. I get the same error as you when I don’t start the single instance receiving codeunit.

You don’t need an application server for this to work, but you would usual use the application server to run the single instance codeunit in case you wanted to interface data into Navision.

Regards

Claus

[:)]Tony & Claus thanks dear,

My Problem is now solved now i can receive messages but now its showing lots of junk messages along with mine. I am working on it. If u also encounterd sunch prob. do help me with solution.

Thx again.

Sanjeev

HI,

I have the same problem. I read the devguide.chm and used the sample.

But I think that the codeunit with the receivedMessage wouldn’t run.

The only different is : ComCom::ReceivedMessage(Var InMessage : Automation “’ '.IDISPATCH”)

is the .IDISPATCH

?

Hi Thraxas,

Whats seems to be the problem, I’m not sure I understand your post. You think it won’t work, or you’ve tried it and it doesn’t work?

Whats the issue with IDDispatch?

/TH

Hi,

I use the two codeunits, and start the codeunit with the event first. then start the other. But I always get the message:

SocketBusAdapter.SocketBusAdapter.1 returned the following message: Failed to connect to 127.0.0.1 on port 8079

It seems the codeunit with the event isn’t running at the time i’m start the other one.

Hi,

there is no chance. I’ve reinstall the “Communication Component” but I think I forget something.

The port is not open and not listen.

You are using the SOCKET bus adapter… use the MESSAGE QUEUE adapter instead. Read the code samples in the .chm file and follow them to the letter, it WILL work.

Some Bus Adapters only work when using two different instances of Navision.

I tested with Named Pipes and found Navision crashing when sending messages within the same instance.

When I tested with Sockets, everything worked fine. Also the MSMQ.

I reported the bug to Microsoft (i.e. the Named Pipes Adapter crashes when sending within same Navision instance).

The answer was:

Actually the Named Pipes Adapter behaves correctly. It is the other two which are wrong.

Believe me I was confused.

Anyway: Make sure that the listening CU (must be defined as Single Instance) is started before trying to send from another CU.

Make also sure that the port is not being used by any other program/service

Make also sure that either the port or the program is being allowed to listen at this port (Firewall issue)

Well there are all sorts of things wrong with the message queue adapter (hard coded label name, no double byte support, to name two), but if you follow the code samples, and you keep things simple, then the MQBA will work fine. As soon as you want to use labels though, or double byte characters, you’re screwed.

The only way to have a truly reliable message queue component is to write your own, using the MSMQ object model directly in the C/AL editor. You can search google for C# or VB code samples and apply them directly in C/AL.

Hi,

thanks for your responses.

I think I’m stone-blind or I have no eyes to read.

“I’m disconsolate about my inability.” (I hope I use the right term :slight_smile: )

→ single ← I have seen it but didn’t use it.