question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExecutorService + Wildfly

See original GitHub issue

Since 2.0.1, Failsafe supports ExecutorService. I have tried to use ManagedExecutorService (JEE -Wildfly) to use FailSafe in WildFly. The circuit break never switchs to half-open state.

    private final CircuitBreaker<Object> circuitBreakerRuntime = new CircuitBreaker<>()
            .onOpen(this::openCircuit)
            .onClose(this::closeCircuit)
            .onHalfOpen(this::halfCircuit)
            .withFailureThreshold(2)
            .withSuccessThreshold(1)
            .withDelay(Duration.ofSeconds(10));
...
    @Resource
    private ManagedExecutorService managedExecutorService;

...
Failsafe
                .with(hsmFailureService.getCircuitBreakerRuntime(), hsmFailureService.getRetryPolicyInit())
                .with(managedExecutorService)
                .onSuccess(e -> log.debug("HSM is ONLINE"))
                .onFailure(e -> log.warn("Retrying FAILED"))
                .get(hsmConfigInitializer::initProvider);

Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jhaltermancommented, Feb 6, 2019

Your stated reason for not allowing this was to force the programmer to be aware of order, but if the names are suggestive enough, wouldn’t that force awareness as well?

Yea, being more explicit wouldn’t be a bad thing, it would just be a bit more verbose. I would probably prefer to offer more explicit wrapping but only in one direction:

Failsafe.with(circuitBreaker)
  .wrapWith(retryPolicy)
  .wrapWith(fallback);

…since wrapping the other way is harder to reason about when considering pre and post execution behaviors in policies, and wrapping in both directions is just more to explain. In this case Failsafe.with(fallback, retryPolicy, circuitBreaker) could still be shorthand but at least we’d have an explicit alternative to compare it to.

0reactions
malyscommented, Feb 18, 2019

Reading your comments (see it)

The important thing to know is that the CircuitBreaker only transitions when an execution occurs.

It was not a problem of asynchronous call but I must generate executions to enable half-open state. (tricky 😃)

Thx for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to use ExecutorService in webapp - JBoss.org
1. is this the right way to use ExecutorService? Is there any better way to do it? Since I'm already inside a webapp...
Read more >
managed-executor-service - WildFly Full 19 Model Reference
completed-task-count The approximate total number of tasks that have completed execution. Attribute, Value. Type, LONG. Nillable, false. Expressions ...
Read more >
Jboss Java EE container and an ExecutorService
ExecutorService es = Executors.newFixedThreadPool(10);. I now want to re-use the same solution within an EJB bean but am unsure how to correctly ...
Read more >
How to use the ManagedExecutorService to submit tasks
Since WildFly 23, the managed executors in the EE subsystem are capable of identifying tasks which are running for a long unexpected time,...
Read more >
Chapter 9. Concurrency Utilities Red Hat JBoss Enterprise ...
Managed executor service (javax.enterprise.concurrent.ManagedExecutorService) allows Java EE applications to submit tasks for asynchronous execution. JBoss ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found