001 public class MyMessageQueue
002 {
003 private static MessageQueue mq;
004 private static log4net.ILog log = log4net.LogManager.GetLogger("MyMessageQueue");
005 private static string QUEUE_NAME = @".\Private$\mymessagequeue";
006 private static object lockObject = new object();
007 private static MessageQueue MQ
008 {
009 get
010 {
011 if (mq == null)
012 Init();
013 return mq;
014 }
015 }
016
017 private static void Init()
018 {
019 try
020 {
021 if (!MessageQueue.Exists(QUEUE_NAME))
022 {
023 mq = MessageQueue.Create(QUEUE_NAME);
024 log.Info("Queue created :" + QUEUE_NAME + " path :" + mq.Path);
025 }
026 else
027 {
028 mq = new MessageQueue(QUEUE_NAME);
029 log.Info("Queue connected :" + QUEUE_NAME + " path :" + mq.Path);
030 }
031 }
032 catch (Exception ex)
033 {
034 log.ErrorFormat("myMessageQueue.Init(): {1}", ex.Message);
035 }
036 }
037
038
039
040 public static object Get(string key, Type t)
041 {
042 lock (lockObject)
043 {
044 try
045 {
046 object reply = null;
047 using (MQ)
048 {
049 mq.MessageReadPropertyFilter.CorrelationId = true;
050 using (MessageQueueTransaction trans = new MessageQueueTransaction())
051 {
052 Message msg;
053 if (mq.Transactional)
054 {
055 trans.Begin();
056 msg = mq.ReceiveByCorrelationId(getCoorId(key), trans);
057 }
058 else
059 {
060 msg = mq.ReceiveByCorrelationId(getCoorId(key));
061 // get message given type
062 msg.Formatter = new XmlMessageFormatter(new Type[1] { t });
063 reply = msg.Body;
064 }
065 }
066 }
067 return reply;
068 }
069 catch (Exception ex)
070 {
071 log.ErrorFormat("myMessageQueue.Get(): {1}", ex.Message);
072 return null;
073 }
074 }
075 }
076
077 public static bool Send(string key, Object o)
078 {
079 bool success = false;
080
081 try
082 {
083 Message msg = null;
084 msg = new Message();
085 msg.Body = o;
086 msg.Label = key;
087 msg.Recoverable = true;
088 msg.TimeToBeReceived = new TimeSpan(5,0,0,0);
089 msg.AcknowledgeType = AcknowledgeTypes.PositiveReceive | AcknowledgeTypes.PositiveArrival;
090 msg.CorrelationId = getCoorId(key);
091
092 using (MQ)
093 {
094 using(MessageQueueTransaction trans = new MessageQueueTransaction()){
095 if (mq.Transactional)
096 {
097 trans.Begin();
098 mq.Send(msg, trans);
099 }
100 else
101 {
102 mq.Send(msg);
103 }
104 success = true;
105 }
106 }
107 }
108 catch (Exception ex)
109 {
110 log.ErrorFormat("myMessageQueue.Send(): {1}", ex.Message);
111 }
112 return success;
113 }
114
115 private static string getCoorId(string key)
116 {
117 string rst = new Guid() + @"\"+ key;
118 return rst;
119 }
120 }
Tuesday, November 10, 2009
A simple class that saves and retrieves messages from MSMQ. This allows you to save objects in the message. Just send the object along with the key. Then get by the key and the type of object : Get("myKey",typeof(string}).
Tuesday, May 5, 2009
Happy Cinco de Mayo
There was as discussion at work about Cinco de Mayo. It was said that it celebrates Mexico's Independence from Spain. This was corrected to 'from France'. Then it was corrected again that Mexico's Independence day is actually September 16th. Someone said that Cinco de Mayo was created by the beer companies to sell beer. This one is most believable.
After a little googling, I came across http://www.mexonline.com/cinco-de-mayo.htm , this should be reputable, it is from mexonline. ;)
According to this article,
Mexico's Independence day is September 16th.
Cinco de Mayo commemorates the victory of the Mexican militia over the French army at The Battle Of Puebla in 1862.
Ok, so Cinco de Mayo is not Mexico's Independence day. It is a day which the people of Mexico fought and won against the occupying French.
So this is a victorious day which deserves to be celebrated.
So Cheers to Mexico on both May 5th and September 16th.
Note to self: Add September 16th to Holiday List.
After a little googling, I came across http://www.mexonline.com/cinco-de-mayo.htm , this should be reputable, it is from mexonline. ;)
According to this article,
Mexico's Independence day is September 16th.
Cinco de Mayo commemorates the victory of the Mexican militia over the French army at The Battle Of Puebla in 1862.
Ok, so Cinco de Mayo is not Mexico's Independence day. It is a day which the people of Mexico fought and won against the occupying French.
So this is a victorious day which deserves to be celebrated.
So Cheers to Mexico on both May 5th and September 16th.
Note to self: Add September 16th to Holiday List.
Labels:
beer,
celebrate,
Cinco de Mayo,
victory
Sunday, April 12, 2009
Easter Sunrise Service at Sea World
We went to the Easter Sunrise Service at Sea World with Ellis and Tylor from Z88.3, Lisa Whelchel (Blair on Facts of Life) and Big Daddy Weave.
God provided another great service to celebrate Resurrection Day! Lisa was great sharing her personal relationship with Jesus and His role in her life with us. Big Daddy Weave was awesome! What a great band!
Here are some photos of the event.
The Stage, pre service

