<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Nav developer's blog : Comcom</title><link>http://blogs.msdn.com/nav_developer/archive/tags/Comcom/default.aspx</link><description>Tags: Comcom</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Things to remember with MSMQ Busadapter</title><link>http://blogs.msdn.com/nav_developer/archive/2008/07/15/things-to-remember-with-msmq-busadapter.aspx</link><pubDate>Tue, 15 Jul 2008 10:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8732769</guid><dc:creator>Lohndorf</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/8732769.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=8732769</wfw:commentRss><description>&lt;P&gt;Thank you&amp;nbsp;to the person who made me aware that the article here:&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/nav_developer/archive/2008/05/13/comcom-and-the-bus-adapter.aspx" target=_blank mce_href="http://blogs.msdn.com/nav_developer/archive/2008/05/13/comcom-and-the-bus-adapter.aspx"&gt;Comcom and the Bus adapter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Misses out a couple of important things. So I will try to correct that here.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you set up NAS to read from Microsoft Message Queues (MSMQ), using the MSMQ Bus Adapter as described in the article above, then you must remember these two things:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; The label on any message you send to the queue, must be "&lt;STRONG&gt;Navision MSMQ-BA&lt;/STRONG&gt;". Otherwise NAS will ignore them, and they will stay in the queue. This is a way to control which messages are intented for NAS. It is a hardcoded feature, and cannot be adjusted or changed or disabled.&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp; Text in the messages must be in the format UTF-8. NAS (or any other NAV component) does not recognise UNICODE and&amp;nbsp;any other format than UTF-8 can make the message unreadable.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if everything else seems to be OK, but NAS still does not read messages from MSMQ, then check these two things.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Lars Lohndorf-Larsen&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics UK&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Microsoft Customer Service and Support (CSS) EMEA&lt;/P&gt;
&lt;P&gt;These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8732769" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nav_developer/archive/tags/Comcom/default.aspx">Comcom</category></item><item><title>Comcom and the Bus adapter</title><link>http://blogs.msdn.com/nav_developer/archive/2008/05/13/comcom-and-the-bus-adapter.aspx</link><pubDate>Tue, 13 May 2008 11:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8499474</guid><dc:creator>Lohndorf</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/nav_developer/comments/8499474.aspx</comments><wfw:commentRss>http://blogs.msdn.com/nav_developer/commentrss.aspx?PostID=8499474</wfw:commentRss><description>&lt;P&gt;This post is the second part of the post &lt;A class="" href="http://blogs.msdn.com/nav_developer/archive/2008/05/13/nas-tutorial.aspx" target=_blank mce_href="http://blogs.msdn.com/nav_developer/archive/2008/05/13/nas-tutorial.aspx"&gt;NAS Tutorial&lt;/A&gt;&amp;nbsp;which is based on KB article 861762, previously published on PartnerSource.&amp;nbsp;This post is an updated version, and available to a wider audience (no PartnerSource login required).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&amp;nbsp;post describes how to use&amp;nbsp;NAV Communication Component (Comcom) and NAV Bus adapter. Comcom is designed to enhance communication between Navision and other applications, like a Web server, a BizTalk server or some other external system. What kind of communication takes place, is all down to the specific application (like Commerce Portal or Commerce Gateway). In this document, we will only look at the mechanisms of sending and receiving a document. &lt;/P&gt;
&lt;P&gt;This post also shows how to create a very small application that can send a message to MS Message queue, and receive this message again.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=== Updated on July 15th ===&lt;/P&gt;
&lt;P&gt;I was made aware of a couple of important additional things to remember when working with MSMQ Busadapter:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; Messages sent to NAS must have the label "&lt;STRONG&gt;Navision MSMQ-BA&lt;/STRONG&gt;"&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp; Text in the messages must be in the format UTF-8. You cannot use UNICODE.&lt;/P&gt;
&lt;P&gt;There are more details about this &lt;A class="" href="http://blogs.msdn.com/nav_developer/archive/2008/07/15/things-to-remember-with-msmq-busadapter.aspx" target=_blank mce_href="http://blogs.msdn.com/nav_developer/archive/2008/07/15/things-to-remember-with-msmq-busadapter.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;=== End of Update ========&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is Comcom and Bus adapter?&lt;/STRONG&gt;&lt;BR&gt;Both Comcom and the bus adapter are automation servers developed by Microsoft for NAV. Comcom is a general communication component. All it does, is sending and receiving messages. You need to use a bus adapter with Comcom. The bus adapter is specific to the media used to transport the messages that Comcom sends and receive. At the moment there are two bus adapters: One for MS Message queue, and one for Named Pipes. In this document we will use the bus adapter for MS Message queue (MSMQ).&lt;/P&gt;
&lt;P&gt;The reason for having Comcom as well as a bus adapter is, that you can create your application using Comcom without being concerned about what the transport media is going to be. When you decide on that / or if you want to change the media used, it will only require small changes – the application itself would need only very minor changes.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;U&gt;Prerequisites&lt;/U&gt;&lt;BR&gt;NAV communication components come as part of SDK (Devkit) on the product CD. This needs to be installed before you start. And, you need to have MSMQ installed (installs as part of Windows).&lt;/P&gt;
&lt;P&gt;First, create a new queue in MSMQ: Open Computer Management, expand "Services and Applications", and you should see "Message Queuing" here, if MSMQ is installed. Expand "Message Queuing", and then expand "Private Queues". Note that the MSMQ Busadapter is only tested with private queues, and is unlikely to work with public queues.&lt;/P&gt;
&lt;P&gt;Rightclick on "Private Queues", select New -&amp;gt; Private Queue, and enter a name. Let's call it MuQueue. Also note that MSMQ Busadapter has not been tested for Transactional queues, so leave the field "Transactional" blank.&lt;/P&gt;
&lt;P&gt;Now you have the queue, and the rest is up to NAV to send a message into this queue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in NAV, create a new codeunit. First we need do declare the following variables to get access to Comcom:&lt;BR&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Subtype&lt;BR&gt;Comcom&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Automation&amp;nbsp;'Navision Communication Component version 2'.CommunicationComponent&lt;BR&gt;ComOut&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automation&amp;nbsp;'Navision Communication Component version 2'.OutMessage&lt;BR&gt;OutStr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Outstream&amp;nbsp;&lt;BR&gt;All automation variables need to be initialised before they can be used. Type these two lines to initialise Comcom and ComOut:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;CREATE(Comcom);&lt;BR&gt;ComOut := Comcom.CreateoutMessage('Message queue://');&lt;/P&gt;
&lt;P&gt;'Message queue://' is the actual word Message queue. We need to tell Comcom to send the message in a format for Microsoft Message queue. But this is the only reference to the media (until we get to the bus adapter).&lt;/P&gt;
&lt;P&gt;Remember, Comcom has only one purpose: Sending / receiving messages. It is for writing the actual message that we want to send that we need OutStr. OutStr will contain the message, and Comcom will send it.&lt;/P&gt;
&lt;P&gt;To associate Comcom with OutStr, add this line:&lt;/P&gt;
&lt;P&gt;OutStr := ComOut.GetStream;&lt;/P&gt;
&lt;P&gt;Then, compose the message using OutStr:&lt;BR&gt;OutStr.WRITE('This is my message.');&lt;/P&gt;
&lt;P&gt;Once the message is done, we just need to send it. Send it in this way:&lt;BR&gt;ComOut.Send(0);&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;That’s the application done. Finally, we just need to add our bus adapter, which needs to be specific to what transport media we are using - in this case MSMQ.&lt;BR&gt;Add one more global variable:&lt;BR&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Subtype&lt;BR&gt;MQBus&amp;nbsp;Automation&amp;nbsp;'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter&lt;/P&gt;
&lt;P&gt;To “plug in” the bus adapter, type in these lines at the beginning of the codeunit: &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;create(MQBus);&lt;BR&gt;MQBus.OpenWriteQueue('My-pc2\Myqueue',0,0);&lt;BR&gt;// On Win2000, use MQBus.OpenWriteQueue('.\private$\Myqueue',0,0);&lt;BR&gt;Comcom.AddBusAdapter(MQBus,0);&lt;/P&gt;
&lt;P&gt;Your final codeunit should now look like this:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;OnRun()&lt;BR&gt;CREATE(Comcom);&lt;/P&gt;
&lt;P&gt;CREATE(MQBus);&lt;BR&gt;MQBus.OpenWriteQueue('My-pc2\Myqueue',0,0);&lt;BR&gt;Comcom.AddBusAdapter(MQBus,0);&lt;/P&gt;
&lt;P&gt;ComOut := Comcom.CreateoutMessage('Message queue://');&lt;BR&gt;OutStr := ComOut.GetStream;&lt;BR&gt;OutStr.WRITE('This is my message.');&lt;/P&gt;
&lt;P&gt;ComOut.Send(0);&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;To test is, try to run it, then look the queue and see if the message was sent.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, we want to receive this message.&lt;BR&gt;Receiving a message &lt;/P&gt;
&lt;P&gt;Create a new codeunit with these variables:&lt;/P&gt;
&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Datatype&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SubType&lt;BR&gt;Comcom&amp;nbsp;Automation&amp;nbsp;Navision Communication Component version 2'.CommunicationComponent&lt;BR&gt;InMsg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Automation&amp;nbsp;'Navision Communication Component version 2'.InMessage&lt;BR&gt;InStr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InStream&amp;nbsp;&lt;BR&gt;MSMQBus&amp;nbsp;Automation&amp;nbsp;'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter&lt;BR&gt;Line&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 250&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Highlight the Comcom variable, go to properties, and set the property WithEvents to Yes. This will create a new trigger called:&lt;BR&gt;Comcom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")&lt;/P&gt;
&lt;P&gt;This trigger will automatically run whenever there is a new message in the queue.&lt;/P&gt;
&lt;P&gt;The finished codeunit should look like this:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;OnRun()&lt;BR&gt;CREATE(Comcom);&lt;BR&gt;CREATE(MSMQBus);&lt;BR&gt;MSMQBus.OpenReceiveQueue('nuk-cp\private$\lll',1,1);&lt;BR&gt;Comcom.AddBusAdapter(MSMQBus,1);&lt;/P&gt;
&lt;P&gt;Comcom::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")&lt;BR&gt;InMsg := InMessage;&lt;BR&gt;InStr := InMsg.GetStream;&lt;BR&gt;InStr.READTEXT(Line);&lt;BR&gt;MESSAGE(Line);&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Go to Codeunit Properties, and set the property SingleInstance to Yes. Now, you can either run it from the object designer, or you set up NAS to run this codeunit.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you should now have 1 codeunit to send a message to MSMQ, and another codeunit which can listen to this queue, and which is triggered as soon as a message arrives.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Lars Lohndorf-Larsen&lt;/P&gt;
&lt;P&gt;Microsoft Dynamics UK&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Microsoft Customer Service and Support (CSS) EMEA&lt;/P&gt;
&lt;P&gt;These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8499474" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/nav_developer/archive/tags/Comcom/default.aspx">Comcom</category></item></channel></rss>