by vj
13. May 2008 23:14
The below post will provide a "hello world" kind of introduction to connecting to a remote IBM WebSphere Message Queue server using client application written in C#.
Points to note:
- Server and client should have a common OS login name. The passwords can be different between the server and client, what matters is that the login name should be identical.
- The login name you have selected to use should be part of the MQM group on the MQ server, or it should be explicitly given permission for querying the Queue manager and the queue.
- I have come across code on the web where they have mentioned how to connect to MQ server even with a different OS login name from the client side by explicitly setting the login and password onto the MQEnviroment class static properties, but it has not worked for me till now. So, my example code would be assuming that there is an identical login name between the client and server.
- Make a note of the Server-connection channel name (case sensitive), queue manager name (case sensitive), queue name (case sensitive) from the server side.
- You would need to install at the least the client package of MQ onto the client machine, the client code would be using the library from this installation to connect to the server.
- A reference to amqmdnet.dll would have to be added to the client project, its located in <MQ Installation Path>\bin\amqmdnet.dll
Now for the code
1: using System;
2: using System.Collections.Generic;
3: using System.Text;
4: using IBM.WMQ;
5:
6: namespace RemoteMQTest { 7: class Test01 { 8: static void Main(string[] args) { 9: MQEnvironment.Hostname = "My_Server";
10: MQEnvironment.Channel = "My_Channel";
11:
12: string mqQueueManagerName = "My_Q_Manager";
13: string mqQueueName = "My_Queue";
14: int openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
15:
16: MQQueueManager qMgr = new MQQueueManager(mqQueueManagerName);
17: MQQueue q = qMgr.AccessQueue(mqQueueName, openOptions);
18:
19: MQMessage message = new MQMessage();
20: message.Version = 2;
21:
22: q.Get(message);
23:
24: Console.WriteLine("I got the message : {0}", message.ReadString(message.DataLength)); 25: message.Seek(0);
26:
27:
28: q.Close();
29: qMgr.Close();
30: Console.WriteLine("done!"); 31: }
32: }
33: }
Note that in line 25, we are explicitly making the message to seek back to 0th byte.
Happy coding 
by vj
12. May 2008 02:40
The Opera browser is my preferred browser as of now, with its low loading time and in-built support for mouse gestures and so many other small good things; it has established itself as the best choice for my taste. Even though it is great as it is out of the package, it helps a lot to customize it to iron out some quirks.
1. Adding Wikipedia quick search option
One of the neat things of Opera is that you can provide a quick search option, using which you can just provide a prefix letter and type your search term straight from the address bar; no need for any specialized area for making your search. Want to search google? or Yahoo!? or Answers? you can do just all this just by providing the appropriate prefix and typing your search term from the address bar (e.g., just typing "g vijay shankar ganesh" would search the term on google whereas providing "y vijay shankar ganesh" would search the same term on Yahoo!).
But, what escapes my logic is that how come they missed adding Wikipedia to the pre-built quick search options? Well, anyway its not much of a problem, all you need to do is Tools -> Preferences (Ctrl + F12) -> Search and then add the following details:
Name: Wikipedia Search
Keyword: w (w is by default used for download.com search, I seldom use it so I change w to use Wikipedia instead)
Address: http://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go
That's it, press OK and now you can just type "w" proceeded by your search term and you will be directly taken to the appropriate Wikipedia article if that's found or else it will take you to the result page of Wikipedia Search.
2. Open Folder option for transfers
Another one of those options which obviously needs to be present by default, it makes you wonder why it's the not the case though. Once your download / transfer has finished downloading / transferring, the right-click option on the transfers screen only provides you with option to directly execute / open the file. I most of the time prefer opening the folder where the download has taken place and then do what's needed of the file. This can be accomplished by following the method described in the following blog post:
http://my.opera.com/Tamil/blog/open-folder-in-transfers-right-click
Cheers!