November 2007 - Posts
I work for a very community oriented company. Black Marble host events on quite a regular basis at a hotel/conference centre in Tong (West Yorkshire) that cover all things technical and usually have some MSDN folk about who travel up to see use from Reading.
A week or so ago I presented at the evening community event about something that I find so powerful that it scares me. It feels like it's the kind of thing you hear them say in films where if this kind of power were to fall into the wrong hands then there'd be all sorts of trouble. I presented about the Dynamic Language Runtime for .NET.
It all started a few years back, when Microsoft released version 1 of .net to the world. Some people tried implementing Python on it, and didn't have an awful lot of luck. They dismissed the .net platform as a waste of space for dynamic languages. However, it wasn't quite that simple. Jim Hugunin (creator of Jython; Python on Java) decided to work out what Microsoft had done so badly and set out to implement Python on .Net.
IronPython was born. Jim was offered a job by Microsoft to improve the CLR for dynamic languages and the story continues.
After version 1 was released, the team looked at what they'd done to get a dynamic language working on the framework and realised that they could abstract a lot of the common behaviours out into a library so that other languages could be implemented on top of it.
So the DLR was started. Currently in alpha, IronPython is being the first language implemented on it, with 3 more Microsoft endorsed languages on the way behind it and some community languages being based on it as well.
Here's my demo slides and the source file that I used for the presentation. If you've got any questions on it or would like any more examples or details, then I can be contacted through this blog! :)
Presentation
Sample Project
OK, so I'm still learning BizTalk, and a lot of this is I'm reading tutorials and working out the best way to do things. Today I learnt about the "Listen" shape in Biztalk. In summary it allows you to wait for any number of specified messages, or fall through in a certain amount of time if no messages are received. So what does this have to do with the singleton pattern?
Well at the moment they run in parallel branches, and I'm sensing the the scopes are causing a few problems (not to mention parallel branches don't actually run in parallel).
So what does it look like now?
Before
After
As you can see, it's a lot simpler. Also as a nice little side effect, it consumes less resources! :) We no longer need a custom variable to store the state (we can use the value of the message itself) and the process is now only single threaded. We also don't need to take care of any transaction scopes or take thread safety into consideration. On the offchance that messages start coming in quickly (which they won't in this case as they're only control messages) then they will be queued until processing loops back round.
That's it for now! Let's see if I find a way of making it even simpler! :P
A couple of the tasks I'm working on at the moment involve polling (eugh) webservices to see if we've got new data to be retrieved, or running scheduled tasks on an hourly or daily basis.
So as not to separate the application into separate components, and have other process trigger this, I've created some long running orchestrations that have few overheads and can be controlled by passing in various XML messages (which then, due to the nature of BizTalk can be any form of message such as webservice/msmq/carrier pigeon etc)
These instances will only ever have one instance of them running, and additional messages will be received mid-orchestration and acted upon. This is the singleton pattern.
Now I will confess, most of what I'm writing here is taken from http://aspalliance.com/1208_Singleton_Orchestration_in_BizTalk_Server and modified for my own purposes. It's mostly here for my own reference and for anyone else that may be stuck in a similar situation.
Instructions
- In Your Orchestration, you will need the following "bits"
- An initialising message attached to a port
- A boolean variable used to control whether you want to stop execution of the orchestration
- A CorrelationSet to tie the orchestration and any future messages together. This wants to use BTS.ReceivePortName as the Correlation Properties
- Start off your orchestration by Receiving an instance of your message.
- Activate = True
- Initializing Correlation Sets = YourCorrelationSet
- Message = YourMessageVariable
- Encase all of the following steps into a ParallelActions component (this is so that we can listen for control messages and perform processing simultaneously).
- On the left hand action:
- Create a scope with the transaction type set to None and Synchronised set to True
- Create a while loop inside the scope that depends upon our controlling boolean
- Inside the while loop, receive another instance of the message from the same port, and analyse it to see if we need to change our controlling variable or do some other processing etc.
- On the right hand action:
- Create a scope with the transaction type set to None and Synchronised set to True
- Create a while loop inside the scope that depends upon our controlling boolean
- Inside the while loop perform the stuff that we want the orchestration to achieve
- Don't forget the delay! (Otherwise you're going to eat a lot of processing cycles)
- That should be it. Sit back and watch your magical BizTalk orchestration start gradually automating your world :)
Edit: Forget to tell you what to make the correlation set match up with! D'oh!
Edit2: Also forgot that you need to put synchronisation scopes around the contents of the parallel actions
Welcome to the nth iteration of my entrance into the world of blogging. This is kind of a brief introduction to me to introduce me to technorati etc (as BizTalk is a bit of black magic sometimes ;))
This blog is going to be relatively technical, but still be a beginners guide to all things Enterprisey (such as BizTalk, Sharepoint, and a lot of .NET things)
I work for Black Marble in Bradford as a Software Developer. That's about it for now :P
Technorati Profile