Spaghetti Code Podcast - Connected Systems

by Matt Milner 12. May 2008 10:56

I got a chance a few weeks ago to sit down with Jeff Brand at the local Microsoft office and talk about something I love - Connected Systems.  We discussed Workflow and Biztalk, WCF and web services and how it all fits together.  Jeff is fun to talk to and does a good job of asking questions that developers are interested in.  The issues most developers face when building connected systems and trying to pick technologies were especially fun to discuss.  If you are interested, check out the audio - http://www.slickthought.net/post/2008/05/Spaghetti-Code-Podcast---Matt-Milner-on-Connected-Systems.aspx.

You can also check out some of his other podcasts with more Minneapolis folks on a range of topics: http://www.slickthought.net/category/SpaghettiCode.aspx

 

Enjoy!

Matt

Tags:

BizTalk Server | Windows Workflow Foundation | Windows Communication Foundation

Applied BTS R2 in the Windy City

by Matt Milner 10. April 2008 09:00

I've been teaching mostly WF and WCF lately, so I'm excited that in a couple of weeks (April 22) I'll be getting a chance to teach our core BizTalk course again in the lovely city of Chicago.  I'm excited because there is a lot of cool stuff for this particular open enrollment. 

1) R2 - need I say more? I will.  We will be using the latest bits to teach the core course from now on so you'll be learning BizTalk Server fundamentals using the latest and greatest version.  This is still a class for developers new to BizTalk, so if you have taken this class, you might be interested in the R2 features class that Jon is teaching in May and August. 

2) Dual Monitors!  Our crack sales team has negotiated dual monitors from the hardware vendor so you'll be able to see the lab manual and Visual Studio each in full screen glory!

3) It's in downtown Chicago right on Wacker Drive near all sorts of cool stuff for the evenings.

4) It's BizTalk and we'll cover all the three letter acronyms (TLA) BRE, BAM, WCF,WSE,ASMX (ok that's four letters), CSV, HAT, PUB (actually a technical term, but maybe where we'll be in the evenings as well), SUB, EAI, ESB, SOA.  I could go on, but you get the picture. 

5) As if all the above are not enough, we have some seats available and the course is in a week and half, so the sales guys are "ready to deal".  Actually, their just ready to cut you some discounts :) , especially if you sign up two or three people together, but even if you are just signing up one developer.  Talk to our fabulous sales team to get more information or register with a discount.  Just tell them you read about it on my blog. 

Hope to see you there, and once I get back from the class, I promise some more technical content.  I've been working on some demos and samples that I'll be posting over the next couple of months. 

Tags:

BizTalk Server | General Musings

Elegant Code Podcast

by Matt Milner 17. March 2008 06:22

Last week I had the pleasure of teaching a class for Healthwise in Boise, and while there met David Starr.  David has a website called Elegant Code and we got a chance to sit down for a podcast during the week.  We chatted about WF, WCF, BizTalk, "Oslo" and being a Pluralsight instructor.  Have a listen if you are interested, and check out the rest of the site while you are there. 

David also organized the Boise Code Camp, which I, sadly, missed by just a day.  From the sound of it, this was a huge success and a pretty large event, even by west coast standards.  I'm sorry I missed it.

Tags:

General Musings

Minneapolis Developer Roundtable - REST and stuff

by Matt Milner 13. March 2008 17:22

I recently got to sit down with some local smart guys here in Minneapolis and we chatted about REST versus SOA.  It wasn't any kind of religious discussion, but it was fun to talk to people who build apps and work with developers every day to hear what they think about this topic. 

You can find the audio over on Jeff Brand's blog.  Enjoy!

We do these periodically and are looking for other folks that might be interested in joining, so if you live in the area, contact Jeff through his blog and let him know. 

Tags:

General Musings

Disappearing BizTalk Add Generated Items wizard with SQL adapter

by Matt Milner 12. February 2008 22:59

I've run into this in two different places now so I figured it was time to blog about it and hopefully help someone else out since I didn't see much about this on the web when searching.  What I experienced was that when I would try to add a schema for a table in SQL Server, the wizard would get part way through allowing me to configure it, and then it would just disappear (usually when I hit the next button after specifying the select state or when I was about to choose the tables for an updategram) with no errors in the UI or in the event log.  I have seen this in two different cases. 

