Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Message sending / receiving from Biztalk Server – Basic understanding needs verification
- This topic has 4 replies, 1 voice, and was last updated 9 years, 7 months ago by
community-content.
-
AuthorPosts
-
-
May 29, 2008 at 3:10 AM #19788
My requirement is thus – I have Application A which is supopsed to send messages to Application B using Biztalk Server. Application A is in C# Dot Net and Application B is in something else (I don’t really know).
I am working on Application A, so I don’t really care about how Application B picks up the messages etc. Application A’s responsibility is just to ensure that the messages are sent to the Biztalk Server. Also, Biztalk Server is already there in the high level architecture, so this question is not really about whether Biztalk Server is required here or not because we don’t really use the Biztalk Server functionality too much except for the message brokering part.
Since I am not very familiar with Biztalk, I am writing out my assumptions here. I need to know if I am on the right track and if not, then where I am wrong. Also, configuring and setting up Biztalk Server is not the scope of this discussion. I just need to know whether purely from Application A’s point of view, whether I am thinking right or not.
I am assuming that the Biztalk Server will have public queues set up by the Biztalk administrator, and Application A’s job is just to write to these queues. Then Biztalk Server will take care of either re-directing the messages to Application B or Application B will poll and pull the messages from the queues on Biztalk Server.
So, firstly I have to know the name of the server (machine) on which Biztalk Server is hosted. Let us assume the server name is SERVER1 and it is available on the intranet.
Then I have to know the name of the Queue on the Biztalk Server where I am supposed to send the messages. So the Biztalk administrator must set up a public queue and tell me the name of the queue, so I can programmatically use the name to send messages.
Assuming the Biztalk administrator does his job of setting up the Biztalk Server, and creating a queue for me, all that is left to me is to write a program in C# which will send a message to Biztalk Server.
I tried the above yesterday on my local computer, which has the Windows 2000 Professional SP4. By default, the Windows “Message Queueing Service” component was not installed on my computer, so I used the WIndows CD to install this component through the “Add / Remove Programs —> Add / Remove Windows Components”. So on my local machine, I had Windows “Message Queueing Service” up and running. I can see the same through the “Computer Management” window console … it shows me all the private / public etc queues.
I then wrote the following code in C#, to send string messages to a queue on my local machine.
*************************************************
MessageQueue m_queue1 = null;
const string m_queue1Name = “my_machine_name\\private$\\TestQueue1234”;
const string m_stringMessageLabel = “This is a String Message Label”;
const string m_stringMessageBody = “This is a String Message Body”;
if (MessageQueue.Exists(m_queue1Name))
{
m_queue1 = new MessageQueue(m_queue1Name);
}
else
{
m_queue1 = MessageQueue.Create(m_queue1Name, false);
}
//sending the message
m_queue1.Send(m_stringMessageBody, m_stringMessageLabel);//receiving the message
System.Messaging.Message inMessage = m_queue1.Receive();MessageBox.Show(“sendAndReceiveSimpleString : Message – ” + inMessage.Body.ToString());
*************************************************
So I wrote a string message to a local queue and also read it from the queue. Simple, nothing earth shattering.
Now my question comes up considering the Biztalk Server. If the things I have written above are all correct, then I would assume that just like I have a queue on my local machine which I can write to and read from using the above code, the only difference from a C# programming point of view would be to change “my_machine_name” to “biztalk_server_machine_name” in the above code where I am writing the queue name.
*************************************************
So the line –const string m_queue1Name = “my_machine_name\\private$\\TestQueue1234”;
would become –
const string m_queue1Name = “biztalkserver_machine_name\\TestQueue1234”; //assuming the queue is public on Biztalk Server, so removing “private$”
*************************************************
Am I right in assuming it is this simple? Please note that my scope here is not really in setting up Biztalk Server or managing any orchestrations or seeing how Application B gets the message. My job is just to ensure that I can send messages to the Biztalk Server and receive messages from it.
I have the following additional questions –
– The above code as stated is an asynch communication between Application A and Biztalk server. Application A just sends a message to the queue and goes on with life without caring what happens to the message. Is that correct? Alternately, in such a scenario, what would be a synchronous communication between Application A and Biztalk Server. What possibly could the C# program wait for …. acknowledgements?
– Suppose my C# programs has to get messages from Biztalk Server. In the above program, it just makes a call to “receive” and gets the message in the queue. However, in the real time program, there might be a message or not. So I am assuming that the C# program would have to be something like a windows service, which would sleep for specified time, and then wake up and make a “receive” or “peek” call to the queue, and if messages are present, then do some processing with it. If messages are not present, then go back to sleep. Would that be the best way to implement this or can the polling (or listening) be done in a better way?
Please give your comments on my post. Thanks in advance!
Sriram
-
May 29, 2008 at 3:43 AM #19790
Hi Sriram,
Your post is good enough but I am not very much clear about your purpose. Your first additional question is itself the answer of most of your queries. Since Biztalk works as middleware, therefore it is not in your scope to post ur data in Biztalk. Biztalk itself is responsible to pick the messages from source application and post it at destination location after doing the required transformation of data. In your case, you have posted ur data in local Queue using MSMQ feature of Windows. Now this private queue is configured with the MSMQ of the remote system, where Biztalk has been installed. Simply the public queue of that system pull data from ur system (No role of Biztalk) and ur Biztalk Server has configured with that public queue using MSMQ adapter, which picks data from local queue. Similarly it is configured at destination end with any adapter (depends where Biztalk needs to post the message). It could be SQL Server, SAP, File etc.
With Regards,
Mithun
-
May 29, 2008 at 6:55 AM #19791
Hi Muthun
Thanks for the reply. However, I am a newbie at Biztalk and so I want to get my ideas really clear here.
I am not really sure abuot the “purpose” of my requirement. This is because I am entering into a project which is being run by some people and the only thing I know is they plan to use Biztalk to be the middleware platform for message exchange between Application A and Application B … I don’t have more information with me. So I am trying to find out all I can so that when I am actually presented with the problem to be solved, (and I am a programmer, not an administrator who sets up Biztalk) I want to know what path to take purely from a programmer’s point of view. I have been told additionally that the interfaces to Biztalk would be done in Dot Net …. whatever this statement means.
I am just putting my understanding point by point. Please reply per point … I would really appreciate it.
– So ur reply seems to be – Application A cannot send messages to Biztalk. It is Biztalk that will pick up the messages from Application A.
– So the way for it would be – Application A posts the messages (Same code as shown above) to the remote server where Biztalk is running. A public queue on this remote server would be storing these messages sent by Application A. This queue is not a “Biztalk queue” as I said but just a MSMQ queue on the remote server. So Biztalk hasn’t done anything yet … the only thing is that this remote server has Biztalk installed on it.
– So Biztalk does not actually have queues … is that right …. I cannot post to a “biztalk queue” as I initially thought?
– Biztalk uses the MSMQ adapter to connect to the queue on the same machine (where my application A has put its message) where Biztalk is installed and pull the message from there. Then it does whatever (I don’t know the details) to change the XML format of the message to what the receiving application wants, and sends it to the receiving application through some mechanism – maybe again the queue mechanism through which the message came in, or something else.
On the other hand, if Application A (made in C# Dot Net) has to “receive” messages from Biztalk, then this would involve the following –
– Biztalk Server would receive the message from somewhere (I don’t care where or how) and process it, maybe to change the XML formatting to suit Application A’s requirement. Then it would push the message either into a MSMQ Queue on the local machine (Biztalk Server’s local machine) or into some local folder as a file (XML file maybe). Then it is my application A’s business to either listen to this queue or poll this folder on the Biztalk Server machine and pick up the message.
– Alternately, to the previous point, Biztalk Server could also send the message to some remote machine’s MSMQ queue (maybe application A’s local machine queue) or save it into some remote machine’s folder (Application A’s local folder) as a XML file. Then it is application A’s business to either listen to this queue or poll this folder on the local machine (Application A’s local machine) and pick up the message.
-
May 30, 2008 at 4:54 AM #19805
– So ur reply seems to be – Application A cannot send messages to Biztalk. It is Biztalk that will pick up the messages from Application A.
[Mithun]: Correct
– So the way for it would be – Application A posts the messages (Same code as shown above) to the remote server where Biztalk is running. A public queue on this remote server would be storing these messages sent by Application A. This queue is not a “Biztalk queue” as I said but just a MSMQ queue on the remote server. So Biztalk hasn’t done anything yet … the only thing is that this remote server has Biztalk installed on it.
[Mithun]: The heart of the Biztalk Server is its SQL Server DB “MessageBox”. It works on the concept of “Publish-Subscription” method, where Receive port picks message from any media (Linke Queue in ur case) using the corresponding adapter and publish it in DB. Similarly Destination application subscribes the DB for those messages and BTS post message to any media using the corresponding adapter. Biztalk has vast list of features, The Solution Architect decides how to use those.
– So Biztalk does not actually have queues … is that right …. I cannot post to a “biztalk queue” as I initially thought?
[Mithun] : Yes
Rest I will reply later.
Regards,
-
-
-
May 31, 2008 at 3:11 PM #19824
Sriram,
In response to your questions:
– To implement synchronous communications with BizTalk, you might want to consider using something other than MSMQ because MSMQ does not inherently support synchronous communication. WCF handles sync communications much more naturally than MSMQ. In BizTalk, one of the best ways to implement request/response communications is to publish a request/response WCF service. You can do this with MSMQ, but you would have to write some custom app to front MSMQ, such as a web or WCF service.
– Yes, you could write a C# Windows service to poll the queue on the BizTalk server. The benefit to this would be that you get durable communication (the apps can send messages to each other without caring if the other one is up). Well guess what, when BizTalk sends messages, it doesn’t really need MSMQ for durable communication. BizTalk itself is a message queue, so you could expose a WCF service from your app for BizTalk to submit messages into. If your app is down, then BizTalk can retry submitting the message until your app comes back up.
Hope this helps!
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.