Things hard and not so hard.... RSS 2.0
# Thursday, October 25, 2012

Great news – Jurgen Willis and his team have worked hard to bring Microsoft’s first V1.0 WF Workflow Hosting Manager.

It  runs both as part of Windows Server and within Azure VMs also. It also is used by the SharePoint team in 2013, so learn it once and you’ll get great mileage out of it.
(I’m yet to put it through serious paces)

Some links to help you out…

What is it?

WF Mgr 1.0 – Code Samples

 

The following main areas for WF improvements in .NET 4.5: (great MSDN magazine article)

  1. Workflow Designer enhancements
  2. C# expressions
  3. Contract-first authoring of WCF Workflow Services
  4. Workflow versioning
  5. Dynamic update
  6. Partial trust
  7. Performance enhancements

Specifically for WorkflowManager there’s integration with:

1. Windows Azure Service Bus.

So all in all a major improvement and we’ve now got somewhere serious to host our WF Services. If you’ve ever gone through the process of creating your own WF host, you’ll appreciate it’s not a trivial task especially if you want some deeper functionality such as restartability and fault tolerance.

but…. if you want to kick off a quick WF to be part of an install script, evaluate an Excel spreadsheet and set results, then hosting within the app, spreadsheet is fine.

Let’s go through installation:

Download from here

image

Workflow_Manager_BPA.msi = Best Practices Analyser.

WorfklowClient = Client APIs, install on machines that want to communicate to WF Manager.

WorkflowManager = the Server/Service Component.

WorkflowTools = VS2012 plugin tools – project types etc.

And we’ll grab the 4 or you can you the Web Platform Installer

image

 

The Workflow Client should install fine on it’s own (mine didn’t as I had to remove some of the beta bits that were previously installed).

Installing the Workflow Manager – create a farm, I went for a Custom Setting install below, just to show you the options.

image

image

As you scroll down on this page, you’ll notice a HTTP Port – check the check box to enable HTTP communications to the Workflow Manager.
This just makes it easier if we need to debug anything across the wire.

Select NEXT or the cool little Arrow->

On Prem Service Bus is rolled into this install now – accepting defaults.

image

Plugin your Service Accounts and passphrase (for Farm membership and an encryption seed).

Click Next –> to reveal….

image

As with the latest set of MS Products a cool cool feature is the ‘Get PowerShell Commands’ so you can see the script behind your UI choices (VMM manager, SCCM 2012 has all this right through). BTW – passwords don’t get exported in the script, you’ll need to add.

Script Sample:

# To be run in Workflow Manager PowerShell console that has both Workflow Manager and Service Bus installed.

# Create new SB Farm
$SBCertificateAutoGenerationKey = ConvertTo-SecureString -AsPlainText  -Force  -String '***** Replace with Service Bus Certificate Auto-generation key ******' -Verbose;


New-SBFarm -SBFarmDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=SbManagementDB;Integrated Security=True;Encrypt=False' -InternalPortRangeStart 9000 -TcpPort 9354 -MessageBrokerPort 9356 -RunAsAccount 'administrator' -AdminGroup 'BUILTIN\Administrators' -GatewayDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=SbGatewayDatabase;Integrated Security=True;Encrypt=False' -CertificateAutoGenerationKey $SBCertificateAutoGenerationKey -MessageContainerDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=SBMessageContainer01;Integrated Security=True;Encrypt=False' -Verbose;

# To be run in Workflow Manager PowerShell console that has both Workflow Manager and Service Bus installed.

# Create new WF Farm
$WFCertAutoGenerationKey = ConvertTo-SecureString -AsPlainText  -Force  -String '***** Replace with Workflow Manager Certificate Auto-generation key ******' -Verbose;


New-WFFarm -WFFarmDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=BreezeWFManagementDB;Integrated Security=True;Encrypt=False' -RunAsAccount 'administrator' -AdminGroup 'BUILTIN\Administrators' -HttpsPort 12290 -HttpPort 12291 -InstanceDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=WFInstanceManagementDB;Integrated Security=True;Encrypt=False' -ResourceDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=WFResourceManagementDB;Integrated Security=True;Encrypt=False' -CertificateAutoGenerationKey $WFCertAutoGenerationKey -Verbose;

