Tuesday, July 14, 2009

Simon Segal: A WPF IronPython REPL and messaging with NServiceBus

Simon Segal has been building an Entity Framework tool with built-in IronPython scripting support. Part of this has involved creating quite a fully fledged interactive Python interpreter as a WPF GUI component. This turns out to be quite a useful tool on its own.
So to move forward with the WPF user control console project I decided to refactor it to support IronPython. Mark has jumped in just recently and started to contribute by adding the new “cached commands”, which offer up / down arrow repeat command behaviour such as found on a DOS console. You will also notice from the screenshot above I have imported the entire System namespace to demonstrate that it is possible (using the environment menu) to print the entire state of the default scopes current set of variables.
I have recently been working with NServiceBus quite a bit and whilst I was working on a WPF IronPython Console - User Control / Window, it occurred to me that it would be a useful tool in testing and monitoring behaviour of my services whilst running under NServiceBus. Let’s have a look at the simplest of examples by configuring up an IBus and publishing messages using Udi’s PubSub sample.


The other thing to note in the code above is that the configuration code from the PubSub sample is removed and what now remains is to create and run an instance of the IronPython Application Shell, effectively embedding IronPython into my NServiceBus publisher. Once this is done we are all set to start scripting our services and NServiceBus. If I run this code above I expect to see the the IronPython Application Scripting Window pop up ready for action.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.