Search Results

Search found 1185 results on 48 pages for 'pulling hair out'.

Page 3/48 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Pulling changes between two separate Mercurial repositories

    - by Rob
    I have two versions of a product and am using separate Hg repositories for each. I have made a change to one (v1.0) and I want to pull just that change into the v2.0 repository. How do I go about this? As far as I can tell, using hg pull -f -r xxxxx \\server\hg\v1.0 will pull in all changes up to the specified revision which isn't what I want. Is this possible or will I have to add the fix by hand?

    Read the article

  • Pulling a value from one jQuery function into another

    - by Travis
    I'm trying to take the hex value chosen from a jQuery colorpicker plugin, and store it as a cookie using the jQuery cookie plugin. I just don't know the appropriate way to tie the two together (new to js and jQuery). Here's my colorpicker function: $('#colorSelector').ColorPicker({ color: '#ffffff', onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; }, onHide: function (colpkr) { $(colpkr).fadeOut(500); return false; }, onChange: function (hsb, hex, rgb) { $('#colorSelector div, .preview-image, .cover ').css('backgroundColor', '#' + hex); $('body').css('backgroundColor', '#' + hex); $.cookie('bgColor', 'picker'); return false; } }); And here's my cookie function as is: var bgColor = $.cookie('bgColor'); if (bgColor == 'picker') { $('#colorSelector div, .preview-image, .cover ').css('backgroundColor', '#' + hex); }; I can set and store the cookie value as a standard css background-color, but can't figure out how to pull the "'backgroundColor', '#' + hex" value into the cookie function.

    Read the article

  • basic JSON pulling data help..

    - by Webby
    New to json data and struggling i guess the answer is real easy but been bugging me for the last hour.. Sample data { "data": { "userid": "17", "dates": { "timestame": "1275528578", }, "username": "harino54", } } Ok I can pull userid or username easy enough with echo "$t->userid" or echo "$t->username " but how do I pull data from the brackets within ? in this case timestame? cant seem to figure it out.. any ideas?

    Read the article

  • LINQ-to-SQL class doesn't implement INotifyPropertyChanging & INotifyPropertyChanged if pulling from

    - by Traples
    I modified my data source in my LINQ-to-SQL class (by the old delete and drag back in method), and was surprised to see the INotifyPropertyChanging & INotifyPropertyChanged interfaces no longer implemented in the generated classes (MyDb.designer.cs). The methods for the individual fields went from looking like this... [Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this.OnSizeChanging(value); this.SendPropertyChanging(); this._Size = value; this.SendPropertyChanged("Size"); this.OnSizeChanged(); } } } To looking like this... [Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this._Size = value; } } } Any ideas on why this happens and how it will affect my application?

    Read the article

  • git, how to I go back to origin master after pulling a branch

    - by fishtoprecords
    This has to be a FAQ, but I can't find it googling. Another person created a branch, commit'd to it, and pushed it to github using git push origin newbranch I successfully pulled it down using git pull origin newbranch Now, I want to go back to the origin master version. Nothing I do seems to cause the files in the origin master to replace those in the newbranch. git checkout master git checkout origin master git pull git pull origin HEAD etc git pull origin master returns: * branch master -> FETCH_HEAD Already up-to-date. This can't be hard, but I sure can't figure it out. 'git branch' returns * master and 'git branch -r' return origin/HEAD origin/experimental origin/master

    Read the article

  • error in pulling trace file -sdcard

    - by con_9
    hi ,Can anybody help me out with traceview! I created sdcard and mounted it on my emulator , after closing my app , when i try to pull to copy the files (using command:adb pull /sdcard/calc.trace /tmp)i get this error:"remote object /sdcard/calc.trace does not exist".I am listin gdown the commands in sequence. 1)f:mksdcard 1024 ./myimage 2)f:emulator -sdcard ./myimage -avd 1 3)(After running my app and exiting the app)adb pull /sdcard/calc.trace /tmp in my activity i have start/stop method tracing with fiename calc.trace. n ya i am running windows --"\" regards

    Read the article

  • DataReader or DataSet when pulling multiple recordsets in ASP.NET

    - by Gern Blandston
    I've got an ASP.NET page that has a bunch of controls that need to be populated (e.g. dropdown lists). I'd like to make a single trip to the db and bring back multiple recordsets instead of making a round-trip for each control. I could bring back multiple tables in a DataSet, or I could bring back a DataReader and use '.NextResult' to put each result set into a custom business class. Will I likely see a big enough performance advantage using the DataReader approach, or should I just use the DataSet approach? Any examples of how you usually handle this would be appreciated.

    Read the article

  • Php mail pulling form data from previous page

    - by Mark
    So I have a form being filled out on one php like so: <p> <label for="first_name">First Name: </label> <input type="text" size="30" name="first_name" id="first_name"/> </p> <p> <label for="last_name"> Last Name:</label> <input type="text" size="30" name="last_name" id="last_name"/> </p> <p> <label for="address_street">Street:</label> <input type="text" size="30" name="address_street" id="address_street"/> </p> <p> <label for="address_city">City:</label> <input type="text" size="30" name="address_city" id="address_city"/> </p> <p> <label for="address_state">State/Province:</label> <input type="text" size="30" name="address_state" id="address_state"/> </p> <p> <label for="email">Your e-mail: </label> <input type="text" size="30" name="email" id="email"/> </p> <p> <label for="phone">Your phone number: </label> <input type="text" size="30" name="phone" id="phone"/> </p> This is on one php page. From here, it goes to another php which part of it contains script to send a html email to recipient. Problem is, I cannot seem to get it to pull the variables even though I thought I declared them correctly and mixed them into the html correctly. <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $to = "[email protected], [email protected]"; $subject = "HTML email for ALPS"; $message .= ' <html> <body> <div style="display: inline-block; width: 28%; float: left;"> <img src="http://englishintheusa.com/images/alps-logo.jpg" alt="ALPS Language School" /> </div> <div style="display: inline-block; width: 68%; float: right;"> <p style="color: #4F81BD; font-size: 20px; text-decoration: underline;">Thanks You For Your Inquiry!</p> </div> <div style="padding-left: 20px; color: #666666; font-size: 16.8px; clear: both;"> <p>Dear $first_name $last_name ,</p> </br > <p>Thank you for the following inquiry:</p> </br > </br > </br > </br > <p>****Comment goes here****</p> </br > </br > <p>We will contact you within 2 business days. Our office is open Monday-Friday, 8:30 AM - 5:00 PM Pacific Standard Time.</p> </br > <p>Thank you for your interest!</p> </br > </br > <p>Best Regards,</p> </br > </br > <p>ALPS Language School</p> </br > </br > <p>430 Broadway East</p> <p>Seattle WA 98102</p> <p>Phone: 206.720.6363</p> <p>Fax: 206. 720.1806</p> <p>Email: [email protected]</p> </div> </body> </html>'; // Always set content-type when sending HTML email $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers mail($to,$subject,$message,$headers); ?> So you see where I am trying to get first_name and last_name. Well it doesn't come out correctly. Can someone help here?

    Read the article

  • Pulling name value pair from a structured adsense code block contained in a txt file

    - by Scott B
    I have a txt file which contains a google adsense code block and I'm trying to pull in the file via file_get_contents to extract the values of the google_ad_client and google_ad_slot variables. In the examples below, I want to return to my calling function: $google_ad_client = 'pub-1234567890987654'; $google_ad_slot = '1234567890' The file may contain one of either of these two formats and I wont know which the user has chosen: Newer Ad Unit Style <script type="text/javascript"><!-- google_ad_client = "pub-1234567890987654"; google_ad_slot = "1234567890"; google_ad_width = 336; google_ad_height = 280; //--> </script> <script type="text/javascript" src="path-to-google-script"></script> Classic Style <script type="text/javascript"><!-- google_ad_client = "pub-1234567890987654"; /* 336x280, created 8/6/09 */ google_ad_slot = "1234567890"; google_ad_width = 336; google_ad_height = 280; google_ad_format="336x280_as"; google_ad_type="text_image"; google_color_border="FFFFFF"; google_color_bg="FFFFFF"; google_color_link="2200CC"; google_color_url="000000"; google_color_text="777777"; //--> </script>

    Read the article

  • Help with regex pulling XML data from response body in PHP

    - by spdaly
    I am working on a project that pulls data from JMS queue using PHP and Zend Framework. The HTTP client response is below. All I need is the XML string. I came up with /(.*)<\/RequestDetails/gs which tests ok on http://gskinner.com/RegExr/ but the preg_match call is returning an empty matches array. I'm going to continue to hunt around for a pattern, but thought I would post here as well. Thanks to all who read, etc... Steve UPDATE: I can't get the code to paste correctly. Here's a link to a pastbin: http://pastebin.com/rQxzcfSg

    Read the article

  • The proper way to script periodically pulling a page from an https site

    - by DarthShader
    I want to create a command-line script for Cygwin/Bash that logs into a site, navigates to a specific page and compares it with the results of the last run. So far, I have it working with Lynx like so: ----snpipped, just setting variables---- echo "# Command logfile created by Lynx 2.8.5rel.5 (29 Oct 2005) ----snipped the recorded keystrokes------- key Right Arrow key p key Right Arrow key ^U" >> $tmp1 #p, right arrow initiate the page saving #"type" the filename inside the "where to save" dialog for i in $(seq 0 $((${#tmp2} - 1))) do echo "key ${tmp2:$i:1}" >> $tmp1 done #hit enter and quit echo "key ^J key y key q key y " >> $tmp1 lynx -accept_all_cookies -cmd_script=$tmp1 https://thewebpage.com/login diff $tmp2 $oldComp mv $tmp2 $oldComp It definitely does not feel "right": the cmd_script consists of relative user actions instead of specifying the exact link names and actions. So, if anything on the site ever changes, switches places, or a new link is added - I will have to re-create the actions. Also, I can't check for any errors so I can't abort the script if something goes wrong (login failed, etc) Another alternative I have been looking at is Mechanize with Ruby (as a note - I have 0 experience with Ruby). What would be the best way to improve or rewrite this?

    Read the article

  • Pulling $_GET data and creating multidimensional array using loop

    - by Chris J
    I'm creating a checkout for customers and the data about what's in their cart is being sent to a page (for just now) via $_GET. I want to extract that data and then populate a multidimensional array with it using a loop. Here's how I'm naming the data: $itemCount = $_GET['itemCount']; $i = 1; while ($i <= $itemCount) { ${'item_name_'.$i} = $_GET["item_name_{$i}"]; ${'item_quantity_'.$i} = $_GET["item_quantity_{$i}"]; ${'item_price_'.$i} = $_GET["item_price_{$i}"]; //echo "<br />Name: " .${'item_name_'.$i}. " - Quantity: " .${'item_quantity_'.$i}. " - Price: ".${'item_price_'.$i}; $i++; } From here I'd like to create a multidimensional array like such: Array ( [Item_1] => Array ( [item_name] => Shoe [item_quantity] => 2 [item_price] => 40.00 ) [Item_2] => Array ( [item_name] => Bag [item_quantity] => 1 [item_price] => 60.00 ) [Item_3] => Array ( [item_name] => Parrot [item_quantity] => 4 [item_price] => 90.00 ) . . . ) What I'd like to know is if there is a way I can create this array in the existing while loop? I'm aware of being able to add data to an array like $data = [] after delacring an empty array but the actual syntax eludes me. Maybe I'm completely off the right track and there is a better way of doing it? Thanks

    Read the article

  • C# generics with MVVM, pulling the T out of <T>

    - by bufferz
    My Model is a generic class that contains a (for example) Value property which can be int, float, string, bool, etc. So naturally this class is represented something like Model<T>. For the sake of collections Model<T> implements the interface IModel, although IModel is itself empty of any content. My ViewModel contains and instance of Model<T> and it is passed in through ViewModel's constructor. I still want to know what T is in ViewModel, so when I expose Model to the View I know the datatype of Model's buried Value property. The class for ViewModel ends up looking like the following: class ViewModel<T> { private Model<T> _model; public ViewModel(Model<T> model) { ....blah.... } public T ModelsValue {get; set; } } This works fine, but is limited. So now I need to expose a collection of IModels with varying Ts to my View, so I'm trying to set up an ObservableCollection of new ViewModel<T>s to a changing list of IModels. The problem is, I can't figure out how to get T from Model<T> from IModel to construct ViewModel<T>(Model<T>) at runtime. In the VS2010 debugger I can mouseover any IModel object and see its full Model<int> for example at runtime so I know the data is in there. Any ideas?

    Read the article

  • Pulling international street addresses / phone numbers from free-form text

    - by spitzanator
    Hey, folks. I'm looking for some regular expressions to help grab street addresses and phone numbers from free-form text (a la Gmail). Given some text: "John, I went to the store today, and it was awesome! Did you hear that they moved to 500 Green St.? ... Give me a call at +14252425424 when you get a chance." I'd like to be able to pull out: 500 Green St. (recognized as a street address) +14252425424 (recognized as a phone number) What makes this problem easier is that I don't care about parsing text that gets pulled out. That is, I don't care that Green is the name of the road or that 425 is the area code. I just want to grab strings that "look like" addresses or telephone numbers. Unfortunately, this needs to work internationally, as best as possible. Anyone have any leads? Thanks!

    Read the article

  • SSIS Migration - Pulling IDs from dest DB?

    - by TheSciz
    So I'm working on migrating some data to a new server. In the new server, each entry in the MAIN table is assigned a new GUID when the transfer takes place. A few other tables must be migrated, and their records must link to the GUID in the MAIN table. Example... WorksheetID --- GUID 1245677903 --- 1 AccidentID --- WorksheetID --- Guid 12121412 --- 1245677903 --- 1 The guid is used moreso for versioning purposes, but my question is this. In SSIS, is there any way to pull the Worksheet's GUID from the destination database and assign it directly to the entries in the 'Accident' table? Or do I have to just dump the data into the source DB and run some scripts to get everything nicely referenced? Any help would be greatly appreciated.

    Read the article

  • Pulling .live() functionality out of jQuery

    - by Daniel
    I am writing a Firefox Add-On that currently is depending on jQuery for the following things: Selectors Animations A special .live("focus") hail-mary event-catching maneuver that happens to work with jQuery 1.4.2 (but not 1.4.4) jQuery isn't well suited for functioning inside XUL, and it's a miracle we've gotten this far with it. We're trying to remove the jQuery requirements, the first two are easy (animations are simple, and we can use .querySelector() instead of jQuery), but the .live has proven impossible to do on our own. I've tried reading the source code, but I haven't been able to piece it apart. What is the jQuery .live function doing? There's clearly a lot more going on than document.addEventListener("focus"/"focusin",function_to_pick_apart_events). What else is going on here?

    Read the article

  • Simple iOS Get Request Not Pulling in Data

    - by user2793987
    I have a very simple get request that doesn't return data on my script. The script is fine when viewed in the web browser but the app does not pull in the data. Any other script works with this code in the app. I'm unsure of what to do because there shouldn't be a reason for this to not work. Please let me know if you need more information. Here's the script: https://shipstudent.com/complaint_desk/similarPosts.php?username=noah //retrieve saved username from user defaults (it's noah) NSUserDefaults *eUser = [NSUserDefaults standardUserDefaults]; savedUser = [eUser objectForKey:@"user"]; NSLog(@"%@",savedUser); in ViewDidLoad: NSString *categoryParam = [NSString stringWithFormat:@"https://shipstudent.com/complaint_desk/similarPosts.php?username=%@", savedUser]; NSURL *url = [NSURL URLWithString:categoryParam]; NSMutableURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:30.0]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (connection==nil) { NSLog(@"Invalid request"); } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { postData = [[NSMutableData alloc]init]; NSLog(@"Response received"); } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [postData appendData:data]; NSLog(@"Data received"); } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; similarPosts = [NSJSONSerialization JSONObjectWithData:postData options:kNilOptions error:nil]; [postsTbl reloadData]; for (id postObject in similarPosts) { NSLog(@"Relatable Post: %@",postObject); } }

    Read the article

  • Pulling Data out of an object in Javascript

    - by PerryCS
    I am having a problem retreiving data out of an object passed back from PHP. I've tried many different ways to access this data and none work. In Firebug I see the following... (it looks nicer in Firebug) - I tried to make this look as close to Firebug as possible results Object { data="{"formName":"form3","formData":"data goes here"}", phpLiveDebug="<...s: 198.91.215.227"} data "{"formName":"form3","formData":"data goes here"}" phpLiveDebug "<...s: 198.91.215.227" I can access phpLiveDebug no problem, but the data portion is an object. I have tried the following... success: function(results) { //$("#formName").val(results.data.formName); //$("#formName").val(results.data[0].formName); //$("#formName").val(results.data[0]); //$("#formName").val(results.data[1]); //$("#formName").val(results.data[0]["formName"]); var tmp = results.data[formName]; alert("!" + tmp + "!"); $("#formName").val(tmp); $("#jqueryPHPDebug").val(results.phpLiveDebug); } This line works in the example above... $("#jqueryPHPDebug").val(results.phpLiveDebug); but... I can't figure out how to get at the data inside the results.data portion... as you can see above, I have been trying different things and more not even listed there. I was really hoping this line would work :) var tmp = results.data[formName]; But it doesn't. So, after many days of reading, tinkering, my solution was to re-write it to return data similar to the phpLiveDebug but then I thought... it's gotta be something simple I'm overlooking... Thank you for your time. Please try and explain why my logic (my horrible attempts at trying to figure out the proper method) above is wrong if you can?

    Read the article

  • PHP I am pulling my hair out trying to find the best! [closed]

    - by darga33
    PULLING MY HAIR OUT I have heard of Martin Fowler's book PoEAA and the other book Head First OOA OOD but those are not in PHP. I DESPERATELY WANT TO READ THEM, but ONLY in PHP utilizing SOLID principles! Does anyone know of the absolute best, most recent PHP book that utilizes the SOLID principles and GRASP, and all the other best practices? I want to learn from the best possible source! Not beginner books! I already understand OOP. This seems like an almost impossible question to find the answer to and so I thought, hey, might as well post on stackexchange!! Surely someone out there must know!!!!!!!!!! Or if noone knows Maybe they know of an open source application that utilizes these principles that is relatively small that is not a framework. Something that I can go through every single class, and spend time understanding the insides and outs of how the program was developed. Thanks so much in advance! I really really really really appreciate it!

    Read the article

  • Pulling in changes from a forked repo without a request on GitHub?

    - by Alec
    I'm new to the social coding community and don't know how to proceed properly in this situation: I've created a GitHub Repository a couple weeks ago. Someone forked the project and has made some small changes that have been on my to-do. I'm thrilled someone forked my project and took the time to add to it. I'd like to pull the changes into my own code, but have a couple of concerns. 1) I don't know how to pull in the changes via git from a forked repo. My understanding is that there is an easy way to merge the changes via a pull request, but it appears as though the forker has to issue that request? 2) Is it acceptable to pull in changes without a pull request? This relates to the first one. I'd put the code aside for a couple of weeks and come back to find that what I was going to work on next was done by someone else, and don't want to just copy their code without giving them credit in some way. Shouldn't there be a to pull the changes in even if they don't explicitly ask you to? What's the etiquette here I may be over thinking this, but thanks for your input in advance. I'm pretty new to the hacker community, but I want to do what I can to contribute!

    Read the article

  • What are some methods for pulling information and interacting with flash games?

    - by Xploit
    In general, how should I approach interacting with a flash game pragmatically? The flash game is online and I would like to be able to pull information from the game, make computations, and send the appropriate keystrokes back to the flash game? I'm having difficult deciding how to begin. Any specific libraries or languages that you feel would be best for accomplishing this task? I would like it to be as fast as possible. Are there ways of doing this without taking screen shots and simulating keyboard presses?

    Read the article

  • How do I find out from which fonts windows is pulling substitute glyphs?

    - by Marcin
    When a given font does not provide a glyph for a unicode character, windows pulls glyphs from a font which does provide it (see screenshot showing charmap and text editor displaying glyphs missing from calluna; the missing glyphs are (not) shown in the pdf visible in the same document. Fontforge also reveals that the glyphs are indeed not in that font). How can I work out from which font windows is pulling the substitute glyph? (I'm using windows 7)

    Read the article

  • how to reduce time of git pulling each time when you do a make world on Xen source

    - by Registered User
    I am compiling xen from source and each time I do a make world it basically gives some or the other error my problem are not those errors ( I am trying to debug them) but the problem is each time when I do a make world Xen basically pulls things from git repository + rm -rf linux-2.6-pvops.git linux-2.6-pvops.git.tmp + mkdir linux-2.6-pvops.git.tmp + rmdir linux-2.6-pvops.git.tmp + git clone -o xen -n git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-pvops.git.tmp Initialized empty Git repository in /usr/src/xen-4.0.1/linux-2.6-pvops.git.tmp/.git/ remote: Counting objects: 1941611, done. remote: Compressing objects: 100% (319127/319127), done. remote: Total 1941611 (delta 1614302), reused 1930655 (delta 1604595) **Receiving objects: 20% (1941611/1941611), 98.17 MiB | 87 KiB/s, done.** and if you notice the last line it is still consuming my bandwidth pulling things from internet.How can I stop this step each time and use existing git repository?

    Read the article

  • Why does Jcreator show iIlegal start of expression?

    - by Inusual Whisper Sinclair
    I am new at programming and currently in our classes we are learning java. I am trying to create a routine in which I need to use String variables only. Below it is the code in which I am working with: public static void main(String[] args) throws java.io.IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System. in )); PrintStream out = System.out; String hair.equals("damagedHair"); cutHair(marvin); cleanHair(michelle); for (int i = 0; i < 2; i++) { static void cutHair(String marvin) { String cabello; marvin.equals(hair); if (marvin.equals("damagedHair")) { cabello.equals("newHaircut"); result(hair); } static void cleanHair(String michelle) { String hair; michelle.equals(hair); if (michelle.equals(newHaircut)) { hair.equals("putShampooAndConditioner"); result(hair); } static void result(String pHair) {; PrintStream out = System.out; out.println("============="); out.println(pHair); out.println("============="); } } Jcreator is giving me an error that says Illegal start of expression and also java 50 error ';' expected. I am not sure why is this coming up and I am a little confused as to whether I am doing something I am not supposed to and how to correct it. Sorry about the double posting, this is the right message. Need some help from you guys to figure this out. Thanks in advanced!

    Read the article

  • Scaling-out Your Services by Message Bus based WCF Transport Extension &ndash; Part 1 &ndash; Background

    - by Shaun
    Cloud computing gives us more flexibility on the computing resource, we can provision and deploy an application or service with multiple instances over multiple machines. With the increment of the service instances, how to balance the incoming message and workload would become a new challenge. Currently there are two approaches we can use to pass the incoming messages to the service instances, I would like call them dispatcher mode and pulling mode.   Dispatcher Mode The dispatcher mode introduces a role which takes the responsible to find the best service instance to process the request. The image below describes the sharp of this mode. There are four clients communicate with the service through the underlying transportation. For example, if we are using HTTP the clients might be connecting to the same service URL. On the server side there’s a dispatcher listening on this URL and try to retrieve all messages. When a message came in, the dispatcher will find a proper service instance to process it. There are three mechanism to find the instance: Round-robin: Dispatcher will always send the message to the next instance. For example, if the dispatcher sent the message to instance 2, then the next message will be sent to instance 3, regardless if instance 3 is busy or not at that moment. Random: Dispatcher will find a service instance randomly, and same as the round-robin mode it regardless if the instance is busy or not. Sticky: Dispatcher will send all related messages to the same service instance. This approach always being used if the service methods are state-ful or session-ful. But as you can see, all of these approaches are not really load balanced. The clients will send messages at any time, and each message might take different process duration on the server side. This means in some cases, some of the service instances are very busy while others are almost idle. For example, if we were using round-robin mode, it could be happened that most of the simple task messages were passed to instance 1 while the complex ones were sent to instance 3, even though instance 1 should be idle. This brings some problem in our architecture. The first one is that, the response to the clients might be longer than it should be. As it’s shown in the figure above, message 6 and 9 can be processed by instance 1 or instance 2, but in reality they were dispatched to the busy instance 3 since the dispatcher and round-robin mode. Secondly, if there are many requests came from the clients in a very short period, service instances might be filled by tons of pending tasks and some instances might be crashed. Third, if we are using some cloud platform to host our service instances, for example the Windows Azure, the computing resource is billed by service deployment period instead of the actual CPU usage. This means if any service instance is idle it is wasting our money! Last one, the dispatcher would be the bottleneck of our system since all incoming messages must be routed by the dispatcher. If we are using HTTP or TCP as the transport, the dispatcher would be a network load balance. If we wants more capacity, we have to scale-up, or buy a hardware load balance which is very expensive, as well as scaling-out the service instances. Pulling Mode Pulling mode doesn’t need a dispatcher to route the messages. All service instances are listening to the same transport and try to retrieve the next proper message to process if they are idle. Since there is no dispatcher in pulling mode, it requires some features on the transportation. The transportation must support multiple client connection and server listening. HTTP and TCP doesn’t allow multiple clients are listening on the same address and port, so it cannot be used in pulling mode directly. All messages in the transportation must be FIFO, which means the old message must be received before the new one. Message selection would be a plus on the transportation. This means both service and client can specify some selection criteria and just receive some specified kinds of messages. This feature is not mandatory but would be very useful when implementing the request reply and duplex WCF channel modes. Otherwise we must have a memory dictionary to store the reply messages. I will explain more about this in the following articles. Message bus, or the message queue would be best candidate as the transportation when using the pulling mode. First, it allows multiple application to listen on the same queue, and it’s FIFO. Some of the message bus also support the message selection, such as TIBCO EMS, RabbitMQ. Some others provide in memory dictionary which can store the reply messages, for example the Redis. The principle of pulling mode is to let the service instances self-managed. This means each instance will try to retrieve the next pending incoming message if they finished the current task. This gives us more benefit and can solve the problems we met with in the dispatcher mode. The incoming message will be received to the best instance to process, which means this will be very balanced. And it will not happen that some instances are busy while other are idle, since the idle one will retrieve more tasks to make them busy. Since all instances are try their best to be busy we can use less instances than dispatcher mode, which more cost effective. Since there’s no dispatcher in the system, there is no bottleneck. When we introduced more service instances, in dispatcher mode we have to change something to let the dispatcher know the new instances. But in pulling mode since all service instance are self-managed, there no extra change at all. If there are many incoming messages, since the message bus can queue them in the transportation, service instances would not be crashed. All above are the benefits using the pulling mode, but it will introduce some problem as well. The process tracking and debugging become more difficult. Since the service instances are self-managed, we cannot know which instance will process the message. So we need more information to support debug and track. Real-time response may not be supported. All service instances will process the next message after the current one has done, if we have some real-time request this may not be a good solution. Compare with the Pros and Cons above, the pulling mode would a better solution for the distributed system architecture. Because what we need more is the scalability, cost-effect and the self-management.   WCF and WCF Transport Extensibility Windows Communication Foundation (WCF) is a framework for building service-oriented applications. In the .NET world WCF is the best way to implement the service. In this series I’m going to demonstrate how to implement the pulling mode on top of a message bus by extending the WCF. I don’t want to deep into every related field in WCF but will highlight its transport extensibility. When we implemented an RPC foundation there are many aspects we need to deal with, for example the message encoding, encryption, authentication and message sending and receiving. In WCF, each aspect is represented by a channel. A message will be passed through all necessary channels and finally send to the underlying transportation. And on the other side the message will be received from the transport and though the same channels until the business logic. This mode is called “Channel Stack” in WCF, and the last channel in the channel stack must always be a transport channel, which takes the responsible for sending and receiving the messages. As we are going to implement the WCF over message bus and implement the pulling mode scaling-out solution, we need to create our own transport channel so that the client and service can exchange messages over our bus. Before we deep into the transport channel, let’s have a look on the message exchange patterns that WCF defines. Message exchange pattern (MEP) defines how client and service exchange the messages over the transportation. WCF defines 3 basic MEPs which are datagram, Request-Reply and Duplex. Datagram: Also known as one-way, or fire-forgot mode. The message sent from the client to the service, and no need any reply from the service. The client doesn’t care about the message result at all. Request-Reply: Very common used pattern. The client send the request message to the service and wait until the reply message comes from the service. Duplex: The client sent message to the service, when the service processing the message it can callback to the client. When callback the service would be like a client while the client would be like a service. In WCF, each MEP represent some channels associated. MEP Channels Datagram IInputChannel, IOutputChannel Request-Reply IRequestChannel, IReplyChannel Duplex IDuplexChannel And the channels are created by ChannelListener on the server side, and ChannelFactory on the client side. The ChannelListener and ChannelFactory are created by the TransportBindingElement. The TransportBindingElement is created by the Binding, which can be defined as a new binding or from a custom binding. For more information about the transport channel mode, please refer to the MSDN document. The figure below shows the transport channel objects when using the request-reply MEP. And this is the datagram MEP. And this is the duplex MEP. After investigated the WCF transport architecture, channel mode and MEP, we finally identified what we should do to extend our message bus based transport layer. They are: Binding: (Optional) Defines the channel elements in the channel stack and added our transport binding element at the bottom of the stack. But we can use the build-in CustomBinding as well. TransportBindingElement: Defines which MEP is supported in our transport and create the related ChannelListener and ChannelFactory. This also defines the scheme of the endpoint if using this transport. ChannelListener: Create the server side channel based on the MEP it’s. We can have one ChannelListener to create channels for all supported MEPs, or we can have ChannelListener for each MEP. In this series I will use the second approach. ChannelFactory: Create the client side channel based on the MEP it’s. We can have one ChannelFactory to create channels for all supported MEPs, or we can have ChannelFactory for each MEP. In this series I will use the second approach. Channels: Based on the MEPs we want to support, we need to implement the channels accordingly. For example, if we want our transport support Request-Reply mode we should implement IRequestChannel and IReplyChannel. In this series I will implement all 3 MEPs listed above one by one. Scaffold: In order to make our transport extension works we also need to implement some scaffold stuff. For example we need some classes to send and receive message though out message bus. We also need some codes to read and write the WCF message, etc.. These are not necessary but would be very useful in our example.   Message Bus There is only one thing remained before we can begin to implement our scaling-out support WCF transport, which is the message bus. As I mentioned above, the message bus must have some features to fulfill all the WCF MEPs. In my company we will be using TIBCO EMS, which is an enterprise message bus product. And I have said before we can use any message bus production if it’s satisfied with our requests. Here I would like to introduce an interface to separate the message bus from the WCF. This allows us to implement the bus operations by any kinds bus we are going to use. The interface would be like this. 1: public interface IBus : IDisposable 2: { 3: string SendRequest(string message, bool fromClient, string from, string to = null); 4:  5: void SendReply(string message, bool fromClient, string replyTo); 6:  7: BusMessage Receive(bool fromClient, string replyTo); 8: } There are only three methods for the bus interface. Let me explain one by one. The SendRequest method takes the responsible for sending the request message into the bus. The parameters description are: message: The WCF message content. fromClient: Indicates if this message was came from the client. from: The channel ID that this message was sent from. The channel ID will be generated when any kinds of channel was created, which will be explained in the following articles. to: The channel ID that this message should be received. In Request-Reply and Duplex MEP this is necessary since the reply message must be received by the channel which sent the related request message. The SendReply method takes the responsible for sending the reply message. It’s very similar as the previous one but no “from” parameter. This is because it’s no need to reply a reply message again in any MEPs. The Receive method takes the responsible for waiting for a incoming message, includes the request message and specified reply message. It returned a BusMessage object, which contains some information about the channel information. The code of the BusMessage class is 1: public class BusMessage 2: { 3: public string MessageID { get; private set; } 4: public string From { get; private set; } 5: public string ReplyTo { get; private set; } 6: public string Content { get; private set; } 7:  8: public BusMessage(string messageId, string fromChannelId, string replyToChannelId, string content) 9: { 10: MessageID = messageId; 11: From = fromChannelId; 12: ReplyTo = replyToChannelId; 13: Content = content; 14: } 15: } Now let’s implement a message bus based on the IBus interface. Since I don’t want you to buy and install the TIBCO EMS or any other message bus products, I will implement an in process memory bus. This bus is only for test and sample purpose. It can only be used if the service and client are in the same process. Very straightforward. 1: public class InProcMessageBus : IBus 2: { 3: private readonly ConcurrentDictionary<Guid, InProcMessageEntity> _queue; 4: private readonly object _lock; 5:  6: public InProcMessageBus() 7: { 8: _queue = new ConcurrentDictionary<Guid, InProcMessageEntity>(); 9: _lock = new object(); 10: } 11:  12: public string SendRequest(string message, bool fromClient, string from, string to = null) 13: { 14: var entity = new InProcMessageEntity(message, fromClient, from, to); 15: _queue.TryAdd(entity.ID, entity); 16: return entity.ID.ToString(); 17: } 18:  19: public void SendReply(string message, bool fromClient, string replyTo) 20: { 21: var entity = new InProcMessageEntity(message, fromClient, null, replyTo); 22: _queue.TryAdd(entity.ID, entity); 23: } 24:  25: public BusMessage Receive(bool fromClient, string replyTo) 26: { 27: InProcMessageEntity e = null; 28: while (true) 29: { 30: lock (_lock) 31: { 32: var entity = _queue 33: .Where(kvp => kvp.Value.FromClient == fromClient && (kvp.Value.To == replyTo || string.IsNullOrWhiteSpace(kvp.Value.To))) 34: .FirstOrDefault(); 35: if (entity.Key != Guid.Empty && entity.Value != null) 36: { 37: _queue.TryRemove(entity.Key, out e); 38: } 39: } 40: if (e == null) 41: { 42: Thread.Sleep(100); 43: } 44: else 45: { 46: return new BusMessage(e.ID.ToString(), e.From, e.To, e.Content); 47: } 48: } 49: } 50:  51: public void Dispose() 52: { 53: } 54: } The InProcMessageBus stores the messages in the objects of InProcMessageEntity, which can take some extra information beside the WCF message itself. 1: public class InProcMessageEntity 2: { 3: public Guid ID { get; set; } 4: public string Content { get; set; } 5: public bool FromClient { get; set; } 6: public string From { get; set; } 7: public string To { get; set; } 8:  9: public InProcMessageEntity() 10: : this(string.Empty, false, string.Empty, string.Empty) 11: { 12: } 13:  14: public InProcMessageEntity(string content, bool fromClient, string from, string to) 15: { 16: ID = Guid.NewGuid(); 17: Content = content; 18: FromClient = fromClient; 19: From = from; 20: To = to; 21: } 22: }   Summary OK, now I have all necessary stuff ready. The next step would be implementing our WCF message bus transport extension. In this post I described two scaling-out approaches on the service side especially if we are using the cloud platform: dispatcher mode and pulling mode. And I compared the Pros and Cons of them. Then I introduced the WCF channel stack, channel mode and the transport extension part, and identified what we should do to create our own WCF transport extension, to let our WCF services using pulling mode based on a message bus. And finally I provided some classes that need to be used in the future posts that working against an in process memory message bus, for the demonstration purpose only. In the next post I will begin to implement the transport extension step by step.   Hope this helps, Shaun All documents and related graphics, codes are provided "AS IS" without warranty of any kind. Copyright © Shaun Ziyan Xu. This work is licensed under the Creative Commons License.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >