Questions tagged [java-failsafe]

Failsafe is a library for handling failures in Java 8+. It works by wrapping executable logic with one or more resilience policies, which can be combined and composed as needed. Project documentation http://jodah.net/failsafe/

20 questions
13
votes
4 answers

How to implement retry policies while sending data to another application?

I am working on my application which sends data to zeromq. Below is what my application does: I have a class SendToZeroMQ that send data to zeromq. Add same data to retryQueue in the same class so that it can be retried later on if acknowledgment…
john
  • 11,311
  • 40
  • 131
  • 251
4
votes
1 answer

Why I'm not getting ConcurrentModificationException while removing element from ArrayList during iteration

I am using the following code to loop through an arraylist and then removing one element from the arraylist. Here i'm expecting ConcurrentModificationException. But didn't get that exception. especially when you are checking condition with (n-1)th…
Naveen
  • 346
  • 2
  • 10
3
votes
1 answer

How to write a unit test for a method that does a retry with back off? (Using FailSafe in Java)

This is the method that I would like to test: void someMethodThatRetries(){ Failsafe.with( retryPolicy ).get(() -> callServiceX()); } Retry policy looks like this : this.retryPolicy = new RetryPolicy() .retryIf(…
Bhallaldev
  • 31
  • 2
2
votes
1 answer

How to use circuit breaker based on a method parameter?

I have a http client that connects to the same api endpoint on different servers. Which server it connects to, depends on business logic. Let's say the http client method is connect(url). How can I make sure that the circuit breaker takes the url…
2
votes
0 answers

Writing Unit Test for Failsafe Retry and Timeout policy

Using Failsafe by jhalterman for the first time ( GIT, Website ) to add a simple asynchronous module to send sms. I am using only Retry and Timeout policy and implementation is working fine Failsafe.with(timeoutPolicy, retryPolicy) …
2
votes
1 answer

Why CopyOnWriteArrayList needs copies for both write and read operations?

Coming from this article, it says: When we are using any of the modify methods – such as add() or remove() – the whole content of the CopyOnWriteArrayList is copied into the new internal copy. Due to this simple fact, we can iterate over the list…
Stefan
  • 969
  • 6
  • 9
2
votes
1 answer

java.util.ConcurrentModificationException while mutating an object

I am iterating over a List of CustomObject and while doing this iteration, I am mutating this object by adding a tag to tags list of this custom object. I am not adding or removing any CustomObject to or from customObjects (List). I am still getting…
Mr Matrix
  • 1,128
  • 2
  • 14
  • 28
2
votes
1 answer

How does ConcurrentSkipListSet has Iterators that are weakly consistent? Understanding meaning of 'weakly consistent'

Fail-fast iterator iterates over collection. If collection gets modified while iterating, we get exception. Opposite applies for fail-safe, where iteration is happening on one collection, while write operation happen on copy of it, thus it is how…
1
vote
1 answer

Jodah Failsafe Library Timeout is taking longer then expected

I have a situation in which I wanted to implement an API retry mechanism. Let say I have an API that calls third party API where normal response time comes under 2 seconds but sometimes we got an error saying "Service Not available", "Gateway…
Sudhanshu Gupta
  • 2,255
  • 3
  • 36
  • 74
1
vote
1 answer

mechanism of "run" method of failsafe

I am using Failsafe (https://github.com/jhalterman/failsafe) as my retry logic framework and want to know more of how "run" method of failsafe works. Suppose I have: void MyCurrentFunction(parameter) { Failsafe.with(MY_RETRY_POLICY) …
derek
  • 9,358
  • 11
  • 53
  • 94
1
vote
2 answers

Failsafe with RetryPolicy and CircuitBreaker throws CircuitBreakerOpenException

I am trying to combine a retry policy with the CircuitBreaker pattern with Failsafe but I get a CircuitBreakerOpenException exception when an attempt is made with the circuit open and it is interrupted. https://github.com/jhalterman/failsafe The…
oscar
  • 1,636
  • 6
  • 31
  • 59
0
votes
0 answers

Failsafe - fallback not triggered after retry policy exceeds max. retries

I want to perform an action that can be retried for a maximum of three times. I use the Failsafe library to implement a RetryPolicy as shown below: private static FailsafeExecutor> includeFailsafe() { RetryPolicy>…
Dominique M
  • 151
  • 10
0
votes
0 answers

How to make the generic FailsafeExecutor reusable

I am using the FailSafe library to handle failures and retries. The current implementation creates the generic FailsafeExecutor on each run - var result = Failsafe.with(Collections.singletonList(retryPolicy)) .with(scheduler) …
RanAbitbul
  • 13
  • 3
0
votes
1 answer

Using custom Java annotation in pom.xml with failsave

I created a custom Java annotation @Tag("webservice") public @interface WebserviceTest { boolean executeAndIgnoreCondition() default false; } Furthermore I created Java test with this annotation. Now I would like to run failsave but only tests…
FenFen
  • 3
  • 2
0
votes
1 answer

Failsafe undesirably negating DataBufferException

I am currently creating a retry mechanism for performing requests using the failsafe-lib. The issue: the RetryPolicy that I defined includes several timeout-related exceptions, but when I use the failsafe-lib (Failsafe.with(someFallback,…
1
2