Infosys Microsoft Alliance and Solutions blog

« April 2007 | Main | June 2007 »

May 28, 2007

MSMQ - Receiving messages from remote private queues

Sometime back I had blogged about how to send messages to remote private queues. There were a few queries on how to read from remote queue as well.

To me it should have worked by using the MessageQueue.Receive API instead of .Send. I decided to give this a try anyway and it indeed is as trivial as that. However a few things to take care while trying to get this working.

1. Check the documentation to see where all the API works. The API may have limitations in working in workgroup mode if you are not using the direct format name syntax.

2. The other very important aspect is setting the formatter prior to receiving the message. You need to set this appropriately to binary or XML and specific type to ensure successful read.

To show a complete example, find below code that posts to the remote queue (transactional as well as non-transactional) and also reads from them. To keep things simple, I have used a simple string message here. However you can definitely use more complex types and custom types for sending and receiving (as long as they match both ways).

        private void btnPostToQueue_Click(object sender, EventArgs e)

        {

            //post to regular non-transactional remote queue using OS name

            MessageQueue rmQ = new MessageQueue("FormatName:Direct=OS:punhjw30076\\private$\\remote");

            rmQ.Send("sent to regular queue - Atul");

 

            //post to  transactional remote queue using IP address

            MessageQueue rmTxnQ = new MessageQueue("FormatName:Direct=TCP:100.100.100.12\\private$\\remoteTxn");

            rmTxnQ.Send("sent to transacted queue - Atul", MessageQueueTransactionType.Single);

        }

 

        private void btnGetFromQueue_Click(object sender, EventArgs e)

        {

            //retrieve from regular non-transactional remote queue using OS name

            MessageQueue rmQ = new MessageQueue("FormatName:Direct=OS:punhjw30076\\private$\\remote");

            rmQ.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            System.Messaging.Message msg = rmQ.Receive();

            MessageBox.Show(msg.Body.ToString());

 

            //retrieve from transactional remote queue using IP address

            MessageQueue rmTxnQ = new MessageQueue("FormatName:Direct=TCP:100.100.100.12\\private$\\remoteTxn");

            rmTxnQ.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            System.Messaging.Message msgTxn = rmTxnQ.Receive(MessageQueueTransactionType.Single);

            MessageBox.Show(msgTxn.Body.ToString());

        }

Hope this helps !

May 18, 2007

Software Factory: Towards the Holy Grail of Software Development

Remember the days when you used to punch some quirky looking characters on a flickering green screen they used to call a "computer"? I guess most of us were not even born then.

Today with the luxury of High Level Languages (Man! When was the last time we spoke about "high level language"?) and sophisticated IDE with stuff like intellisense, software development has reached a new peak altogether. And so has the complexity of software systems.

The business, from the days of the green screen, has grown manifold to what it is today, and it's changing faster than ever. Software development methodologies have been trying to keep pace with the changing businesses finding new ways of addressing complexities and dynamism. Despite all the tools, complexities have been on the rise and the line connecting business and technology has continues to be elusive.

Increasing sophistication has only taken us so far, while a host of other issues from developer productivity to receptiveness to changes, faster production, adoption of standards, creating more predictable and sustainable systems have been a huge onus on the technology communities. One way the developers have tried to counter this is by creating reusable artifacts, frameworks and components. But for a swifter, cost-effective business, technology keeps changing so fast, that the reusable components itself may have to be revisited and updated every few months and hence increasing the overall development, maintenance and support cost of these components.

Today, we are at the forefront of another evolution. High Level languages with their english-like syntax will soon give way to business flow diagrams which would have the ability to emit and manage code all by themselves. Much like the assembly lines in the manufacturing industry where a base product line is created, and modified to come up with different variants, the current phase of the evolution is based on identifying software product lines and coming up with variants to suit specific businesses. This is broadly called Software Factories.

I’ll be writing more on the views, theories and practices of this next big thing in software evolution in the coming days.

May 14, 2007

WindowsClient.net

New Winforms and Windows Presentation Foundation (WPF) community site - http://windowsclient.net/Default.aspx. Lot of material to help developers... do check out the video section for a good collection of video tutorials 

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter