Geeks With Blogs

News View Michael Stephenson's profile on BizTalk Blog Doc View Michael Stephenson's profile on LinkedIn
Michael Stephenson keeping your feet on premise while your heads in the cloud

In this article we will revisit the first sample about one way messaging and look at how the AppFx.ServiceBus framework implements error handling and retries. In this article we want to achieve the following:

  • We will take the code from sample 1
  • We will modify the message handler to throw errors.
  • We will see that the message will be retried
  • We will see that eventually the message will be processed successfully

 

Getting the Sample

The sample is available in the source code section on codeplex:

http://appfxservicebus.codeplex.com/releases

In the source code and samples download you will see a samples folder and you want the folder called Sample4-OneWayErrorHandling.

Im not going to go into the full details of the sample like we did in previous samples so I will assume you are familiar with sample 1 on the following link:

http://geekswithblogs.net/michaelstephenson/archive/2013/02/03/152012.aspx

In the rest of the article we will talk about how that sample has been modified.

Azure Setup

The setup of queues and topics to support this sample is exactly the same as for sample 1 and in fact it uses the same queues.

 

Modifying the message handler

In the message handler we are going to extend the logic. We will use the some context information from the MessageProcessorContext class. In that class there is an instance for each processed message which gives the message handler developer access to the Azure Service Bus Message and other things in an encapsulated way. From that class in our message handler we are interested in the MessageProcessorContext.Current.DeliveryCount property. This property tells us how many times the message has been attempted to be received from the Service Bus queue or subscription. In the error handler we will look to throw an error if the delivery count is less than three. The framework will reject this message and Azure Service Bus will make it available for collection again. The framework will then again try to process the message. In our logic the message handler will allow the message to be successfully processed once the delivery count is 3 or greater.

See below for an example of the message handler.

 

Running the sample

Rather than talking through the whole running of the sample, if you remember back to sample 1 you need to do the following:

  1. Compile the visual studio solution
  2. Start the AppFx.ServiceBus.Hosts.Console.exe application in the library folder
  3. Start the windows test application
  4. Click the button

 

When the button is clicked within a second or so your message will be received by the console application and you will see that in the red text indicates that the message was received and an error occurred. The message was rejected. This happens twice and then on the third attempt the message is processed successfully.

 

 

 

Other Considerations

Below are some other considerations you may want to think about when handling and throwing errors.

Azure Max Delivery Attempts

One thing to consider is that in the configuration or your Azure queue or subscription you can set a value for the maximum attempts for redelivery. This setting still comes into play when using the AppFx.ServiceBus framework. If the framework rejects a message 4 times and the Azure Queue max deliveries is set to 4 then Azure Service Bus will send the message to the Dead Letter queue.

AppFx Exception

In the framework there is an exception called AppFx.ServiceBus.Exceptions.ApplicationException. This exception allows you to throw an error in your message handler and to have the framework use the properties on the exception to allow you to control if a retry is attempted or not.

If an exception is thrown which is not the above type of exception then the framework will implement the behavior to keep log the error and keep retrying the message until the Azure Service Bus max delivery attempts kicks in and dead letters the message.

 

Summary

This sample should show you how the AppFx.ServiceBus framework deals with the retry and error handling scenarios you are most likely to need. This is one of the key areas we feel that AppFx.ServiceBus really makes life simpler for you.

Posted on Tuesday, February 5, 2013 11:57 AM | Back to top


