The mysteries of software development and networking... RSS 2.0



 Wednesday, November 12, 2008

We had an interesting workflow issue the other day. For some inexplicable reason our state machine workflow was terminated. After digging around in the database trying to reconstruct what might have happened we finally figured it out:

We have a transaction scope activity which sends an update to the database. The update failed and the exception cause the fault handler on the activity to kick in. The fault handler changed the state of the state machine to custom state called 'TechnicalError'. We explicitly modeled this state because it allows our administrators to recover a workflow from a technical error and essentially restart the workflow. In the InitializeState of the 'TechnicalError' state we wanted to update some data in the database. This also failed, since the cause of the original error was that we had lost connectivity to our database.

Next?

Since we had no fault handler on this database action the workflow crashed. Since connectivity to our workflow persistence database was also lost we now have a situation where the workflow in memory is inconsistent with the data in our line of business application database and is also inconsistent with the last persisted state in the workflow persistence database.

Next?

The workflow runtime never crashed several minutes later the workflow persistence database came back online and the in memory state of the workflow (which was terminated) was sync-ed with the workflow persistence database. However, our line of business database was never updated. The timestamp on the updates in the workflow persistence database where minutes apart from the last updates in the line of business database, which made it hard to reconstruct what had happened.

Solution?

We now have a fault handler on the initialize state of the 'TechnicalError' state. If the workflow persistence database OR the line of business application database is unavailable then a delay is introduced. And the workflow retries to transition to the TechnicalError state. This way the workflow will never ever terminate. The only scenario left is where the machine running the workflow is turned off. If this happens then the workflow will recover from it's last save point and life should be good.

Wednesday, November 12, 2008 1:51:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | WF

 Roadshow-September-2008_thumb

The Maine Developer Network is proud to announce that the Northeast MSDN Roadshow by Chris Bowen and Jim O'Neil will once again make it as far north as Augusta!

Don't hesitate: sign up today!

 mdn_logo

Wednesday, November 12, 2008 1:28:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Saturday, November 01, 2008

It would appear that LINQ to SQL is running on a dead end track.

At PDC the announcement was made that no more investments in LINQ to SQL are made and the Entity Framework will absorb any features that LINQ to SQL has and that are worth preserving.

The following message from Tim Mallalieu says it all:

Is LINQ to SQL Dead?

We will continue make some investments in LINQ to SQL based on customer feedback. This post was about making our intentions for future innovation clear and to call out the fact that as of .NET 4.0, LINQ to Entities will be the recommended data access solution for LINQ to relational scenarios. As mentioned, we have been working on this decision for the last few months. When we made the decision, we felt that it was important to immediately to let the community know. We knew that being open about this would result in a lot of feedback from the community, but it was important to be transparent about what we are doing as early as possible.  We want to get this information out to developers so that you know where we’re headed and can factor that in when you’re deciding how to build future applications on .NET.  We also want to get your feedback on the key experiences in LINQ to SQL that we need to add in to LINQ to Entities in order to enable the same simple scenarios that brought you to use LINQ to SQL in the first place.

Saturday, November 01, 2008 5:26:24 AM (Eastern Standard Time, UTC-05:00)  #    Comments [2] -
LINQ
 Friday, October 31, 2008

Live Mesh has gone from Tech Preview to official beta status. This also means it has gone world wide!

"Worldwide availability. We’ve removed the limits on what countries are able to sign up to use Live Mesh. We previously had limitations in place so that we could complete our testing with various language and locale settings, and now that work is indeed complete (with the caveat of course that for now the mobile client, as mentioned above, is not actually available worldwide)."

Yesterday I watched Don Gillet's PDC session on building a Mesh Application. It looks very easy.

My main concern with all this data in the cloud is securing my data. I'm thinking I may need to implement some sort of EncryptedDataEntry class which derives from DataEntry. I'll think about it some more...

Friday, October 31, 2008 1:42:15 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Tuesday, October 28, 2008

In the past I looked at the OpenID standard in relation to Cardspace and AOL. Now Microsoft has committed to making Windows Live ID (previously known as Microsoft Passport) support the OpenID initiative.

"Beginning today, Windows Live ID is publicly committing to support the OpenID digital identity framework with the announcement of the public availability of a Community Technology Preview (CTP) of the Windows Live ID OpenID Provider."

The Live Services page does not mention Cardspace in relation to OpenID, but it stands to reason that as an OpenID provider Microsoft will somehow offer Cardspace support as well, just like www.myopenid.com.

Tuesday, October 28, 2008 1:28:31 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Monday, October 27, 2008

Windows Azure is the name Microsoft has given to the cloud based platform. If you're not at PDC (like me) then go here for more information: http://www.microsoft.com/azure/services.mspx.

"The Azure™ Services Platform (Azure) is an internet-scale cloud services platform hosted in Microsoft data centers, which provides an operating system and a set of developer services that can be used individually or together. Azure’s flexible and interoperable platform can be used to build new applications to run from the cloud or enhance existing applications with cloud-based capabilities. Its open architecture gives developers the choice to build web applications, applications running on connected devices, PCs, servers, or hybrid solutions offering the best of online and on-premises."