# Add SB Host
$SBRunAsPassword = ConvertTo-SecureString -AsPlainText  -Force  -String '***** Replace with RunAs Password for Service Bus ******' -Verbose;


Add-SBHost -SBFarmDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=SbManagementDB;Integrated Security=True;Encrypt=False' -RunAsPassword $SBRunAsPassword -EnableFirewallRules $true -CertificateAutoGenerationKey $SBCertificateAutoGenerationKey -Verbose;

Try
{
    # Create new SB Namespace
    New-SBNamespace -Name 'WorkflowDefaultNamespace' -AddressingScheme 'Path' -ManageUsers 'administrator','mickb' -Verbose;

    Start-Sleep -s 90
}
Catch [system.InvalidOperationException]
{
}

# Get SB Client Configuration
$SBClientConfiguration = Get-SBClientConfiguration -Namespaces 'WorkflowDefaultNamespace' -Verbose;

# Add WF Host
$WFRunAsPassword = ConvertTo-SecureString -AsPlainText  -Force  -String '***** Replace with RunAs Password for Workflow Manager ******' -Verbose;


Add-WFHost -WFFarmDBConnectionString 'Data Source=BTS2012DEV;Initial Catalog=BreezeWFManagementDB;Integrated Security=True;Encrypt=False' -RunAsPassword $WFRunAsPassword -EnableFirewallRules $true -SBClientConfiguration $SBClientConfiguration -EnableHttpPort  -CertificateAutoGenerationKey $WFCertAutoGenerationKey -Verbose;

 

Upon completion you should see a new IIS Site…. with the ‘management ports’ of in my case HTTPS

image

 

Let’s Play Smile

Go and grab the samples and have a play – make sure you run the samples as the user you’ve nominated as ‘Admin’ during the setup – for now.

Thursday, October 25, 2012 3:06:11 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
Async | Azure | Integration | ServiceBus | BizTalk | 2010 | 2010 R2 | Dev
# Sunday, April 01, 2012

Local MS Developer pillar Andrew Coates spilled the beans on this next new language to come out of MS Research.