In the first case, and easiest to fix, I was trying to access tables to create an updategram, but all of the tables names belonged to a schema other than the DBO schema.  Every time I tried to create the updategram, I would say I wanted to do the updategram and then wizard would crash.  In this case, I was able to duplicate the database tables in another database (using scripting of the sql from the sql management tool) and put it in the default namespace.  Then I updated the schema by manually changing the node in the updategram that corresponded to the table name so that it contained the schema name.  After making this change, the updated schema worked fine against the database.  So it seems like the adapter can handle the non-standard schemas at runtime just fine, but not at design time. 

I should note that the above scenario was with BTS 06, not the R2 release.  I haven't determined if this is still an issue in the latest bits. 

The other scenario where I ran into this problem was with a BizTalk solution that had been created in BTS 06 and which I was now opening with BTS 06 R2.  In this situation, I was creating a receive location and after I entered the select statement, the wizard would bail on my with no warnings or errors.  I'm still not sure why this one was happening, but here is what I did to get it working. I created a new empty BizTalk project in a brand new solution and used the wizard to generate the items, which worked fine for some reason.  Then I went back to my old solution and tried again and it worked.  I'm surmising that running the wizard once on a new project allowed the problem to be fixed, some update or reg setting tweaked with the new project type, but I don't really know, it could have been a fluke of some sort for all I know.  The end result is that now my wizard appears to be working fine with new and updated projects. 

Tags:

BizTalk Server

Microsoft live labs projects

by Matt Milner 6. December 2007 22:51

Several people are starting to blog about the introduction of the Volta project on live.labs.com.  This is a pretty interesting research project and points to an interesting development at Microsoft.  I get a little frustrated at times b/c I hear developers complain that a) Microsoft isn't agile enough and it takes them too long to release stuff, and b) there is too much stuff coming out of Microsoft for me to keep up.  Well which is it!

The stuff on live labs is really early stuff that is only interesting if you want to see what Microsoft is thinking about long term and provide feedback.  If you are going to get frustrated when you can't use this stuff in 6 months in production, then it is not for you.  That being said, looking at the list of projects out there, two really stick out for me: Volta and Deep Fish.  Volta is a really intesting project to me in that it potentially allows me to write client code once and have the framework take advantage of the richest platform on the client.  I think that is where it really shines, where I can create the UI and it will use Ajax on clients that don't have .NET, and use something richer like Silverlight 2.0 when it is there.  I think that is more compelling than figuring out architecture/deployment later on.  I watched a Channel 9 video a this summer about Volta: check out part 1 and part 2 to hear more about the ideas from

Jeff was just complaining about the fact that IE mobile has not evolved.  I look at the Deepfish project and it gives me hope that someday my Windows Mobile device will have a browser half as cool as the one on the IPhone. 

Tags:

General Musings

Minneapolis Roundtable on RIA

by Matt Milner 6. December 2007 21:56

A couple of weeks ago, I had the pleasure of participating in a roundtable event with some really smart folks from around the Minneapolis area.  Jeff Brand, our local evangelist and .NET sex symbol (self-proclaimed) organized the whole thing and recorded it using a very cool device from Microsoft that came out of their research group.  It is a panning video camera that can react to the voices and capture video of the person speaking.  I think Jeff had some problems getting it working just how he wanted, but it is still pretty cool stuff and I'm sure we'll get it ironed out for future chats. 

Jeff has some posts with the links to download the conversation if you are interested.  Unfortunately, I was in NC at the time teaching a class so I had to participate via phone and Live Meeting.  While it gave me a remote user look at the experience with the Roundtable device, it was less than optimal way to be an active participant in the conversation.  I'm looking forward to the next conversation when I can hopefully be in town. 

Tags:

General Musings

Updating the Retry Activity - adding timed interval

by Matt Milner 28. November 2007 14:19

Updated 11/29 - see below

I recently created a retry activity that I've been wanting to write for some time now, and had a few features that I wanted to add. I was teaching a class a couple of weeks ago and took the opportunity to add a retry interval to the activity.  The activity is designed as a composite activity which can retry its child activities if it detects that a fault/exception has occurred.  Rather than retrying immediately, I wanted the consumer of my activity to be able to specify a TimeSpan indicating how long to wait between retry attempts.

The simplest part was adding a property that allowed people to specify the interval. 

private TimeSpan retryInt;

public TimeSpan RetryInterval 
{
    get { return retryInt; }
    set { retryInt = value; }
}

 

