Morning Coffee 1

I gave up drinkin’, I gave up smokin’
I gave up thinkin’ all the time, stone cold revoken
No reason to my rhyme, I wasn’t jokin’
If there’s a phony bone in me, I want it broken
Rub It In” by All Day Sucker

I’m trying to write more in 2007. Here’s a roundup of stuff rattling around my brain:

  • Fight On! So much for Michigan and their bleating about being left out of the championship game. Also, massive congrats to Boise State.
  • Santa did bring me free time this holiday, but I spent it playing games rather than writing them. I’m digging Gears (big surprise) and Dead Rising, and I’ve starting playing Viva Pinata with Patrick. Plus, I finished GRAW which I had on loan from a friend just in time to start playing Vegas. Note I said “free time” which is to say time when I wasn’t hanging out with my family. Typically during naps or after everyone was in bed, though I did skip at least one birthday party to play instead.
  • We had a “surprise” snow storm two days after Christmas. Not enough to be dangerous driving, but enough to make a snowman with my kids. It’s still there, though now that it’s 55 degrees, I’m guessing it will be totally melted by the time I get home from work. It’s been melting a little bit each day, so it’s been like watching the climax of Raiders of the Lost Ark in slow motion.
  • My wife and I finished watching season 5 of Alias last night. Fun, though it had really jumped the shark by Season 5. We watched the entire series on DVD, which really makes me wonder about the future of broadcast TV. We watched season 1 of Lost on DVD but we’ve been watching on TV ever since. I’m hooked on Lost, so there’s no way I could go back to DVDs at this point, but I’m thinking that DVD is a better way to go for most TV. I wonder how this will change TV storytelling.
  • I wish I could see how a show like Lost or Alias evolves over time. How much of the Rimbaldi story arc was mapped out before the show started? How did the production team deal with forced changes like Jennifer Garner’s pregnancy or the apparently surprise series cancellation?
  • I had 12 days off for the holidays, so it’s very tough to be back at work. As I suggested above, I did very little coding while I was off, so getting back in the saddle won’t be easy. It’s especially hard on my little boy that I’m back to work. He was acting up yesterday which is fairly unusual. I finally asked him if he was sad about me going back to work and he broke down crying. I’m very lucky to be a part of such a tight knit family.
  • I’ve been in my “new” job for six months, but it seems like longer. I mean that in a good way. It feels like I fit better in this job, on a much smaller team, actually building stuff instead of just “evangelizing” it. Nothing against evangelism, I just think I burned out on that job.

So starts a new feature on DevHawk. As you might guess from the “1″ in the title, I’m hoping to make this a regular feature. As I ease back into work, expect more tech related nuggets along with the more random stuff. I should admit, however, that I actually don’t drink coffee. 😄

My Wife, YouTube, MySpace and All Day Sucker

My wife was poking around on YouTube and found two videos she wanted to show me. The first was a music video from a band called okgo where they dance on treadmills. Interesting for about 60 seconds. Unfortunately, the video is three minutes long. Still, it is currently #8 on YouTube’s Most Watched All Time list. The other was a much funnier video called Stick Magnetic Ribbons on Your SUV (sung to the tune of Tie a Yellow Ribbon ‘Round the Old Oak Tree). The song is by the Asylum Street Spankers and the video was produced by Devil’s Night Productions.

Among Devil’s Night’s other work is an almost unknown movie called Matters of Consequence that stared Morty Coyle. Morty fronts a band called All Day Sucker, which was born out of the ashes of a band called THE iMPOSTERS. Back when I lived in LA, I used to go see THE iMPOSTERS pretty much whenever they played. This must have been the second half of 1996, when I was dealing with a massively broken heart. They had a regular gig every week, though I forget the name of the place. But I was there, pretty much every week. I used to carry Morty around the club on my shoulders during the harmonica solo of Rational Anthem. Wow, was that really 10 years ago?

Anyway, you check out a few songs from of All Day Sucker on their MySpace page. Some of the songs – Heavy Weather and Rub It In – date back to the iMPOSTERS days. Their album is available from CD Baby and from Zune, Rhapsody and iTunes. (No direct link for artists on Zune?) Check them out.

It’s amazing how small the world seems when you run across old friends online like this. Especially when the recent wind storm and power outage two weeks ago served as such a rude reminder of just how big the world really is, regardless of how it seems.

Good Week for Hobbyists and Students

Both XNA Game Studio Express and Microsoft Robotics Studio shipped their 1.0 releases this week. So once you’re done hacking a robot to mow your lawn, you can relax by debugging your latest game on your Xbox 360. W00t!

Santa, please bring me a few extra hours per day so I can play with this stuff!

Transactions in Workflow Foundation-land