The hosts from Z88.3 (Ellis and Tyler) introduce Big Daddy Weave
Waiting for the sun.

Big Daddy Weave performing. What a great band!

Hello Sun.

Big Daddy Weave performing after the sun rise.

Signing autographs
God provided another great service to celebrate Resurrection Day! Lisa was great sharing her personal relationship with Jesus and His role in her life with us. Big Daddy Weave was awesome! What a great band!
Here are some photos of the event.
The Stage, pre service

The hosts from Z88.3 (Ellis and Tyler) introduce Big Daddy Weave

Waiting for the sun.

Big Daddy Weave performing. What a great band!

Hello Sun.

Big Daddy Weave performing after the sun rise.

Signing autographs
Saturday, April 11, 2009
Easter BMX Classic
We got to check out the 2009 Easter BMX Classic. It was pretty cool. There were a ton of ridders and a ton of heats. Riders from 5 to 17+, boys and girls.
Here you can see the track and all the tens in the background.

Here is one of the many heats, with the leader way out in front.

Here someone just took a spill over turn 3, ouch!

Here is one of the girl heats. I couldn't believe some of them were racing in jeans.

And a shot of the first table top.
Here you can see the track and all the tens in the background.

Here is one of the many heats, with the leader way out in front.

Here someone just took a spill over turn 3, ouch!

Here is one of the girl heats. I couldn't believe some of them were racing in jeans.

And a shot of the first table top.
Saturday, April 4, 2009
Mini Tractor Pull!!!!
We decided to go down by the lakefront to see what the Rotary Club was putting on. Besides fair booths and rides,they had mini tractor pulls! Yes, mini tractor pulls! I did not know this excited. I like regular tractor pulls, but this was better, another use for the riding lawnmower. I have seen the ridding mower races, I thought they were very red neck, but this, this was brilliant! So I took some photos and video to share with my dad, who loves tractor pulls. So enjoy!
Note: click on the picture for full size
The mini-Tractors

The Sled!
The Pulls!
Full Pull!!!! by 01LittleNut

Pull Videos
Note:turn volumn down before playing videos
Note: click on the picture for full size
The mini-Tractors

The Sled!
The Pulls!
Full Pull!!!! by 01LittleNut