The next step was to actually use this information.  When the child activity closes, my Retry activity checks if it faulted and then needs to reschedule the child activity for execution.  With the interval, I need a way to wait for a duration and then schedule the activity for execution.  Since my workflow could be persisted during this interval, I have to use a mechanism that will both support passivation, and allow for the workflow to be resumed automatically when the duration has been reached.  To support this I used the same mechanism that the delay activity uses, which is to create  timer subscription and then wait for an event signaling the time has expired. 

In my event handler for closing child activities, if I determine that I should retry the child activity, I use the following code to 1) create a new workflowqueue where the timer can signal completion, 2)register for data arriving on the queue, 3) create a TimerEventSubscription with my duration and my queue information and 4) add my timer subscription the collection on the workflow. 

 

DateTime expires = DateTime.UtcNow.Add(RetryInterval);
SubscriptionID = Guid.NewGuid();
thisContext.GetService<WorkflowQueuingService>().CreateWorkflowQueue(SubscriptionID, false).QueueItemAvailable += new EventHandler<QueueEventArgs>(RetryActivity_QueueItemAvailable);
TimerEventSubscription subscription = new TimerEventSubscription(SubscriptionID, WorkflowInstanceId, expires);
TimerEventSubscriptionCollection timers = GetTimerSubscriptionCollection();
timers.Add(subscription);

 

The GetTimerSubscriptionCollection simply grabs the collection from the parent workflow by recursively climbing the parent hierarchy. 

 

private TimerEventSubscriptionCollection GetTimerSubscriptionCollection()
{
    Activity parent = this;
    while (parent.Parent != null)
    {
        parent = parent.Parent;
    }
    TimerEventSubscriptionCollection timers = (TimerEventSubscriptionCollection)parent.GetValue(TimerEventSubscriptionCollection.TimerCollectionProperty);
    return timers;
}

 

Finally, I have the event handler for when data arrives on the queue for the timer.  I simply empty and delete the queue, then begin my next iteration on the child activity. 

 

void RetryActivity_QueueItemAvailable(object sender, QueueEventArgs e)
{
    ActivityExecutionContext ctx = sender as ActivityExecutionContext;
    ctx.GetService<WorkflowQueuingService>().GetWorkflowQueue(e.QueueName).Dequeue();
    ctx.GetService<WorkflowQueuingService>().DeleteWorkflowQueue(e.QueueName);

    BeginIteration(ctx);
}

 

So adding a retry interval turned out to be pretty simple and I was also able to provide a good example of how you can put your own delay into your activities.  In a later post, I'm going to talk about the other issue I had to manage which is how to deal with exceptions and control whether or not my Retry activity got put into the faulting state. 

 

BEGIN UPDATE

Someone posted a question on the original activity indicating some concern over the fact that I hadn't overridden the Cancel method.  In the simpler scenario I should have still done that, but with the addition of my retry interval it became even more important as I had more to clean up.  So I added the Cancel method and do two things in it.  First, I had to see if there were any spawned execution contexts that were currently executing indicating that I had an iteration in progress and cancel the root activity if I did.  I also had to add some code to remove the timersubscription in both the expected case and the exception case.  In the process, I factored some code into a helper method to remove the timer subscription and the workflow queue when I no longer needed them.  The cancel method now looks like this:

protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext)
{
    bool canClose = true;
    ActivityExecutionContext ctx = executionContext;
    //cancel any execution iteration
    if (ctx.ExecutionContextManager.ExecutionContexts.Count > 0)
    {
        ctx.ExecutionContextManager.ExecutionContexts[0].CancelActivity(ctx.ExecutionContextManager.ExecutionContexts[0].Activity);
        canClose = false;
    }
    //remove the timer and related queue if there is a subscription
    CleanupSubscription(ctx);
    return canClose ? ActivityExecutionStatus.Closed : ActivityExecutionStatus.Canceling;
}
Notice that I can only close the activity if the child is not currently executing.  If I had to cancel the child activity, then I can't yet close the retry, that will happen in the usual way when the child activity closes.  The other important step I added was to check the current ExecutionStatus of the retry activity before scheduling a new iteration.  If the activity has moved into the Canceling state, I shouldn't start a new iteration regardless of how many times I am supposed to retry. 

If you have any other feedback or suggested improvements, keep them coming. 

END UPDATE

