Skip to content

42patterns/training-spring-integration

Repository files navigation

Exercises

TODO follow you must. There are places in code annotated as todos, which guides ou

Load balancing

  1. Create a randomized load balancer

    1. Implement LoadBalancingStrategy so that the returned list of handlers will be randomized. Dispatcher takes first to process message, so changing the order of handlers does the job.

Scatter and gather

  1. The http://musicbrainz.org service is not very reliable, regularly returning 503 responses - Service temporarily unavailable. To mitigate it we need to add appropriate retry policy, so that failing messages will be repeated.

    1. Look for RetryTemplate class and how it can be used with request handling advices (http://docs.spring.io/spring-integration/reference/htmlsingle/#advice-classes)

  2. Despite retrials the response can eventually fail. Configure appropriate errorChannel so that error will be redirected there

    1. Class RequestHandlerRetryAdvice can be further configured with recoveryCallback (initially empty) and retryTemplate (initially three retries).

    2. Prepare a bean with will try only once and after failure redirect message to a newly created myErrorChannel.

    3. Error channel can be set during constructing ErrorMessageSendingRecoverer bean.

Result cache

  1. This about you it can be tested that we are dealing with cached value (in a reliable way - other than measuring time)

    1. Generate cache-related MessageHeader

    2. Preserve it between channels and eventually map it within the outbound gateway

    3. Check in test if caching was successful (if the flag / header is set)

  2. Spring Integration Java DSL is a new - different way - of expressing integration flows with a fluent Java interface.

    1. Rewrite the current integration from of the result cache example to fully utilize the IntegrationFlows builder

    2. This online Spring tutorial might be of some help and guidance:

  3. Current workflow is very complicated, non-linear and hard to reason about

    1. Based on previous assignment (explicit header that was set - refactor CacheLayer no to take MessageChannel as a parameter and explicity route the message based on headers (with <int:header-value-router />)

Pipes and filters

  1. Some (most popular) products might come with subcategories (AGD / TV)

    1. Implement product searches for subcategories, for example AGD/TV, using separate queue for category

    2. Extend Product with subcategory field and process it accordingly

    3. When you search for AGD you go to all services, when you search AGD/TV, you go to specific service

Shared Spaces

  1. How to trace flow of messages through integration components?

    1. Check MessageHistory and WireTap patterns

Service orchestation

  1. AirBnB API doesn’t work, find out why and fix it, and add fallback to different provider

    1. You can use Google Places API as a fallback (create a separate fallback channel in a similar way as in Result Cache example

    2. Use following url https://maps.googleapis.com/maps/api/place/textsearch/json?query=hotels+near+{location}&key={api-key} passing over location and api key

    3. Use a following Google API key to proceed: AIzaSyCvyRnNH7aSfWaDCG1n7IMpBEVM355scnY

Protocol adapter

  1. Make use of parameterized callback URL, don’t hardcode it pass it as a part of HTTP request

  2. Implement retry when it is not possible to send callback

About

Spring Integration workshop exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages