Spring Retry

Using Spring boot Async with Retry

A few months ago, during technical design session for a light micro service that requires calling different microservices while customer receives an asynchronous response. Ive seen the need to use something simple, but effective and choose to go with Async & Retry of Spring boot.

Why this choice?

Spring Retry provides the ability to automatically re-invoke a failed operation. This is helpful when errors may be transient in nature (like a momentary temporary errors). Also it provides a declarative control of the process and policy-based behavior that is easy to extend and customize.

Spring boot @Async provides the ability to make it execute in a separate thread, for instance, the caller will not wait for the completion of the called method.

Why those choices? It’s simple with less lines of code and Retry & Async is implemented. All you need is @EnableRetry on SpringBootApplication:

Add the async on any public method that is used before the retry:

And on the function in your interface:

After that, a simple test that asserts that the retry mechanism is working as expected.

Annotations are an easy way to get started with Spring Retry And Async and it is good enough for many cases. However, if you need more customization there is a RetryTemplate & RestTemplate where you easily can configure stuff exactly the way you want it. Sure you could create RetryTemplate and more sophisticated rules and properties. You can find more in this article: https://www.baeldung.com/spring-retry

When working with external APIs, especially micro services, a lot of things can go wrong especially network glitches. This is where it is important to consider having retries. Spring Retry can handle this for you in an easy and convenient.

Is retries always the way to go? Not always, like everything in software engineering there is no right or wrong solution for everything. There is the right solution for a particular use case. Use retry only on the temporary errors, it isn’t recommended to to use it on permanent errors else it can cause system performance issues. 

To improve the resilience of microservices architecture, it is recommended considering Spring Retry & Circuit Breaker. Spring retry is not an alternative to circuit breaker.

With CircuitBreaker, using a RetryTemplate is recommended.

A nice article to check, Applying The Circuit Breaker Pattern at HMH

Do you have any thoughts, comments disagreements? let me know!

Development Conferences in 2019

Reasons why I Attend Tech Conferences?

Educational is top one on my list

No matter how experienced I’m in my field, I always have the need to learn. Working in daily business ventures can often be isolated in one team without the exposure to variety of points of views. This sometimes to missing new ideas, trends that can impact future results. The educational aspect of any of those conferences is bug and can expose me to new ways of conducting my business, meanwhile helps me discover how to be more productive and bring new opportunities to the my employer and colleagues.

Encounter new vendors and vendors

Discovering innovative products and services for your business is necessary to stay competitive in today’s fast-paced world.  Plus, many vendors who sell to your industry fully grasp what is happening inside your competition.  Invest time with the sponsors at the event and turn them into your friends and allies. Get nice goodies! and you may introduce a great product for your team at the end of the day! (Happened with me on multiple occasions)

Position yourself as an expert

When you are active in your industry, you can develop a reputation as an expert to your peers and your clients.  Those who are engaged over the long term are often asked to speak at the events and to write articles for their industry publications.  Like it or not, others like to associate with the experts in any industry.  Clients feel good about doing business with those that are celebrated by their peers. If your strategy is to be the best-kept secret in your business community, you will be missing a valuable opportunity. I prefer to share my knowledge, and grow together with anyone I do business with.

Having Fun & Networking

Being between people that share the same interest is fun, it gave me the opportunity to speak more freely specially at AMA (ASK ME ANYTHING) sessions.
On the other hand conferences provide a great opportunity to network. Often competitors from other regions of the world can become valuable resources for referrals and best-practices. Collaboration is the way to approach networking.

For instant, Qcon offers a great way to network during lunch time. Eat with people you don’t know, discuss what you like and get the best out of it…

Such conferences can add a layer of enjoyment to managing my career growth by mixing the social and learning aspect.

Never underestimate the power of a little fun mixed with some interesting people!

Many falsely believe that since they can now access industry information via the Internet that the days of the live meeting are gone.  The truth is, meetings are more important than ever.  The value in meetings comes from the human-to-human connections that occur.  Often people cite the serendipitous “hallway conversations” that they have with other attendees as the most valuable parts of attending an event.  While these are not on the agenda, or mentioned in the breakout sessions learning objectives, when two or more people begin to discuss topics on a deeper and personal level, the success of the event to those involved becomes irreplaceable.  It is the people that bring the ROI to your time at a conference.

Usually, I take an extra day at the end of the conference to visit the city of the conference and enjoy the trip exposure while exploring the culture.

Bring back goodies & knowledge to your team

I have a big drawer of gifts I got in conferences, many of which i gift to others or I use for myself. Having been at such conferences, its always good to bring back with you knowledge to the team you work with and share what you learned!

Create an engineering social, share with your peers what you found interesting and try to get them the videos to watch. This may allow them to join you next time and it will get your ideas you believed in to your work where you spend the most time of the week.

Finally!

Below you will find a great list of conferences for 2019, I hope we could meet on one of those and have a heated discussion that can end up with a great solution!

ConferenceLocationWebsiteDate
FosdemBrussels | Belgiumhttps://fosdem.org/2019/Feb 2 – 3
DeveloperweekSan Francisco | USAhttps://www.developerweek.com/Feb 20 -> 22
Qcon LondonLondon | UK https://qconlondon.com/March 4 -> 8
Java Dayİstanbul | Türkiyehttps://javaday.istanbul/March 16
JavaLandBruehl | Germanyhttps://www.javaland.eu/March 19 -> 21
Dublin tech summitDublin | Irelandhttps://dublintechsummit.com/April 10 – 11
Devoxx FRParis | Francehttps://www.devoxx.fr/April 17 -> 19
DockerConSan Francisco | USAhttps://www.docker.com/April 29 -> May 2
Microsoft BuildSeattle | USA https://www.microsoft.com/en-us/buildMay 6 -> 8
Devoxx UKLondon | UK https://www.devoxx.co.uk/May 8 -> 10
J on the beachMarbella| Spainhttps://www.jonthebeach.com/May 15 -> 17
GeeCONKraków | Polandhttps://2019.geecon.org/May 15 -> 17
Software Design & DevelopmentLondon | UKhttps://sddconf.com/May 20 -> 24
ACEKraków | Polandhttps://aceconf.com/May 23 – 24
J-SPRING 2019Utrecht | Netherlandshttps://jspring.nl/May 29
Riga DevDaysRiga | Latviahttps://2019.rigadevdays.lv/May 29 – 31
KotlinersBudapest | Hungaryhttps://www.conferenceforkotliners.com/June 7
GOTO AmsterdamAmsterdam | Netherlandshttps://gotoams.nl/June 17 -> 20
Devoxx PLKraków | Poland http://devoxx.pl/June 24 -> 26
QconNew York | USAhttps://qconnewyork.com/June 24 -> 26
J-FALL 2019The Netherlandshttps://jfall.nl/Oct 30 – 31
Devoxx UAKyiv | Ukrainehttps://devoxx.org.ua/Nov 1 – 2
Devoxx BEAntwerp | Belgiumhttps://devoxx.be/Nov 4 -> 8
QconSan Francisco | USAhttps://qconsf.com/Nov 11 -> 15
Devoxx MoroccoMarrakech | Moroccohttps://devoxx.ma/Nov 27 -> 29
KotlinConfCopenhagen | Denmarkhttps://kotlinconf.comDec 4 -> 6

If you find those conferences expensive, there are ways to visit them for free. Being a volunteer at a conference is a great way to watch the conference enjoy the people and attend it for free.
You can view some of the volunteering options for Qcon on https://qconlondon.com/volunteers

If you need help or questions about volunteering you can always reach me on social media!
Twitter: @gajabahian

I hope I answered my version of why to attend Development conferences?