Comments on this post: AppFx.ServiceBus – One Way Error Handling

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
awsome Simply shoot an image and also have a celebration. YouCam Perfect Download Effects alter the colour tone of the image several times, youcam perfect nice.
Left by deep on Mar 01, 2016 10:23 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
This cool application about viva video making vivavideodownload.com is freely available
Left by Joney on Mar 09, 2016 6:29 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
sufficient explanation on how to control errors from servers. to share files from on mobile phone to another mobile phone download these File Transfer apps.
Left by miami on Jun 10, 2016 1:14 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definately interested in this one. Just thought that I would post and let you know.
list of emoticons
Left by 123 on Jul 03, 2016 1:45 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
WhatsApp messenger on PC download available at http://brownstacks.com
Left by brownstacks on Jul 19, 2016 10:04 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
You can download download vidmate here
Left by appsfreeforpc on Jul 19, 2016 10:05 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
vacuum cleaner are so useful for home improvment cleanwellexpert.com
Left by cleanwellexpert on Jul 20, 2016 7:37 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
WhatsApp for PC Downloading is possible from here technotup.com
Left by technotup on Jul 20, 2016 7:51 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
I think Service Bus handles only one way communication of error handling and explained it very well. air shou download for iphone to record your screen of your iOS device in awesome way. I tested my screen at high 1080P resolution.
Left by vanikar on Aug 15, 2016 6:31 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
As you guys are very familiarized with the Android OS, you may be knowing the installation process of any app for pc Android app.
When I say this, the first thing that comes to your mind is
Left by Aryan Arya on Aug 22, 2016 7:35 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
That's really cool. I would be interested in seeing more graphs of different information you pull from these logs.

zngamehack
Left by dw on Sep 09, 2016 10:33 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Download Hackz4iOS for iOS 10 to download jailbreak apps and paid apps for free without jailbreak
Left by Jack on Sep 22, 2016 3:50 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Download Terrarium TV Apk to watch all latest TV Shows.
Left by Terrarium on Oct 05, 2016 6:00 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
to stream movie online download showbox apk for free
Left by daniels danny on Nov 05, 2016 9:32 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Free movie stuff app download now from here.
Left by polc on Dec 06, 2016 7:30 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
very informative. check this article for more.
Left by Miller on Dec 07, 2016 4:24 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Download Strange Hero Future Battle an action packed game in which you play as your favorite super hero - Spider man.
Left by Shreya Pandey on Jan 26, 2017 7:52 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Hi thanks keep it up always.. pdf to word converter
Left by janifermagi72 jana on Jan 27, 2017 1:25 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is entirely off topic
Fallout 4 Torrent
Left by vacey roy on Jan 27, 2017 1:28 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
thanx for sharing an informative post!!! i am
lucky
to land up here!
Left by aily cyrus on Jan 30, 2017 8:05 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Thanks a lot for sharing this with us. I have bookmarked your blog. Keep on sharing stuff with us forever.
Anghami plus apk
Left by Chris Brog on Feb 06, 2017 4:53 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
great one mate, also checkout Toysrus creditcard login
Left by James on Feb 07, 2017 10:41 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Left by James on Feb 07, 2017 10:46 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Thanks for such post.For Best WhatsApp Status just visit Best WhatsApp Satus
Left by Best WhatsApp Status on Feb 08, 2017 8:24 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
THANKS FOR YOUR TIME AND PROVIDING US SUCH USEFUL INFORMATION.KEEP IT UP.
Left by Tips and Tricks of Lucky Patcher on Feb 24, 2017 9:40 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Looks cool .I was unknown about these things.thanks for sharing with us.
Free Lucky Patcher Apk Download

Left by Free Lucky Patcher Apk on Feb 24, 2017 10:31 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
great one mate, recently i came across Spotify premium cracked apk and i must say its really amazing and everyone should have it
Left by bob on Apr 05, 2017 11:06 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
great one mate, i recently came across drastic ds emulator for android and i must say its an amazing emulator
Left by bob on Apr 05, 2017 11:08 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Good post on error handling!! Keep up the good work!

Download iApps4you iOS App Free Jailbreak tweaks.
Left by Pratikar on Apr 10, 2017 6:53 PM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
this setting still comes into play when using the jio4gvoice app for android
AppFx.ServiceBus framework. If the framework rejects a message 4 times and the Azure dream league soccer kits Queue max deliveries is set to 4 then Azure Service Bus will send the message to the Dead Letter queue.
Left by sfr on May 01, 2017 6:54 AM

# re: AppFx.ServiceBus – One Way Error Handling
Requesting Gravatar...
Hi man thanks keep it up always. am really impressed by your great wording. malwarebytes key
Left by hashim amla on May 07, 2017 10:39 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Stephenson | Powered by: GeeksWithBlogs.net