Pull Videos
Note:turn volumn down before playing videos
Monday, January 5, 2009
Web applications on 64-bit Windows
If you have developed a web application and are concerned if your users will have any issues with your web app on a 64-bit Windows machine, you might find this helpful.
I needed to do this research for the web applications I have written and maintain.
If your application uses PDF to deliver content, then the 64-bit user should be using Adobe Acrobat 8.1+. According to Adobe “Adobe Acrobat 8.0 was not developed for the Windows XP x64”, but 8.1+ versions do support 64-bit machines. The latest version is 9.x, which supports 64-bit.
If your application uses Java Plug-in, then the 64-bit user needs to use a 32-bit browser and they will be good. According to www.java.com “Currently Java Plug-in, Java Web Start, and Java Control Panel are not available for 64-bit systems. However you can still download 32-bit version of JRE, in order to use Java Plug-in and Java Webstart on 64-bit systems.
Note: Make sure to have 32-bit version of browser installed on your 64-bit machine as the Java plug-in works only with 32 bit version of browser.”
So if you are using Adobe Acrobat or the Java Plug-in, you will not have any code changes! It just falls on the Help Desk to verify that the users follows the vendor's recomended configuration.
That's good news to me!
I needed to do this research for the web applications I have written and maintain.
If your application uses PDF to deliver content, then the 64-bit user should be using Adobe Acrobat 8.1+. According to Adobe “Adobe Acrobat 8.0 was not developed for the Windows XP x64”, but 8.1+ versions do support 64-bit machines. The latest version is 9.x, which supports 64-bit.
If your application uses Java Plug-in, then the 64-bit user needs to use a 32-bit browser and they will be good. According to www.java.com “Currently Java Plug-in, Java Web Start, and Java Control Panel are not available for 64-bit systems. However you can still download 32-bit version of JRE, in order to use Java Plug-in and Java Webstart on 64-bit systems.
Note: Make sure to have 32-bit version of browser installed on your 64-bit machine as the Java plug-in works only with 32 bit version of browser.”
So if you are using Adobe Acrobat or the Java Plug-in, you will not have any code changes! It just falls on the Help Desk to verify that the users follows the vendor's recomended configuration.
That's good news to me!
Friday, January 2, 2009
Read XML files to List of XML Strings Dynamically
I needed to dynamically get XML files into a list of strings for load testing a web service. To improve performance this list needed to be static, but I wanted it to also be random. So here is what I came up with:
A class to load and contain the list of xml string from xml files:
Now to call it from the webTest inside of the GetRequestEnuberator().
To get the string for FormPostParameters, I create a string like this:
And here is the random method:
This will allow you to just drop xml files into the directory "TestXMLFiles" and they will be randomly put into your load test. I think it's cool. ;)
A class to load and contain the list of xml string from xml files:
public class TestXMLFiles
{
private static List_xmlStrings;
public static ListXmlStrings
{
get
{
if (_xmlStrings == null)
{
try
{
// get files
string[] _files = System.IO.Directory.GetFiles("../../../WebService_LoadTest/TestXMLFiles", "*.xml");
// create list for strings
_xmlStrings = new List(_files.Length);
System.IO.StreamReader _stream;
// cycle through files
foreach (string _file in _files)
{
// open stream to file
_stream = System.IO.File.OpenText(_file);
using (_stream) // this will dispose of stream when done
{
// read from steam to list
XmlStrings.Add(_stream.ReadToEnd());
}
}
}
catch (Exception e)
{
throw e;
}
}
return _xmlStrings;
}
}
}
Now to call it from the webTest inside of the GetRequestEnuberator().
To get the string for FormPostParameters, I create a string like this:
String _xml = TestXMLFiles.XmlStrings[getRandomXML()];
And here is the random method:
private int getRandomXML()
{
Random rand = new Random();
return rand.Next(0, TestXMLFiles.XmlStrings.Count);
}
This will allow you to just drop xml files into the directory "TestXMLFiles" and they will be randomly put into your load test. I think it's cool. ;)
Thursday, January 1, 2009
Javascript and complex field names
If your web form has need for a more complex naming structures for the field names like "user.first_name" instead of the basic "firstName". Then you might have run into issues trying to access these fields for a javascript form validation.
For the basic field name like "firstName":
<input type="text" name="firstName" value="">
You could access this by using the following:
_form.firstName.value
But if you are using the more complex naming structure like "user.first_name":
<input type="text" name="user.first_name" value="">
The _form.user.first_name.value will not work. You need to access it like this:
_form["user.first_name"].value
For more consistent style of code when using complex field names you should go ahead use the style _form["blah"].value for all of the elements in your javascript.
Have a great Day!
For the basic field name like "firstName":
<input type="text" name="firstName" value="">
You could access this by using the following:
_form.firstName.value
But if you are using the more complex naming structure like "user.first_name":
<input type="text" name="user.first_name" value="">
The _form.user.first_name.value will not work. You need to access it like this:
_form["user.first_name"].value
For more consistent style of code when using complex field names you should go ahead use the style _form["blah"].value for all of the elements in your javascript.
Have a great Day!
Labels:
form,
javascript,
validation,
web
Subscribe to:
Posts (Atom)
