data exchange with Navision via MSMQ

We are trying to integrate Navision using MSMQ. Using a VB-script the message read by Navision seems to be empty, while our c#-script works well.

We are using

a private Message Queue
Windows Server 2003
Net Framework 2.0
Net Studio 2005
Dynamics NAV 4.0

Who can give us hints to develop a general MSMQ bridge to Navision (without using Biztalk)?

Hartmut

PS our VB-script:

Option Explicit

Dim objInfo
Dim objQue
Dim objMsg
Dim strFormatName ’ Destination

strFormatName = “direct=os:.\private$\tonavision”

Set objInfo = CreateObject(“MSMQ.MSMQQueueInfo”)
Set objMsg = CreateObject(“MSMQ.MSMQMessage”)

objMsg.Label = “Navision MSMQ-BA”
objMsg.Body = “Hello”
objInfo.FormatName = strFormatName
set objQue = objInfo.Open(2, 0)

’ Send Message
objMsg.Send objQue

’ Close Destination
objQue.Close

Set objMsg = Nothing
Set objInfo = Nothing

msgbox “Done…”


our Navision codeunit here

OBJECT Codeunit 123456782 MQConnectionDemo_2
{
OBJECT-PROPERTIES
{
Date=19.06.06;
Time=[ 7:44:30];
Modified=Yes;
Version List=;
}
PROPERTIES
{
SingleInstance=Yes;
OnRun=BEGIN
// Message Queue Adapter
CREATE(MQBus);
// Navision Communication Compponent
CREATE(CC2);

// open Message Queue
MQBus.OpenReceiveQueue(’.\private$\toNavision’,0,0);
// Den MQ-Adapter und die Communication Component verbinden
CC2.AddBusAdapter(MQBus,1);
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;

EVENT CC2@1000000001::MessageReceived@1(VAR InMessage@1000000000 : Automation “:{00020400-0000-0000-C000-000000000046}:’’.IDISPATCH”);
VAR
InText@1000000001 : Text[100];
OutText@1000000002 : Text[100];
InS@1000000004 : InStream;
OutS@1000000003 : OutStream;
InMsg@1000000006 : Automation “{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{D184D0AC-61C9-4AC1-B537-0D28C277FEDE}:‘Navision Communication Component version 2’.InMessage”;
OutMsg@1000000005 : Automation “{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{6CB9762C-E61C-4F96-BA34-8B20D3A5B46E}:‘Navision Communication Component version 2’.OutMessage”;
BEGIN
// reading message
InMsg := InMessage;
//
InS := InMsg.GetStream();
//
InS.READTEXT(InText);

// open send Queue
MQBus.OpenWriteQueue(’.\private$\fromNavision’,0,0);
// reply
OutMsg := CC2.CreateoutMessage(‘Message queue://.\private$\fromNavision’);
//
OutS := OutMsg.GetStream();

// write text into Messagelog
MESSAGE('receivedn: ’ + InText);

// a example function
OutText := UPPERCASE (InText);

//
OutS.WRITETEXT(OutText);
// send reply
OutMsg.Send(0);
END;

BEGIN
END.
}
}

The code looks ok to me at first glance. Make sure your message queue is non transactional, and that you only have the common message queue components installed. The MQBA does not know how to read from a transactional queue, and I’ve seen AD integration screw things up as well.

we are using a non transactional MSMQ with WINDOWS 2003 SERVER. We didn’t make any changes on the preinstalled MSMQ 3.0 services. Please give us hints, which MSMQ common components are important.

There exist other open postings concerning our problem (http://www.velocityreviews.com/forums/t346473-using-msmq-on-windows-and-navision.html)

Change your encoding, NAV (well the MQBA at least) does not understand unicode.

When you install MSMQ in Windows components, you can look at the settings, and it will list a few things. Make sure that only common is selected. Triggers don’t screw it up, but I doubt you’re using those anyway.

How should we change our NAV-Code?

We tried to read the MSMQ without using the communication component and it is reading our MSMQ. Nice, but now there is no triggering. We want to use it with the Navision Application Server.

When unicode is our problem, why does the following code works and the former code not?

OBJECT Codeunit 123456780 ReceiveMQ
{
OBJECT-PROPERTIES
{
Date=08.06.07;
Time=13:11:46;
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
CREATE(QUI);
CREATE(QUE);
CREATE(MSG);

QUI.PathName:=’.\private$\ToNavision’;

QUE:=QUI.Open(1,0);

MSG:=QUE.Receive();

MESSAGE(MSG.Label);

MESSAGE(FORMAT(MSG.Body));
END;

}
CODE
{
VAR
QUI@1000 : Automation “{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE} 3.0:{D7D6E07C-DCCD-11D0-AA4B-0060970DEBAE}:‘Microsoft Message Queue 3.0 Object Library’.MSMQQueueInfo”;
QUE@1001 : Automation “{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE} 3.0:{D7D6E079-DCCD-11D0-AA4B-0060970DEBAE}:‘Microsoft Message Queue 3.0 Object Library’.MSMQQueue”;
MSG@1002 : Automation “{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE} 3.0:{D7D6E075-DCCD-11D0-AA4B-0060970DEBAE}:‘Microsoft Message Queue 3.0 Object Library’.MSMQMessage”;

BEGIN
END.
}

}

I have the same problem, does someony have a solution for this problem?

Regards,

Stefan

I could also not find an ‘incoming message’ event we made it work by using a timer object.

I never had such problems, but timer should be a good solution for event triggers problems.

They’re not using the MQBA Nuno, and there doesn’t seem to be a ‘messagereceived’ event in the MSMQ object model.