The Cloud Computing and Services Platform Diagram

Looks like my personal point of interest, Live Mesh, is part of this platform:

"Live Services includes Mesh technologies for synchronizing user’s data and extending web applications across multiple devices."

Monday, October 27, 2008 11:25:27 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Sunday, October 26, 2008

After discovering that the LINQ to SQL Designer will only support tables from a single data source I set out to manually implement a cross database query using two data contexts.

The result is the following query which joins orders in the OrderDB to products in the VideoGameStoreDB.

public List<Order> FindOrders( string typename )

{

    try

    {

        var productdb = new VideoGameStoreDBDataContext();

        var orderdb = new OrderDBDataContext();

 

        var query  = from o in orderdb.Orders

                     join p in productdb.Products on o.ProductID equals p.ProductID

                     where p.ProductType.ProductTypeName.Contains( typename )

                     select o;

 

 

        return query.ToList();

    }

    catch ( Exception exception )

    {

        Trace.WriteLine( exception );

        throw;

    }

}

 

LINQ to SQL is unable to resolve this query, even though both databases sit on the same server. The compiler will however not warn you not to do this, instead a runtime exception with message 'The query contains references to items defined on a different data context.' occurs.

In a scenario like this the only solution appears to be to write a stored procedure which can perform the cross database query and use that stored procedure from a data context.

Sunday, October 26, 2008 5:16:21 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
C# | LINQ

The LINQ to SQL Designer supports just one connection, which makes sense since a LINQ DataContext is scoped to one connection. The designer does offer to change the connection string for you, but I guess making cross database queries is not possible using the designer.

The following message is what you get when dragging a table from a second data source onto the design surface.

image

Sunday, October 26, 2008 4:25:01 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ

I just discovered that the LINQ to SQL Designer does not support User Defined Types.

The following message appears when I try and add a table from my database to my design surface. The Customer table in question has a UDT named 'Point' to specify the GPS location of the business.

image

Sunday, October 26, 2008 4:17:42 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ

Daylight savings for Europe started today. The United States does not switch to daylight savings until the first Sunday in November (this year: Nov. 2nd 2008). Between now and then the time difference between the States and Europe is one hour less.

Sunday, October 26, 2008 3:23:25 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General

At PDC this week Microsoft is announcing a new logo for .NET.

Looks very refreshing!

newdotnetlogo

NET_v_rgb_2[1]

NET_h_rgb_2[1]

Sunday, October 26, 2008 3:12:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Saturday, October 25, 2008

With LINQ to SQL you can choose to use an external mapping file, allowing you to map SQL statements to CLR objects (also referred to as POCO, Plain Old CLR Objects). Doing so means you do not need to adorn your classes with attributes.
Here's a little sample of how to do this.

public class Supplier
{
    public int ID { get; set; }
    public string Name { get; set; }
}
 
public List<Supplier> GetSupplier( string name )
{
    SqlConnection conn = new SqlConnection( cConnectionString );
 
    XmlMappingSource xms = XmlMappingSource.FromUrl( @"mapping.xml" );
 
    var db = new DataContext( conn, xms );
 
    Table<Supplier> Suppliers = db.GetTable<Supplier>();
 
    var query = from s in Suppliers
                where s.Name == name
                select s;
 
    return query.ToList();
}
 
 

The XML can be as simple as:

<?xml version="1.0" encoding="utf-8"?>
<Database Name="VideoGameStoreDB"
          xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
  <Table Name="dbo.Supplier" Member="Supplier">
    <Type Name="Supplier">
      <Column Name="SupplierID" Member="ID" />
      <Column Name="SupplierName" Member="Name"  />
    </Type>
  </Table>
</Database>
 

You can use SQLMetal (a command line tool included with Visual Studio) to generate a mapping file.

Saturday, October 25, 2008 8:27:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ
 Wednesday, October 15, 2008

The SDN Conference 2008 was a great success, thanks to all the speakers and attendees for making it so!

Beth Massi has a great write up on the day after the conference, the traditional Holland Tour: http://blogs.msdn.com/bethmassi/archive/2008/10/14/holland-tour.aspx.

Time to start working on SDN Conference 2009 :-)

Wednesday, October 15, 2008 9:22:17 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Monday, September 29, 2008

Microsoft has put up a page to inform us about the next version of Visual Studio,  it is called Visual Studio Team System 2010.

Part of the new deal is a change in licensing, the fun part is: the licensing change takes effect on October 1st 2008!!!

Those of you who subscribe to MSDN and will now have access to both the Developer and DBPro edition of VSTS:

Better Together – Visual Studio Team System Development Edition and Database Edition
In recognition of the increased need to integrate more of the lifecycle members together, we will provide a unified Development and Database product in Visual Studio Team System 2010. Beginning October 1, 2008 Development Edition and Database Edition MSDN subscribers will have access to both products.

Monday, September 29, 2008 2:55:49 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -

 Saturday, September 27, 2008

I just answered an email asking for a referral to a good hosting place, thought I'd blog about my experience with my hosting provider.

