<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codemunchies &#187; spring batch</title>
	<atom:link href="http://codemunchies.com/tag/spring-batch/feed/" rel="self" type="application/rss+xml" />
	<link>http://codemunchies.com</link>
	<description>Satisfy your cravings</description>
	<lastBuildDate>Mon, 19 Sep 2011 19:32:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Repeatable code</title>
		<link>http://codemunchies.com/2009/09/repeatable-code/</link>
		<comments>http://codemunchies.com/2009/09/repeatable-code/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 18:32:49 +0000</pubDate>
		<dc:creator>Jaran Nilsen</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Prototyping]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jmock]]></category>
		<category><![CDATA[spring batch]]></category>

		<guid isPermaLink="false">http://codemunchies.jaranweb.com/?p=25</guid>
		<description><![CDATA[A request for a resource times out due to a temporary network issue. How do you handle this? ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodemunchies.com%2F2009%2F09%2Frepeatable-code%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodemunchies.com%2F2009%2F09%2Frepeatable-code%2F&amp;source=codemunchies&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">How often do you want to repeat a chunk of code? A request for a resource times out due to a temporary network issue. How do you handle this?</p>
<p style="text-align: justify;">Last week I was in the creative corner and after having checked out the <a href="http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/retry/support/RetryTemplate.html" target="_blank">RetryTemplate from Spring Batch</a> I  figured I wanted something more stylish and configurable &#8211; in the least possible number of lines.</p>
<p style="text-align: justify;">After adopting JMock into our unit testing toolbox, I&#8217;ve become increasingly fond of the syntax proposed by that framework (among others). So I decided a similar syntax for configuring my RetryManager would be fun to try implementing.</p>
<pre class="brush: java" style="text-align: justify;">RetryManager.instance().numberOfTimes(5).onExceptions(IOException.class).retry(new Retryable() {

    public void execute() {

        // Here goes your retryable code.
    }
});</pre>
<p style="text-align: justify;">As you see from the example above, the amount of space occupied by the configuration and execution code is not overwhelming at all.</p>
<p style="text-align: justify;">Currently the implementation is at a prototype stage, but in a few days time we hope to have implemented more configuration options such as delays and the option to specify fail/retry strategies instead of just a list of exceptions. We  also want to make the RetryManager available through an open source library, together with other boiler plate code &#8211; we are working on figuring out the last details on that.</p>
<p style="text-align: justify;">Feel free to give your throughs on the solution presented above and if you have used another solution to a similar problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://codemunchies.com/2009/09/repeatable-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