I’ve been spending some quality time with SSB and WF of late. On the balance, my opinion of both these technologies is very positive, though each has some warts of note. For Service Broker, they got the transactional messaging semantics right, but much of the lower level connection management – what SSB calls “routes” are clumsy to deal with. For Workflow Foundation, the execution model is amazingly flexible. Unfortunately, WF’s support for transactions is significantly more rigid.

If you’re build a SSB app, you’re typical execution thread looks like this:

  1. Start a transaction.
  2. Receive message(s) from top of the queue.
  3. Execute service business logic. Obviously, this varies from service to service but it typically involves reading and writing data in the database as well as sending messages to other services.
  4. Commit the transaction

When I sat down to marry SSB and WF, I naively assumed I could simply use WF for step three above. Alas, that turns out to be impossible. This thread on MSDN Forums has most of the gory details, but the short version is that WF does not support flowing host managed transactions into the workflow instance. As per Joel West in the aforementioned thread:

“[T]he WF runtime in V1 only supports flowing in a transaction on WorkflowInstance.Unload. There are various ways that you could try and hack this (with a custom persistence service or WorkflowCommitWorkBatchService) but if you do this it won’t work correctly 100% of the time and the times when it fails (error conditions or failures causing the tx to rollback) will be exactly when you are expecting transactional consistency.

Bottom line – the only way to make this work is to call WorkflowInstance.Unload inside your transaction scope.  This was the best that we could do in V1 to try and enable this pattern in some form.  Not always ideal but it can be made to work for most scenarios that require usage of an external transaction.”

So the WF compatible execution thread looks like this:

  1. Start a transaction
  2. Receive message(s) from the top of the queue
  3. Load/Create the associated workflow instance for the received messages
    • All messages received are guaranteed to be from the same SSB conversation group, which is roughly analogous to a WF instance, so this turns out to be fairly easy
  4. Enqueue the received message in the workflow instance
  5. Unload the workflow instance
  6. Commit the host transaction
  7. Reload the workflow instance
  8. Run the workflow instance (note, I’m using the manual scheduling service)
    • Workflow instance creates a transaction if needed
  9. Unload the workflow instance (typically done via UnloadOnIdle in the persistence service)
    • Assuming the workflow instance needed a transaction, it gets committed after unload

Basically, you use two transactions. One host managed transaction to move the message from SSB to WF instance and one WF managed transaction to process the message.The need for two transaction instead of one is unfortunate, but required given the current design of WF. And frankly, given the importance and difficulty of transaction management, I’m not that surprised that WF has hard coded transaction semantics. Trying to build a generic transaction flow model that would work in the myriad of scenarios WF is targeting would have been extremely difficult. At least there is a work around, even if it means using two transactions and loading and unloading the workflow instance twice.

However, there is a silver lining to the two transaction approach: two unexpected benefits when dealing with poison messages. First, SSB doesn’t have dead letter queue like MSMQ does. Moving a poison message to a dead letter queue would break SSB’s exactly once and in order semantics.(MSMQ doesn’t guarantee in order delivery) But moving all messages into the WF instance gets them out of the main SSB queue so poison messages don’t continue to get processed over and over.

Second, because the workflow instance is peristed after the messages are enqueued, there’s a representation of the workflow after the message is received but before the message is processed. If there’s a poison message, attempting to processing the message will fail and rollback to this state. This persisted workflow instance could be sent to a developer who could step through it to determine the cause of the error. We could even have developer versions of runtime workflow services so we could read remote data and simulate data updates. I wouldn’t want the developer updating production data in this way, but it would be great for troubleshooting issues.

Streaky Caps

Washington Capitals record in the past four games: 4-0
Washington Capitals record in the past ten games: 4-4-2

That is what in the business of hockey you call “streaky”.

When your recent winning streak includes wins over Dallas (16-8 at the time, 19-9 now) and Eastern conference leading Buffalo (20-3-2 then, 21-4-2 now), you can feel pretty good about yourself. Being only one point out of the playoffs doesn’t hurt either.

On the other hand, the East is a beast this year. Only Florida and Philadelphia are below .500. Everyone else is in the thick of the playoff hunt. Another six game slide would really hurt the Caps’ playoff chances. By comparison in the West, seven of the fifteen teams are below .500 (i.e. everyone not currently in a playoff spot). Dallas, at ten games over .500 is 3rd in the Pacific Division behind Anaheim (+18) and San Jose (+12).

Finally, it’s always nice to be looking down on the Penguins in the standings. But their not far behind. Their 26 points puts them in 13th place in the East, but they’re at .500 (11-11-4) and only five points out of a playoff spot. Next Monday’s game should be a good one. It’s even on national TV in HD!