Google Search

Google
 

Monday, February 25, 2008

Durable Services with WCF V3.5

URL
XMLFILE

db456a07-6809-4a60-884e-361c7c49da99 0.01 Oh and welcome to the short video on Windows syndication foundation in net framework version 3 5 and a feature called durable services Finance and 10.01 I told him I work in the developer and platform group in Microsoft in the UK and I ve ever signify that this version of 20.01 the net framework which will ship with visual studio 2008 and the idea of durable services in winner s communication foundation here is that you 30.01 can allow the framework overview in managing a conversation between client and a service which may last a long time to the idea here is 40.01 that the client begins a conversation with the service and service may well build a state on the half that clients conversation and the phone 50.01 automatically persists that 40 the framework also automatically send a token down to the clan which identifies asset of state lack of the service and 60.01 To conversation with services later by the framework again automatically pulls out that token from a message golden indexes to find the state rehydrates the state and 70.01 get your service go back and running with the state that it had the last time he was speaking to that particular line to associate the automatic 80.01 state management and passing backwards and forwards compensation tokens automatically am to the client and the service can have a conversation this is done in pluggable manners 90.01 of estate management the persistence of their is something that pluggable is we can help in different providers naturally as you d expect we have a sequel 100.01 server based provider for implementation of cases we are in visual studio 2082 and have already built some of the bits and pieces here and specifically I 110.00999999999999 have a website containing prebuilt web service I have a client about that service and has has been the theme in a number of these winners communication foundation videos 120.01 The website and the World Service about displaying album art from a collection are stored under this contract so it is a look at the service 130.01 of the giving of you is a browsing service so it actually idea is that you just want to browse the art of the albums in 140.01 your CD collection to this WTF interface which is how you build anything to be said he will start with interfaces so we conceivably got his 150.01 eye row was interface without a vision of course so that is the reason of service contract and I got stoned and members on here which 160.01 really set their conversation in place so the idea is that initially the client will call get me the first album art and will return a 170.01 data structure to them if we had got over that data structures very simple you get an album name and the URL which point you to the 180.01 Artwork that particular album so we got back to this interface with to get first album and then we ve got to get next album and a 190.01 valuable unethical than they do notice that we ve also attributes of the synthesis and you have to be to comment on the final version 3 5 200.01 so this member here with attribute of this durable operation after being and whether we can or can t create an instance of the service in order 210.01 to handle this particular operation there because of course this is supposed to start the conversation then we want to create his service in that case will 220.01 look at Ireland forget the next album against durable operation but this time the same well the very idea of next means that when I was creating 230.01 a new instances of coming into existing conversation I finally got this kind of dummy method vehicle done and all that are saying is this 240.01 Already finished with the conversation between these three are methods on this interface with finding a conversation starts here continues here and complete here and you can 250.01 call it as many times as you won in the way that the service will work as when it falls off the end of the available it 260.01 wouldn t go back to the beginning of a self conscious hour that artwork again a look at the service implementation here it is a look of 270.01 implementation essentially about this classical browse that implements interface you ll notice that the glass itself has been attribute it to say this is durable service and 280.01 essentially the only important thing about this implementation the only reason to showing it to you if it maintains two pieces of state it maintains which artists 290.01 were up to assist the integer and it retains which album within artists collection currently looking at on a per client basis and is just two entities that are 300.01 To end and the beauty of durable services is that I don t have to write any code whatsoever to get the thing serialise for me the net framework is 310.01 just going to do that for me so have to do is put them onto my implementation class and the framework will magically serialise these things for me and essential 320.01 advantages under serialise and after every operation complete so every time they have an operation on this thing was in Appin and in my case he is doubtless greater incidence 330.01 of my service class because that s licensing model were going to feed it any persistent state that it has to the client is making the particular quarrel with an 340.01 answer that call with serialise state and never delivered an object again naturally have is working severely one thing really about his son this class is that in order to 350.01 do its job it maintains needs to values and in order to do that it does not write any code to make that happen all we ve done is said that this 360.01 Is a durable service now close with an interface and implementation were hosting inside of IIS over 72 configurations in order to 370.01 make the BCF work so that they could configurations must pop into a web config as collateral this down as some expand 380.01 some of our justice system or service model portion is what we won to get in here I ve got a service 390.01 is that Societa showed you it s listening after particular endpoint is using a new binding in net frame of version 3 400.01 5WS HTTP content binding essentially this means an author of services stuff so the security model and thing but it also brings 410.01 in context and context essentially is the way in which the client is sent an identifier token of July 420.01 It took only find the whole state of the client even though we soon realised it was me some tokens go to get back to that state of 430.01 point in the future and it s these contextual bindings that is not the only one around as a TCP version as well it is contextual bindings and 440.01 know how to transmit that to open up and down the belief that communications stack there were considering that in our case were not reconfiguring a very in 450.01 a very fancy way of network and servers and consideration here you can see there is real advertising meta database and debugging but the most important piece here 460.01 is that we are using a persistence provider and is this thing is going to make the serialisation work for us so in our case were using a 470.01 built in and persistence provider it s these sequel server persistence provider is a connection strings only pointed to the connection string which is also defined in the configuration file further 480.01 As you can see some semantics around how long should it be able to lock a piece of skaters and so on within within the database now if you don 490.01 t want to use sequel server here you can go ahead and implement their own persistence provide a mental into the framework so we have one that we ship or 500.01 even on plug in if you want a different support so the only other piece of configurations of this service might browse our service beyond its persistent provider is that 510.01 if you can figure down here considering that of US 63 context binding and all I ve done their research of security because of this particular scenario are not interested 520.01 in security so with all that implies a better service is advertising that the data I used that methylated to help rebuild a point against service so if you are 530.01 over to this client have added a service reference to that thing and is using the dialogue reinvestigation of the latter service reference to let go ahead and 540.01 But a few windows and will run the client pressure on the skin that up case of the claim comes up and it starts going through the albums and the 550.01 pictures I actually put into the store offers particular example on with the next way through these this guy through the middle order as said in a previous video these 560.01 are not all of Bob Dylan s albums because I only cut in the first 10 or so and put off a lot of downloading to go to every album 570.01 here from these and what your spot is the only acid in the popular move on to Bruce Springsteen and his albums are coming in order fan if we stop 580.01 at this point here I happen to know the next album should be done while the innocent in this reshuffle and if we were to shut this kind down now 590.01 you see that says he wants a state s then the kind that has persisted that token that the service sector and if we go back and run up the client again 600.01 What was feared the client will call and ask for the next piece of album from the position where it was at the last time Iran are exactly remembering where 610.01 it was in that sequence engine to the client s comeback and hasn t started at the beginning of the sequence is medical to get the next piece of art 620.01 and it so happens as you say after great is rationed by New Jersey and an exclusive album is the wild innocent in his reshuffle and a protein of electrons 630.01 want to run and not the point of this is not as that Springsteen is an album history the point is that the client remembered where it is up to 640.01 a quarter service and asked for the next and the entry and the service rehydrated state and based on what the client centres and sent back the right piece of 650.01 data so it s a look at the Clydesdale associates and will direct them not to say states are now on what s going on on the client services outlook of 660.01 Code of into the coded so when this form and first runs up a coldest method load first picture and the first thing that method does is create an instant 670.01 half the proxy to the service of this is just the proxy class I got from adding a service reference and we keep this around the duration of my service 680.01 missing he was out in the variable of this class envisages situations at men s application of the either you are halfway through a conversation he want to continue on 690.01 your not and if you are halfway through the conversation you will have a complex token for a conversation persisted on the disc because that s what they performed a 700.01 primary close we do is use a little help the class to see if we ve got a complex token on the disc on if we don t have one 710.01 then we could call get first album because we starting a conversation if we have one of these things and what we do is use a little bit of WC 720.01 Magic to reach into the proxy and anything called a complex manager and use that to set the context on the proxy giving the coconut loaf and the disc 730.01 so this is essentially way of setting up the right token such that we can continue the conversation that we were having previously anatomical get next album battle to 740.01 send the converts to service the services and dehydrate the states that context opens in the past that the right result and only put the things on screen and 750.01 when they can buy from the service naturally when you call get next picture the next button on screen we could call the next method on the proxy and 760.01 put the bits onto the screen is that simple enough and then finally an in the form is closing as you so amazing with a message box and you 770.01 want to save if you say no will use a helper method to delete any previously stated and stored conversation to and from the disc just incase we are 780.01 That lying around in Scottsdale now where is if you say that you do want to save the current state of the conversation and once again we reach 790.01 in using the WC of magic to get the complex manager from the proxy we are older that thing and we ask if the current contact the complex 800.01 token that identifies a conversation were having that service and again like a side issue is a persistence method on a helper class to still add to this 810.01 sort of issue that matters to them don t appear to be magical complicated essentially all that is happening is this method he load context all it s 820.01 doing in its using some standard serialisation drew to deserialise one of the sanctions from the disc so fundamentally a complex token is a bunch of names and 830.01 strings into dictionary of names and strings and so does nothing complex about its just a property bag and you were doing a scene for a 840.01 On our disc if we have will bring it back of course than assist context takes the property bag and persists it and it 850.01 in the context simply make sure that we delete the file that will use so is nothing magical and and there is just put 860.01 into a separate class to move it out of the main code and has a budget so essentially client is beginning the conversation all 870.01 continuing a conversation depending on whether Scott persisted token on the disc on and is once again a system response to backline of a 880.01 so were you not advantage the first time it has no persisted state so it was a service asking from the first picture on 890.01 the goal press next goes on cause of the next picture and bear in mind that context open will be propagated service with 900.01 Dehydrate the state and would do the right thing based on the states of this particular client and then if it were to shut down the application it talks 910.01 to the proxy if we quit yet a little talk to the rocks it ll grab that context open us over the desk and then the next time we 920.01 run up we will be starting from the beginning any more because the application will load the context of the disc inserted into the proxy the proxy was in 930.01 the service service will continue the previous conversation that we were having with it and the carrier to jump into the middle of an interaction and carry out work 940.01 were before so this is just a really nice easy way that we could estate management on the service I have without having to write a bunch of code 950.01 sales persistence framework is already there is important to say that time on the service either using net civilisation in a civilised son those member states have 960.01 Back to a service just the second you remember that service had these two things will eventually were using binary civilisation to serialise us into the database and we 970.01 saw that you plug in a provider in the configuration file and of course you will monitor on Thursday a nice way of maintaining and a conversation and some 980.01 state on the server side to the client would am to write any of your own explicit code in order to make that happen just as the rise will 990.01 be seen here the DCF in net framework version to confide her support of his durable services the idea is that clients and servers have a conversation during the 1000.01 course of our conversation that the service may well build up some state and the framework can automatically persist that stay for the service here in order that obviously 1010.01 the service could be restarted and still get back on state in difference is that we can have multiple instances of the service or running on a server farm and 1020.01 Of them can get back to the states of particular conversations are having a crime we say that the assistant is automatically after writing the code to make a 1030.01 persistent happen if the pluggable provider we have a signals recommendations of this and then the token that needs to flow from the service back to the client in 1040.01 the first instance and then between the client and the service to continue the conversation that token is automatically propagated for a figure have to do anything to get 1050.01 that open to flow as it happens that open is either propagated by and HTTP cookie or if you are working in a soap full world than it ll 1060.01 going to the soap had you get a control and that propagation is done depending on your transport of your message former and there are some bindings in the 1070.01 framework and didn t already know how to propagate this contest took about four is specifically noted of US HTTP content finding and figures also let it become 1080.01 And I think that already know how to move this context took about and forwards for you in order to make that to happen now if you want more information 1090.01 on this topic I recommend going into your MSDN documentation there is a topic and there called creating works and services and durable services and the sex part of the 1100.01 Windows workflow foundation documentation and the sugar documentation to find the information you want in their thing to say about that you might be thinking why is this a topic 1110.01 under creating workflow services and durable services wise and within the BCF and it s important to realise that one great way of being able to build services that work 1120.01 in a long running manner with some extra capabilities beyond what we can do just durable services is to use Windows workflow foundation to workflow foundation in net 2 5 1130.01 is a great way of building the BCF services that have long running capabilities and a whole bunch more capabilities so I recommend you look at whether is 1140.01 This is and will make a video around how you build services 1150.01 with workflow and at a later point if you question specifically on 1160.01 this video then feel free to mail me my notice adjuster on 1170.01 the screen and other that 80 from a sling up the phone 1180.01 session useful and hope to catch up with you either electronically via 1190.01 wobbly sessions in the future or perhaps it in person

No comments: