You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hystrix-contrib/hystrix-javanica/README.md
+44-1Lines changed: 44 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -326,7 +326,32 @@ Based on [this](https://github.com/Netflix/Hystrix/wiki/How-To-Use#ErrorPropagat
326
326
}
327
327
```
328
328
329
-
If `userResource.getUserById(id);` throws an exception which type is _BadRequestException_ then this exception will be thrown without triggering fallback logic.
329
+
If `userResource.getUserById(id);` throws an exception that type is _BadRequestException_ then this exception will be wrapped in ``HystrixBadRequestException`` and re-thrown without triggering fallback logic. You don't need to do it manually, javanica will do it for you under the hood. It is worth noting that a caller will get root cause exception, i.e. user ``BadRequestException``. A caller always gets root cause exception, never ``HystrixBadRequestException`` or ``HystrixRuntimeException`` except the case when executed code explicitly throws those exceptions.
330
+
331
+
*Note*: If command has a fallback then only first exception that trigers fallback logic will be propagated to caller. Example:
332
+
333
+
```java
334
+
classService {
335
+
@HystrixCommand(fallbackMethod="fallback")
336
+
Objectcommand(Objecto) throwsCommandException {
337
+
thrownewCommandException();
338
+
}
339
+
340
+
@HystrixCommand
341
+
Objectfallback(Objecto) throwsFallbackException {
342
+
thrownewFallbackException();
343
+
}
344
+
}
345
+
346
+
// in client code
347
+
{
348
+
try {
349
+
service.command(null);
350
+
} catch (Exception e) {
351
+
assertCommandException.class.equals(e.getClass())
352
+
}
353
+
}
354
+
```
330
355
331
356
## Request Cache
332
357
@@ -531,6 +556,24 @@ ThreadPoolProperties can be set using @HystrixCommand's 'threadPoolProperties' l
531
556
}
532
557
```
533
558
559
+
### DefaultProperties
560
+
``@DefaultProperties`` is class (type) level annotation that allows to default commands properties such as ``groupKey``, ``threadPoolKey``, ``commandProperties``, ``threadPoolProperties`` and ``ignoreExceptions``. Properties specified using this annotation will be used by default for each hystrix command defined within annotated class unless a command specifies those properties explicitly using corresponding ``@HystrixCommand`` parameters.
561
+
Example:
562
+
563
+
```java
564
+
@DefaultProperties(groupKey="DefaultGroupKey")
565
+
classService {
566
+
@HystrixCommand// hystrix command group key is 'DefaultGroupKey'
567
+
publicObjectcommandInheritsDefaultProperties() {
568
+
returnnull;
569
+
}
570
+
@HystrixCommand(groupKey="SpecificGroupKey") // command overrides default group key
571
+
publicObjectcommandOverridesGroupKey() {
572
+
returnnull;
573
+
}
574
+
}
575
+
```
576
+
534
577
## Hystrix collapser
535
578
536
579
Suppose you have some command which calls should be collapsed in one backend call. For this goal you can use ```@HystrixCollapser``` annotation.
0 commit comments