use of com.alibaba.csp.sentinel.demo.dubbo.consumer.FooServiceConsumer in project Sentinel by alibaba.
the class FooConsumerBootstrap method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext consumerContext = new AnnotationConfigApplicationContext();
consumerContext.register(ConsumerConfiguration.class);
consumerContext.refresh();
FooServiceConsumer service = consumerContext.getBean(FooServiceConsumer.class);
for (int i = 0; i < 15; i++) {
try {
String message = service.sayHello("Eric");
System.out.println("Success: " + message);
} catch (SentinelRpcException ex) {
System.out.println("Blocked");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
use of com.alibaba.csp.sentinel.demo.dubbo.consumer.FooServiceConsumer in project Sentinel by alibaba.
the class FooConsumerBootstrap method main.
public static void main(String[] args) {
initFlowRule();
AnnotationConfigApplicationContext consumerContext = new AnnotationConfigApplicationContext();
consumerContext.register(ConsumerConfiguration.class);
consumerContext.refresh();
FooServiceConsumer service = consumerContext.getBean(FooServiceConsumer.class);
for (int i = 0; i < 10; i++) {
pool.submit(() -> {
try {
String message = service.sayHello("Eric");
System.out.println("Success: " + message);
} catch (SentinelRpcException ex) {
System.out.println("Blocked");
} catch (Exception ex) {
ex.printStackTrace();
}
});
pool.submit(() -> System.out.println("Another: " + service.doAnother()));
}
}
Aggregations