Db.NET or ‘D flat’ – F#, C# and the Cinderella of the 3 sisters ‘VB.NET’
(Last year I was introduced to F# over a 5 month project and absolutely loved the simplicity and freshness of it – async was simple, tasks, functions and code that would normally take 400 lines in C#, we were able to do in 100 in F#)

It promises:

- speed

- optimisation (I wonder if it’ll be smart enough to run tasks on different CPU cores?)

SNAGHTML7dd9a16

There is a focus on Orchestration – data Orchestration found here http://thenextlanguage.net/a-focus-on-orchestration/

Where it talks about “An example of the close collaboration between the product team and the company’s research arm is the use of Schenkerian Analysis in the compiler to maximize orchestration between sections of the code.”

Oooh I thought – let’s check out what this is Schenkerian Analysis and a quick check of Wikipedia reveals http://en.wikipedia.org/wiki/Schenkerian_analysis

Schenkerian analysis is a method of musical analysis of tonal music based on the theories of Heinrich Schenker. The goal of a Schenkerian analysis is to interpret the underlying structure of a tonal work. The theory's basic tenets can be viewed as a way of defining tonality in music. A Schenkerian analysis of a passage of music shows hierarchical relationships among its pitches, and draws conclusions about the structure of the passage from this hierarchy. The analysis is demonstrated through reductions of the music, using a specialized symbolic form of musical notation that Schenker devised to demonstrate various prolongational techniques. The concept of tonal prolongation, in which certain pitches determine the goal of other, subordinate pitches, is a cornerstone of the pitch hierarchy that Schenkerian analysis involves itself with.”

So tones, pitches and music is where this algorithm has its roots…I can see how you could take this analysis when applied to the frequency of music and apply it to the frequency of code items; data being hit etc.

I’ll crack open this VS.2011 extension and see what transpires…

Grab the TOOLS here - http://thenextlanguage.net/tools/

Sunday, April 01, 2012 8:10:48 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
.NET Developer | Async
# Saturday, December 17, 2011

Well folks – the appfabric labs have come out with a real gem recently.

In CTP we have:

  • EDI + EAI processing
  • AS2 http/s endpoints
  • ‘Bridges’
  • Transforms

and of course the latest version of

  • ServcieBus, Queues and Topics.

To get the real benefit from this ‘sneak peek’ there’s a bit of setup required. To those familiar with BizTalk there’s a few EDI screens declaring parties/partners and agreements you’ll have seen before.

To get cracking:

  1. Update your local bits with the latest and greatest - Installing the Windows Azure Service Bus EAI and EDI Labs - December 2011
    Part of this install is to install the Service Bus Connect component, which installs the BizTalk 2010 LOB Adapter pack.
    image

    So this is really quite interesting. As the WCF LOB Adapter SDK provides a framework for developers to build out ‘adapters’ to connect systems/endpoints through a sync/async messaging pattern.

    The BizTalk Adapter Pack 2010 is the BizTalk Team set of adapters built on top of the WCF Adapter Framework. The BizTalk Adapter pack includes:
    - SQL Server Adapter. Hi performance sql work, notifications, async reads, writes etc.
    - SAP Adapter – uses the SAP Client APIs (under the hood) to talk directly to SAP. Very powerful
    - SIEBEL Adapter
    - Oracle DB Adapter
    - Oracle ES Adapter

    These adapters are exposed as ‘WCF Bindings’ with BizTalk or a small amount of code, allows you to expose these adapters as callable WCF Services.

    What does this mean in our case here?
    If you think about your on-premise Oracle system, we now have a local means of accessing Oracle and we can then push the message processing (e.g. a new order arrived) into our ‘cloud’ bridge where we have the immediate benefit of HA + Scale. Do some work there, and spit the result out any which way you want. Maybe back down to on-premise, or in a Queue or to Azure Storage.

  2. Sign up to AppFabricLabs – http://portal.appfabriclabs.com and provision your ‘servicebus’ service.
    This provides your EDI/EAI relay endpoints and also provides a way for you to listen/send requests to/from the cloud.
  3. Here I have used mickservices as my ServiceBus namespace.
    image
    (I created a Queue and a couple of Topics for later use – not really needed here)
    Note: grab your HIDDEN KEY details from here – owner + <key#>
  4. From within the Portal Create a Queue called samples/gettingstarted/queueorders

    image
  5. Register at the EDI Portalhttp://edi.appfabriclabs.com
    Even though this says ‘EDI’ think of it as your sandpit. It’s where all your ‘widgets’ live that are to run in Azure Integration Services.

    The registration form had me stumped for a little bit. Here’s the details that work.

    image

    Notice my servicebus namespace – just the first word. I previously had the whole thing, then variations of it.
    Issuer Name: owner
    Issuer secret: <the hidden key from above>

    Click save/register and you should be good here.
  6. Once this is done – click on Settings –> AS2 and Enable AS2 message processing (which is EDI/HTTP – you might be lucky enough to get the msgs as XML, but most times no). This will create some endpoints for you b2bgateway… style endpoints.

    image
  7. At this stage, have a look under Resources and you’ll notice that it’s empty. But…they have Schemas, Transforms and Certificates. We’ll come back to that later.
  8. Let’s head to Visual Studio 2010 with the updates installed and open up the Sample Order Processing project.

    I installed my samples under c:\samples
    image

    If all opens well you should see:
    image

    Note: there’s a couple of new items here: (expand out artifacts)
    *.bcs – Bridge. There’s a MSDN Article describing these – I was like ‘what???’. Basically these are a ‘processing pipe’ of which various operations can be performed on a message in stages. These stages are ‘atomic’ and they also have ‘conditions’ as to whether they *need* to be applied to the said message. So a bridge could take a message, convert it to XML and broadcast the message out to a Topic.

    Opening up the designer – it gets pretty cool I must say!!!

    image
    Note the ‘operations’ on the LHS. I must have a play with these guys Smile 
    Another thought – how extensible is this? I’d bet we could write our own widgets to throw on the design surface as well.

    By double clicking on the BridgeOrders component, you can see the designer surface come up with the ‘stage processing’.

    image

    Here you can see the ‘bridge’ (I wonder if that term will last till the release) will accept only 2 types of message schemas – PO1 + PO2. Maps them out to a more generic PO format.
    The map – XMLTransform from my initial testing only applies one map, the first one that matches the source schema (this is the same as BizTalk).

    Close the bridge view down and leave the BridgeConfiguration open.
  9. Click anywhere on the white surface of the BridgeConfiguration and set your Service Namespace property from the Properties window (this guy was hard to find!!)
    Put <your service namespace> you created originally.
    image
  10. Save and click Deploy and a Deployment window comes up – put your details in from above.
    image

    After deployment completes, keep an eye on the Output window as this has all the URLs you’ll need for the next step. In particular the BridgeOrders.

    Feel free to go back to your Azure Portal –> Resources and see your deployed bits in there, Schemas, Transforms etc.

  11. Running what you’ve built – sending a message to the ‘bridge’ (here I’ve borrowed info from the ‘Readme.html’ in the sample project folder)
    We don’t need to setup the whole EDI Trading partner piece. – just send messages to a restful endpoint – aka the bridge.
    1. From the samples folder locate the Tools\MessageSender project. (you may have to build it in VS.NET first)
    2. from a command prompt run messagesender.exe
      image

      In my case it looks like this:

      image

      Took me a little to get this originally, make sure all your VS.NET stuff is deployed properly.

      So effectively we have sent PO1.xml to our ‘Bridge’ and it’s been accepted, validated and transformed into ‘something else’ and popped onto a Queue called Samples/gettingstarted/QueueOrders.

      We will now get the message Reader to Read it.
  12. From under the Samples\Tools folder locate the MessageReceiver project and build if required.
  13. From a command prompt at that location, run the following to Listen to the queue

    image






Wrapping up -

Here is obviously a quick walk through of what’s possible, performance, scale and throughput are other measures that we haven’t got here – given it’s CTP/Labs we’re not quite ready for that conversation.

BizTalk adapter pack will expose out for e.g. your SAP system to a wider audience and imagine having restful WCF services to call that provide you customer data in the format you want…or better still…deliver it straight to you!
(currently in BTS 2010, the adapter pack is licensed separately, it’s part of BTS standard or enterprise. BTS2009 it *was* licensed separately for RRP $5K. Maybe we’ll see this as a separate component again.)
Or you could do like the SharePoint team and write a brand new WCF Adapter (‘connector’ in their terms) – ‘Duet’ and spend 18 months doing so.

Some things I’d like to see here is a Rules Processor or Engine – being a long long BizTalk fan, the rules engine is a massive strength of any loosely coupled solution. The majority of BizTalk solutions I come across don’t employ any rules engines…or better still, Windows Workflow 2,3+ (but not 4 or 4.5) has a rules ‘executor’ which is very powerful in it’s own right. Who’s heard or used the Policy shape?

Given that this is a sneak peak at what is on the horizon, this is definitely a space not to miss.

Get those trial accounts going and enjoy!

In particular I’d like to call out Rick’s Article (well done Rick!) for a great read on this space also.

Mick.

Saturday, December 17, 2011 10:08:00 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
Async | BizTalk | 2010 R2 | BizTalk Adapter Pack | SAP
# Monday, December 12, 2011

Hi folks, as you may/may not have been aware these are the core corner stone technologies of the MS Integration Stack.

The teams have been busily plugging away and coming up with the new versions – 4.5 corresponding to .NET 4.5 framework.

Here’s some links that describe what’s new from MS Santa & his elves:

  1. What's New in Windows Communication Foundation 4.5
    1. New Items I found of note are:
      • New Service Transport Default values – keep an eye on these.
      • Improvements from VS.NET 2011 – validation , better intellisence support.
      • Streaming improved – true async (yay!)
      • WebSocket support – through NetHttp(s)Binding
      • Single WSDL file generation with ‘?singleWSDL’ (which is pretty handy)
      • Self hosted + II hosted allow you to get to ServiceHost from code for dynamic configuration.
      • Binary Encoder supports compression!! – this is generally gzip compression.
      • My personal favourite – UDP support
  2. What's New in Windows Workflow Foundation in .NET 4.5
    1. New Items of note are:
      • New Activites – NoPersistScope (possible previously but we needed to write code)
      • WF Designer improvements – several here, but the ‘Outline view’ looks to be easier to work with.
      • C# Expressions – where’s the F# ones Sad smile ??
      • Designer Annotations – add your own comments to keep control of the jungle that is built.
      • WF Versioning – use WorkflowIdentity & DefinitionIdentity to define the version. WorkflowServiceHost supports multiple versions of the same WF. All pretty cool.
      • WF Designers can still be rehosted – I’ve used that many a place.
      • Contract First Development – ticks the boxes.
    2. WF Rules – still didn’t make the cut. There is a sample for WF4 using a custom Activity calling back to WF 3.5 Policy4 it’s called. It uses ‘interop’ back to WF3.5 and is found here - http://msdn.microsoft.com/en-us/library/dd797584(v=VS.100).aspx
      1. Will have to check out perf in this new land on these rules.
  3. Async CTP – while this didn’t make the ‘whats new’ list, it certainly does deserve a mention here.
    Over the last year I’ve built some pretty serious F# projects, and F# has the async support through and through the language. After over coming the challenge of learning it, the Async functionality is absolutely brilliant!!! F# does a great job in being able to turn a non-async chunk of code/method/class into an async one with by using the keyword async and a !. It’s straight forward from that aspect.

    It’s great to see the C# & VB.NETs being able to use the same fundamentals (albeit not as slick IMO Winking smile). – see a previous POST - http://blogs.breezetraining.com.au/mickb/2011/04/26/EasierAsyncProgrammingComingToCVBSoon.aspx

    As developers we sit here and say – what do I need this for? My code runs fine as it….and yes for the most part of what we do on our machine it does. This technology really comes into it’s own when you want consistent throughput from a solution with 1 person or 10000 concurrent people using it. That’s the difference.

    To use it:
    1. Get VSNET 2011 (as it requires a new compiler)
    2. Use ASYNC CTP (refresh3) with VSNET2010 SP1
  4. Check it out from here - http://msdn.microsoft.com/en-us/vstudio/gg316360
Monday, December 12, 2011 12:00:52 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
.NET Developer | Async | BizTalk | Dev | .NET Framework 4.5
# Tuesday, April 26, 2011

Hi folks, I thought I’d share something that captivated me on this rainy Easter day and that was

Visual Studio Asynchronous Programming - http://msdn.microsoft.com/en-au/vstudio/async
(you’ll need VS2010 + SP1 before you grab the CTP)
There’s a new improved compiler + an extended library for us.

Hands up who’s done async programming in either VB.NET or C#??? It’s a pain! Thread management, Main UI threads can only update certain objects, passing values between main + background threads, determining whether a thread has completed its tasks… and so on…

Basically all these ‘issues’ keep us from delving further into the world of asynchronous programming cause it very rapidly becomes complex just managing the two worlds – sync + async.

Today I was pleasantly surprised!!!

About a year ago I saw a great presentation on F# and I was amazed at how if they wanted to run a bit of code async it was simple an extra character as in:

set results = …..   <-sync

set results! = ….  <- run this async

(don’t quote me on the above, but it’s something like that – let’s call it pseudo code)

Why are we interested in this? – that’s always the first question to ask when investigating. Too many times we here ‘this is really cool’ and ‘check this cool software out’ etc… but the real reason of WHY do we want to go down this road is never answered.

On a ‘developers machine’ looking at 5 items, running a single test client – you’d have to say “works on my machine” and you’d have no need to async anything. True. Let’s move beyond our beloved developer box and think about UAT/PROD environments and what your code is doing.

What happens if 4 concurrent requests come along – how is your code going to perform? (As developers we’d be thinking …’it’s in the hands of IIS, not my issue’ :) )
(I recently was presented with a solution that ran across 20 odd servers, the answer to everything was get more hardware to make the app more performant, scalable etc – couldnt be the code.)