The updated retry activity can be found here, and has been updated for Visual Studio 2008.  If you want the updates for 2005, just download the original, and then copy the class file for the retry activity from the new project.  I didn't use any new features of 2008, just updated the project and solution files, so it should work fine. 

Tags:

Windows Workflow Foundation

Visual Studio 2008 released!

by Matt Milner 19. November 2007 11:25

Hot off the presses, you can get it now from MSDN subscriber downloads or the trial version.  See Soma's blog for more details on the new features, etc. 

Surprisingly, being a WF and BizTalk guy, I'm least excited about the WF/WCF integration.  I'll talk more about what I dislike later, but this is a happy post!  I'm jazzed about the new web models in WCF if only because it provides a nice affirmation of the extensibility of WCF.  I might not like all of the details of how they have accomplished things, but the CSD team has certainly shown that WCF is a solid platform with all the extensibility hooks you need. 

I'm also excited to spend some time with LINQ now that I'll have the bits on my main PC (I have only put the beta on VMs or my secondary machine in my office).  Like everyone else, I've done the simple examples to get some data out of a database and bind it to a UI, but I really want to dig in and see how it works after I have some code written and want to change something in the database. I want to see what the visual modeler/designer can and cannot do, and how using XML files might benefit me more than using the simple path that is there in V1.  

The main thing that really sells this, and some folks don't know this, is that VS 2008 and .NET 3.5, build on the existing .NET 2.0 framework.  So, it should be close to a no-brainer for organizations to upgrade because they can still build their 2.0 applications without having to worry about using 3.5 assemblies if they use the multi-targeting correctly in VS / MS Build.  That's right, there are only additive changes and bug fixes in 3.5 and it uses the same 2.0 runtime that you are using today.  So there should be no issues with breaking changes to core things like datasets and remoting like there were moving from 1.1 to 2.0.  I'm upgrading all my boxes to take advantage of the new features and perf improvements.  The only reason I could see for not updating is if you have other tools like BizTalk or Commerce Server that depend on the 2005 version.  Then you can run both side-by-side, and maybe strip out some of the tools from 2005 that you no longer used to free up some space on your hard drive.   

So, download, enjoy, and happy coding! 

Tags:

General Musings | Windows Workflow Foundation | Windows Communication Foundation

Demos from SOA conference (including RetryActivity)

by Matt Milner 31. October 2007 14:48

If you attended my talk at the SOA conference on building composite activities, then you'll find the demos here.  I really liked doing this talk and it gave me a reason to work on a composite activity that I wanted to write for a while: the RetryActivity.  I started wanting to build this activity because when I teach people about WF and we talk about security on incoming data, there is always a question about how to handle failed authorization.  When the user fails authz on the built-in activities today, an exception is raised which I can catch and handle in the workflow.  The problem is that once I have done that catch, I close out the composite activity that caught the exception and I'm no longer listening for data.  Well, if Bob tries to submit data and fails because he isn't supposed to, I don't want to stop listening for data, I want to keep listening and let Alice (who is authorized) submit data and interact with my workflow.   The retry activity lets me do that by re-executing the child activities for a certain number of tries as long as an exception gets raised. 

The way I implemented this was to spawn a new execution context for each iteration much like the while activity.  In my case, what I use to determine if I'll iterate again is a combination of whether the child activity failed to succeeded, along with a retry count/max pair that lets me know if I should quit trying.  Naturally, if there are no failures, I just close and finish.  This allows me to use a single purpose activity for retry behavior instead of continually having use the while activity and check whether an exception was raised or not.  It also makes it easier to manage the errors raised by the child activities and nulling out the CurrentException property so I can decide when errors should propagate beyond my activity. 

Now, what I'd really like, related to security, is to move the authorization out of the workflow, so that authorization failures don't have to be modeled in my workflow unless I want them to be.  That way my workflow doesn't even get invoked if you don't have rights.  Something where I can declare the security in the workflow, and then generally be able to apply security to the queues that are used to communicate with the workflow.   The "Silver" or WCF activities in .NET 3.5 do a little of this by reading the validation from the workflow definition and invoking it before sending the data to my workflow. 

 

I'll be working on some other features of this activity to allow things like retry only on certain exception types, and the ability to put an interval between retries.  If there are other features you'd like to see, let me know and I'll put them on my plan. 

Tags:

Windows Workflow Foundation

Pluralsight Developer Training

View my developer training videos on Pluralsight.

Pluralsight .NET Training