org.eclipse.microprofile.faulttolerance.Bulkhead Java Examples
The following examples show how to use
org.eclipse.microprofile.faulttolerance.Bulkhead.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DisableAnnotationGloballyTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .disable(Retry.class) .disable(CircuitBreaker.class) .disable(Timeout.class) .disable(Asynchronous.class) .disable(Fallback.class) .disable(Bulkhead.class); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableGlobally.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableGlobally.war") .addAsLibrary(testJar); return war; }
Example #2
Source File: DisableFTEnableOnClassTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .enable(DisableAnnotationClient.class, Retry.class) .enable(DisableAnnotationClient.class, CircuitBreaker.class) .enable(DisableAnnotationClient.class, Timeout.class) .enable(DisableAnnotationClient.class, Asynchronous.class) .enable(DisableAnnotationClient.class, Fallback.class) .enable(DisableAnnotationClient.class, Bulkhead.class) .disableGlobally(); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableGlobalEnableClass.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableGlobalEnableClass.war") .addAsLibrary(testJar); return war; }
Example #3
Source File: DisableAnnotationOnMethodsTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .disable(DisableAnnotationClient.class, "failAndRetryOnce", Retry.class) .disable(DisableAnnotationClient.class, "failRetryOnceThenFallback", Fallback.class) .disable(DisableAnnotationClient.class, "failWithCircuitBreaker", CircuitBreaker.class) .disable(DisableAnnotationClient.class, "failWithTimeout", Timeout.class) .disable(DisableAnnotationClient.class, "asyncWaitThenReturn", Asynchronous.class) .disable(DisableAnnotationClient.class, "waitWithBulkhead", Bulkhead.class); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableMethods.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableMethods.war") .addAsLibrary(testJar); return war; }
Example #4
Source File: DisableAnnotationOnClassTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .disable(DisableAnnotationClient.class, Retry.class) .disable(DisableAnnotationClient.class, CircuitBreaker.class) .disable(DisableAnnotationClient.class, Timeout.class) .disable(DisableAnnotationClient.class, Asynchronous.class) .disable(DisableAnnotationClient.class, Fallback.class) .disable(DisableAnnotationClient.class, Bulkhead.class); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableClass.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableClass.war") .addAsLibrary(testJar); return war; }
Example #5
Source File: DisableFTEnableOnMethodTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .enable(DisableAnnotationClient.class, "failAndRetryOnce", Retry.class) .enable(DisableAnnotationClient.class, "failWithCircuitBreaker", CircuitBreaker.class) .enable(DisableAnnotationClient.class, "failWithTimeout", Timeout.class) .enable(DisableAnnotationClient.class, "asyncWaitThenReturn", Asynchronous.class) .enable(DisableAnnotationClient.class, "failRetryOnceThenFallback", Fallback.class) .enable(DisableAnnotationClient.class, "waitWithBulkhead", Bulkhead.class) .disableGlobally(); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableGloballyEnableMethod.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableGloballyEnableMethod.war") .addAsLibrary(testJar); return war; }
Example #6
Source File: FaultToleranceExtension.java From smallrye-fault-tolerance with Apache License 2.0 | 6 votes |
void registerInterceptorBindings(@Observes BeforeBeanDiscovery bbd, BeanManager bm) { LOGGER.info("MicroProfile: Fault Tolerance activated"); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(CircuitBreaker.class))); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Retry.class))); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Timeout.class))); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Asynchronous.class))); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Fallback.class))); bbd.addInterceptorBinding(new FTInterceptorBindingAnnotatedType<>(bm.createAnnotatedType(Bulkhead.class))); // It seems that fraction deployment module cannot be picked up as a CDI bean archive - see also SWARM-1725 bbd.addAnnotatedType(bm.createAnnotatedType(FaultToleranceInterceptor.class), FaultToleranceInterceptor.class.getName()); bbd.addAnnotatedType(bm.createAnnotatedType(DefaultFallbackHandlerProvider.class), DefaultFallbackHandlerProvider.class.getName()); bbd.addAnnotatedType(bm.createAnnotatedType(ExecutorProvider.class), ExecutorProvider.class.getName()); bbd.addAnnotatedType(bm.createAnnotatedType(DefaultFaultToleranceOperationProvider.class), DefaultFaultToleranceOperationProvider.class.getName()); bbd.addAnnotatedType(bm.createAnnotatedType(MetricsCollectorFactory.class), MetricsCollectorFactory.class.getName()); bbd.addAnnotatedType(bm.createAnnotatedType(StrategyCache.class), StrategyCache.class.getName()); }
Example #7
Source File: DisableFTEnableGloballyTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .enable(Retry.class) .enable(CircuitBreaker.class) .enable(Timeout.class) .enable(Asynchronous.class) .enable(Fallback.class) .enable(Bulkhead.class) .disableGlobally(); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableGlobalEnableClass.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableGlobalEnableClass.war") .addAsLibrary(testJar); return war; }
Example #8
Source File: BulkheadConfigTest.java From microprofile-fault-tolerance with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive create() { ConfigAnnotationAsset config = new ConfigAnnotationAsset() .set(BulkheadConfigBean.class, "serviceValue", Bulkhead.class, "value", "1") .set(BulkheadConfigBean.class, "serviceWaitingTaskQueue", Bulkhead.class, "waitingTaskQueue", "1"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ftBulkheadConfig.jar") .addClass(BulkheadConfigBean.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); WebArchive war = ShrinkWrap.create(WebArchive.class, "ftBulkheadConfig.war") .addAsLibrary(jar); return war; }
Example #9
Source File: Bulkhead5RapidRetry12MethodSynchBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(value = 5, waitingTaskQueue = 5) @Retry(retryOn = { BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.MICROS, maxRetries = 0, maxDuration=999999 ) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #10
Source File: DisableAnnotationGloballyEnableOnClassTest.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .disable(Retry.class) .disable(CircuitBreaker.class) .disable(Timeout.class) .disable(Asynchronous.class) .disable(Fallback.class) .disable(Bulkhead.class) .enable(DisableAnnotationClient.class, Retry.class) .enable(DisableAnnotationClient.class, CircuitBreaker.class) .enable(DisableAnnotationClient.class, Timeout.class) .enable(DisableAnnotationClient.class, Asynchronous.class) .enable(DisableAnnotationClient.class, Fallback.class) .enable(DisableAnnotationClient.class, Bulkhead.class); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableGlobalEnableClass.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableGlobalEnableClass.war") .addAsLibrary(testJar); return war; }
Example #11
Source File: ClashingNameBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(maxRetries = 5) @Bulkhead(3) @Timeout(value = 1000, unit = ChronoUnit.MILLIS) @CircuitBreaker(failureRatio = 1.0, requestVolumeThreshold = 20) @Fallback(fallbackMethod = "doFallback") @Asynchronous public Future<Void> doWork() { return CompletableFuture.completedFuture(null); }
Example #12
Source File: ClashingNameBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(maxRetries = 5) @Bulkhead(3) @Timeout(value = 1000, unit = ChronoUnit.MILLIS) @CircuitBreaker(failureRatio = 1.0, requestVolumeThreshold = 20) @Fallback(fallbackMethod = "doFallback") @Asynchronous public Future<Void> doWork(String dummy) { return CompletableFuture.completedFuture(null); }
Example #13
Source File: AllMetricsBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(maxRetries = 5) @Bulkhead(3) @Timeout(value = 1, unit = ChronoUnit.MINUTES) @CircuitBreaker(failureRatio = 1.0, requestVolumeThreshold = 20) @Fallback(fallbackMethod = "doFallback") @Asynchronous public Future<Void> doWork() { return CompletableFuture.completedFuture(null); }
Example #14
Source File: BulkheadMetricBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
/** * WaitFor method for testing async calls * * @param future to complete * @return a completed future set to null */ @Asynchronous @Bulkhead(value = 2, waitingTaskQueue = 2) public Future<Void> waitForAsync(Future<?> future) { doWaitFor(future); return CompletableFuture.completedFuture(null); }
Example #15
Source File: Bulkhead55RapidRetry10MethodAsynchBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(waitingTaskQueue = 5, value = 5) @Asynchronous @Retry(retryOn = { BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.MICROS, maxRetries = 10, maxDuration=999999) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #16
Source File: Bulkhead55RapidRetry10MethodSynchBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(waitingTaskQueue = 5, value = 5) @Retry(delay = 1, delayUnit = ChronoUnit.MILLIS, maxRetries = 10, maxDuration=999999) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #17
Source File: Bulkhead10MethodAsynchronousBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(10) @Asynchronous public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName() ); return action.perform(); }
Example #18
Source File: BulkheadMethodAsynchronousQueueingBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(value = 10, waitingTaskQueue = 10) @Asynchronous public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName() ); return action.perform(); }
Example #19
Source File: Bulkhead5MethodSynchronousRetry20Bean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(value = 5) @Retry(retryOn = { BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.SECONDS, maxRetries = 20, maxDuration=999999) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #20
Source File: Bulkhead3MethodAsynchronousBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(3) @Asynchronous public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName() ); return action.perform(); }
Example #21
Source File: Bulkhead55MethodAsynchronousRetryBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(waitingTaskQueue = 5, value = 5) @Asynchronous @Retry(retryOn = { BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.SECONDS, maxRetries = 10, maxDuration=999999) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #22
Source File: BulkheadMethodAsynchronousDefaultBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead @Asynchronous public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName() ); return action.perform(); }
Example #23
Source File: Bulkhead5RapidRetry0MethodSynchBean.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Override @Bulkhead(value = 5) @Retry(retryOn = { BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.MICROS, maxRetries = 0, maxDuration=999999 ) public Future test(BackendTestDelegate action) throws InterruptedException { Utils.log("in business method of bean " + this.getClass().getName()); return action.perform(); }
Example #24
Source File: DisableAnnotationOnClassEnableOnMethodTest.java From microprofile-fault-tolerance with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive deploy() { Asset config = new DisableConfigAsset() .disable(DisableAnnotationClient.class, Retry.class) .disable(DisableAnnotationClient.class, CircuitBreaker.class) .disable(DisableAnnotationClient.class, Timeout.class) .disable(DisableAnnotationClient.class, Asynchronous.class) .disable(DisableAnnotationClient.class, Fallback.class) .disable(DisableAnnotationClient.class, Bulkhead.class) .enable(DisableAnnotationClient.class, "failAndRetryOnce", Retry.class) .enable(DisableAnnotationClient.class, "failWithCircuitBreaker", CircuitBreaker.class) .enable(DisableAnnotationClient.class, "failWithTimeout", Timeout.class) .enable(DisableAnnotationClient.class, "asyncWaitThenReturn", Asynchronous.class) .enable(DisableAnnotationClient.class, "failRetryOnceThenFallback", Fallback.class) .enable(DisableAnnotationClient.class, "waitWithBulkhead", Bulkhead.class); JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ftDisableClassEnableMethod.jar") .addClasses(DisableAnnotationClient.class) .addPackage(Packages.UTILS) .addAsManifestResource(config, "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); WebArchive war = ShrinkWrap .create(WebArchive.class, "ftDisableClassEnableMethod.war") .addAsLibrary(testJar); return war; }
Example #25
Source File: OrderRepository.java From Hands-On-Cloud-Native-Applications-with-Java-and-Quarkus with MIT License | 5 votes |
@Asynchronous @Bulkhead(value = 5, waitingTaskQueue = 10) private Future writeSomeLogging(String item) { LOGGER.info("New Customer order at: "+new java.util.Date()); LOGGER.info("Item: {}", item); return CompletableFuture.completedFuture("ok"); }
Example #26
Source File: PingService.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
@Asynchronous @Bulkhead(value = BulkheadTest.QUEUE_SIZE, waitingTaskQueue = BulkheadTest.QUEUE_SIZE) public Future<String> ping(CountDownLatch startLatch, CountDownLatch endLatch) throws InterruptedException { if (startLatch != null) { startLatch.countDown(); } if (endLatch != null) { if (endLatch.await(1500, TimeUnit.MILLISECONDS)) { return CompletableFuture.completedFuture("pong"); } else { return CompletableFuture.completedFuture("timeout"); } } return CompletableFuture.completedFuture("null"); }
Example #27
Source File: RetryTestBean.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(retryOn = BulkheadException.class, delay = 500) @Bulkhead(2) @Fallback(fallbackMethod = "fallback") public String callWithRetryOnBulkhead() { int attempt = this.attempt.getAndIncrement(); // both first attempts should take long time // without @Asynchronous, the third attempt should fail right away with BulkheadException and should be retried // the third attempt should be retried in 500 ms, after the first two calls were processed and should be successful // no fallback should be called if (attempt < 2) { sleep(300L); } return "call" + attempt; }
Example #28
Source File: RetryTestBean.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(retryOn = TimeoutException.class, delay = 500) @Bulkhead(2) public String callWithNoRetryOnBulkhead() { int attempt = this.attempt.getAndIncrement(); if (attempt < 2) { sleep(300L); } return "call" + attempt; }
Example #29
Source File: RetryTestBean.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
@Retry(retryOn = TimeoutException.class, delay = 500) @Bulkhead(2) @Fallback(fallbackMethod = "fallback") public String callWithFallbackAndNoRetryOnBulkhead() { int attempt = this.attempt.getAndIncrement(); if (attempt < 2) { sleep(300L); } return "call" + attempt; }
Example #30
Source File: AsyncHelloService.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
@Asynchronous @Bulkhead(value = 15, waitingTaskQueue = 15) @Timeout(value = 1, unit = ChronoUnit.SECONDS) @Fallback(fallbackMethod = "fallback") public CompletionStage<String> bulkheadTimeout(boolean fail) throws InterruptedException { if (fail) { Thread.sleep(2000); } return completedFuture("Hello from @Bulkhead @Timeout method"); }