So as the requests start to build (don’t know an exact number but let’s say 100/sec), what is happening to your code? how often do we sit down with profiling tools on our code in this space? must be the disks..slow…and as always we have definitive proof works on my machine says the developer!

It’s not until we see our code running under load that we get an appreciation for where things could be improved and are causing grief for not only IIS but other systems as well.

Scalability, performance and scalability – single threaded app/service vs multi-threaded. Multi-threaded tend to win all the time.

Let me give you a couple of suggestions where this stuff is great:

  1. As part of a WF/WCF/Class where you want to ‘push’ some processing into the background – critical things can be done upfront, and you can push some of the ‘other stuff’ into the background.
  2. Take advantage of some of the great multi-core/multi-cpu Servers out there – single threaded tend to run on the same core on the same CPU (known as thread affinity)

Anyway enough jabbering from me and let’s see some of the hidden gems…

Async Programming Framework

Let me show you a couple of examples (from my set):

1. Fetching a webpage

image

Here I go off to twitter and search for all the BizTalk items.

Couple of things to notice
- …Async is added to the end of routines for convention, indicating that these are Async callable routines.
- not a single IAsyncResult to be seen, no StateObject and no Callback routines!
– line 104 the async keyword indicating that this routine itself can be called async if desired (more for the compiler)
- line 108 the await keyword is used in the Async framework to ‘wait for the async task to complete’  then move onto the next line.
- line 108 WebRequest.Create(…).GetResponseAsync – it’s the GetResponseAsync that is the async method, no …Begin or ..OnEnd calls! Just write it as you read it.
- line 109 We get a reference to the response stream (I should check for the existence of data etc – demo code, demo code :))
- line 112 …await stm.ReadAsync(…) – reads the response stream into a buffer on a background thread and we wait there until this completes (await keyword). By all means there’s many other ways to program this, as in we don’t need to wait, we could run this guy in the background quite happy and then check on him periodically.

