Geeks With Blogs

News This is the *old* blog. The new one is at blog.sixeyed.com
Elton Stoneman
This is the *old* blog. The new one is at blog.sixeyed.com

[Source: http://geekswithblogs.net/EltonStoneman]

As part of the testing for the Dynamic Looping Convoy solution, I wanted performance testing with LoadGen, which proved to need almost as much development as the BizTalk design.

The standard LoadGen message creation from templates, and even the Dynamic Message Creator wouldn't work for my case where I wanted to generate messages in related sets, all of the same type but each only populating part of the schema. So the message id would be the same for a set, but the segment number would dictate what else was populated.

I ended up writing a custom IMessageCreator implementation to generate the convoy messages, which is not complex, but doesn't seem to be too well-trodden a path. Here's the class with the interface methods highlighted:

  • OptimizeFileSizeLimit lets you specify when streaming comes into play for large message; in my case the message were all small so this is just a get/set of a local field;
  • CreateNewMessage is where the message generation happens. In the convoy case you need to be wary that LoadGen can operate in multiple threads, so I have static methods to return the current message id and segment number*. The method retrieves the next segment info, selectively populates a segment, and returns it to LoadGen. LoadGen expects a byte array, so the class is serialized to XML and the bytes are passed out:

public Message CreateNewMessage(Message OriginalMessage, string TemplateFilePath, string NewMessageUniqueFileSuffix)

{

//construct the segment:

MessageSegment messageSegment = GetNextSegment();

IncomingSegment segment = new IncomingSegment();

segment.HireId = messageSegment.MessageId;

segment.SegmentNumber = messageSegment.SementNumber;

//add data:

switch (segment.SegmentNumber)

{

case 1:

segment.CustomerId = "CUST_X";

break;

//etc...

}

//retrieve XML as byte array:

byte[] buffer = this.SerializeSegment(segment);

//populate outgoing message:

Message outgoing = new Message();

outgoing.MessageData = buffer;

outgoing.MessageLength = buffer.Length;

outgoing.MessagePath = OriginalMessage.MessagePath;

outgoing.MessageExtension = OriginalMessage.MessageExtension;

 

return outgoing;

}

* - there are issues with this in any case, as you may have the situation where the thread count is not a multiple of the expected segment count so you'll get incomplete sets generated. Useful if you want to check error handling in your BizTalk solution, but you can stick to a single LoadGen thread if not (although this has its own limitations).

You get the last message created by LoadGen in the OriginalMessage parameter, which you can use to populate the path and extension of the outgoing message – note the path will be ignored in favour of the DstFilePath set in config. The complete Section in config looks like this:

<Section Name="FileSection">

<MessageCreator Mode="Synchronous">

<SleepInterval>10</SleepInterval>

<QueueLength>10</QueueLength>

<Assembly>x.y.Test.dll/x.y.Test.LoadGen.ConvoyMessageCreator</Assembly> <TemplateFilePath>x:\Msg100Segment1.xml</TemplateFilePath>

</MessageCreator>

<SrcFilePath>x:\Msg100Segment1.xml</SrcFilePath>

<DstLocation>

<Parameters>

<DstFilePath>x:\x.y\Locations\SegmentReceive</DstFilePath>

</Parameters>

</DstLocation>

</Section>

Note that you need to specify TemplateFilePath and SrcFilePath and they need to exist, even if you don't use them. And I couldn't get Asynchronous mode to work (it would always use the source file path over the message creator config), but Synchronous runs the message creator.

Posted on Monday, September 15, 2008 7:31 PM BizTalk 2006 R2 , LoadGen 2007 | Back to top


Comments on this post: Implementing LoadGen.IMessageCreator to Generate Convoy Messages

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
I will ask me bro about some of these terms, my english isnt the best....

Santos Catolicos, Santos Religiosos, Imagenes de Santos Catolicos
Left by Catholic Saints Names List, on Jul 08, 2010 5:38 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
I admire the valuable information you offer in your articles. I will bookmark your blog and have friends check up here often. I am quite sure they will learn lots of new stuff here than anybody else!
Left by dedicated server489 on Sep 24, 2010 6:41 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
Your posts are always so interesting and informative. Always do enjoy returning back to read more. Hope will post again soon.
Left by ipad scrapbook app on Oct 07, 2010 7:05 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
I haven't any word to appreciate this post.Thanks a lot for sharing.... Looking forward to reading your next post.
Left by Actor Headshots London on Mar 08, 2011 9:45 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
I have go through your articles and found some information which is quite important for me. It is very informative. thanks a lot.
Left by Edinburgh Bed and Breakfast on Mar 09, 2011 4:11 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
Thanks for taking the time to share this, I feel strongly about it and love reading more on this topic.
Left by driving lessons Birmingham on Jun 17, 2011 3:52 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
It's good that you will moving your posts from your old blogs. I will be looking forward to read your posts.
Left by Edinburgh Bed and Breakfast on Jul 11, 2011 5:01 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
Thanks for taking this opportunity to converse about this, I feel fervently about this and I like learning about this subject. I have you bookmarked your site to check out the new stuff you post.
Left by Sensory Deprivation Tank on Jul 20, 2011 7:01 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
This is all a bit over my head
Left by Driving school Bristol on Sep 18, 2011 5:40 PM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
Great piece very nice article keep them coming driving lessons Portishead
Left by Driving Schools Portishead on Jul 16, 2012 11:47 AM

# re: Implementing LoadGen.IMessageCreator to Generate Convoy Messages
Requesting Gravatar...
A very useful information provided. Which will be very useful in future.
Left by Blog Reviews on Sep 07, 2012 12:36 PM

Your comment:
 (will show your gravatar)


Copyright © Elton Stoneman | Powered by: GeeksWithBlogs.net