I've been running my blog and website with DiscountASP.NET for the last 3 years and never had an incident. They offer ASP.NET 3.5 hosting and usually offer options to test beta versions of ASP.NET or SQL Server as well, which is something I like. They're not the cheapest, but in my opinion, worth the money.

Click the banner to go to their site.

In the spirit of transparency: The link contains a referral code which will generate a kickback for me :-)

Saturday, September 27, 2008 7:14:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
ASP.NET | General

The Maine Developer Network is helping out the MSDN Roadshow. Thanks to Shawn we're able to have the MSDN Roadshow come as far north as Augusta, ME. On October 3rd the Developer Evangelists for the New England region: Chris, Bob and Jim will be up (or down) in Augusta to present the latest and greatest .NET technologies. A full day of FREE training, open to everyone!

Sign up here: http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032387795&culture=en-US

Topics are:

  • Understanding the ADO.NET Entity Framework
  • Discovering Dynamic Data
  • Exploring Internet Explorer 8
  • RoboLunch
  • UI, UX, U Confused?
  • A RESTed Development
  • Befriending Unit Testing

Location:

Riverview Psychiatric Center
250 Arsenal Drive
Sebago Room Augusta Maine 04332-0011
United States

There will be give aways and ofcourse plenty of fun people to meet!

Saturday, September 27, 2008 5:52:26 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Saturday, September 06, 2008

Here is a good reason to always keep improving:

:-)

Saturday, September 06, 2008 12:10:24 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
General
 Wednesday, September 03, 2008

Registration for the SDN Conference 2008 is open. Visit: www.sdc.nl

SDN Conference

Wednesday, September 03, 2008 1:45:41 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
General
 Saturday, August 30, 2008

According to Matt Winkle some performance enhancements have been made to the Workflow designer in Visual Studio 2008 SP1. Strangely enough no mention of these improvements is made in the release notes. I wonder if they made it in.

Matt Winkle: "In .NET 3.5 SP1, there are no features introduced, but there have been a number of internal improvements made, including some substantial perf gains in the WF designer (for certain scenarios)."

Saturday, August 30, 2008 8:37:17 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Friday, August 29, 2008

Windows Workflow scheduling services manage how workflow instances are scheduled by the workflow runtime engine. Whether they are handled in an asynchronous manner through the DefaultWorkflowSchedulerService, or in a manual, synchronous manner through the ManualWorkflowSchedulerService, these services are an important part of your workflow solution.

The application I'm working on right now uses ManualWorkflowScheduler, so I needed to figure out the exact differences between the two scheduler, luckily MSDN actually offers pretty clear documentation:

Default Workflow Scheduler Service

DefaultWorkflowSchedulerService is used by the workflow runtime engine by default. It creates and manages the threads that run workflow instances in an asynchronous manner on the workflow runtime engine. Workflows that are waiting to run are stored in the internal queue of the DefaultWorkflowSchedulerService . When the DefaultWorkflowSchedulerService wants to start a workflow, a thread is acquired from the .NET Framework thread pool and used to run the workflow. The MaxSimultaneousWorkflows property determines how many simultaneous threads the scheduler service will allow at one time. If the limit is four, for example, the DefaultWorkflowSchedulerService will acquire up to four threads from the .NET Framework thread pool to execute the workflows. If four workflows are already running, additional work items (workflows) are placed in the queue and eventually executed as threads become available. The following figure shows how the DefaultWorkflowSchedulerService executes workflows in an asynchronous manner.

defaultworkflowscheduler

You can set the maximum number of workflow instances that can be active at any one time by passing a parameter to the DefaultWorkflowSchedulerService constructor or by using an application configuration file. Task 1: Configure Runtime Services Using Code shows how to configure the DefaultWorkflowSchedulerService class by using the constructor. Task 2: Configure Runtime Services using App.Config shows the same configuration of the DefaultWorkflowSchedulerService but uses an application configuration file.

Manual Workflow Scheduler Service

The ManualWorkflowSchedulerService provides a threading service that enables the host application that creates a workflow instance to donate the Thread on which the workflow instance is run. Using this threading service, host applications can run a workflow instance on a single Thread (that is, in synchronous mode). This mode blocks the execution of the host application until the workflow instance becomes idle. Subsequently, the workflow instance can only be executed by using the RunWorkflow method of this service.

Alternatively, the workflow can be run on a thread created by a .NET timer by setting the useActiveTimers constructor parameter to true. When this timer expires, the workflow is executed on the timer's thread, rather than the host application's thread. This timer is implemented as a DelayActivity activity.

ManualWorkflowSchedulerService controls the number of threads spawned in an ASP.NET process by reusing the thread that made the ASP.NET Web request to run the workflow instance. This ensures that at any time, the number of active threads in the workflow runtime equals the number of active Web requests in the ASP.NET process.

ManualWorkflowSchedulerService does not automatically run a workflow instance that is in the queue. The host must call RunWorkflow to run a specified workflow.

Friday, August 29, 2008 4:49:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 334
This Year: 78
This Month: 2
This Week: 0
Comments: 94
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)