That’s it! Not too tough at all, multi-threaded goodness right there. You can have blocking and non-blocking calls etc.

2. What about a Chunk of CPU based code

NO Async Example – as per normal, doing some cpu things.

image

Written in Async….

image

Points to notice:
- line 63 async Task<int[]> … to the Async framework the async methods are wrapped within a Task class. We must ‘wrap’ anything we return from our routines within a Task<..> – here I’m returning an int[]
-line 66 … = TaskEx.Run(…something to run in a background thread…). As we’re dealing with a block of code, there’s a Task Extension class that allows us to run that bit of code Async.
-line 79 await matrix – this line ensures that our async routine has indeed completed (or errored) before we move onto the next line.

Too easy if you’ve lived in the other world.

As always remember this is CTP so I wouldn’t go rolling out into Prod just yet. The perf numbers I get are pretty much identical to rolling all of this by hand with ThreadPool.QueueWorkItem(…) and IAsyncResult etc.

Well done MS!

Enjoy and here’s my VS.NET Sample Solutions – I had great fun! Oh – this is also applicable to Silverlight + WP7 apps :)

Tuesday, April 26, 2011 11:33:52 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
.NET Developer | Async | Silverlight | TechTalk | Tips
Archive
<August 2014>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
Blogroll
 AppFabric CAT
AppFabric Windows Server Customer Advisory Team - New Blog.
[Feed] BizTalk 2006 - Windows SharePoint Services adapter
BizTalk 2006 Sharepoint adapter!!
 Breeze SharePoint 2010 Bootcamp
Breeze SharePoint 2010 Bootcamp
[Feed] BTS 2006 R2/EDI
[Feed] Chris Vidotto (MS BTS Legend)
Needs no intro....
 Mark Daunt
BTS/SPS/.NET GURU!!!
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 603
This Year: 7
This Month: 0
This Week: 0
Comments: 270
All Content © 2014, Breeze