本文整理匯總了Java中org.springframework.cloud.client.loadbalancer.LoadBalanced類的典型用法代碼示例。如果您正苦於以下問題:Java LoadBalanced類的具體用法?Java LoadBalanced怎麽用?Java LoadBalanced使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LoadBalanced類屬於org.springframework.cloud.client.loadbalancer包,在下文中一共展示了LoadBalanced類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
@LoadBalanced // 自動負載均衡:他的機製是(通過)Application Name去尋找服務發現,然後去做負載均衡策略的
public RestTemplate restTemplate() {
// HttpComponentsClientHttpRequestFactory httpRequestFactory = new
// HttpComponentsClientHttpRequestFactory();
// httpRequestFactory.setConnectionRequestTimeout(1000);
// httpRequestFactory.setConnectTimeout(1000);
// httpRequestFactory.setReadTimeout(3000);
return new RestTemplate(httpRequestFactory());
}
示例2: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@LoadBalanced
@Bean
RestTemplate restTemplate() {
RestTemplate template = new RestTemplate();
template.setErrorHandler(getResponseErrorHandler());
return template;
}
示例3: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
/**
* Ribbon 経由で Eureka がサポートしているサービスを実行するための RestTemplate。
* <p>リクエスト時に利用者情報を紐づけています。
*/
@Bean
@LoadBalanced
RestTemplate restTemplate(ActorSession session) {
RestTemplate tmpl = new RestTemplate();
tmpl.setInterceptors(new ArrayList<>(Arrays.asList(
new RestActorSessionInterceptor(session)
)));
return tmpl;
}
示例4: ClientCredentialsResourceDetails
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(ClientCredentialsResourceDetails resource) {
ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
clientCredentialsResourceDetails.setClientId(resource.getClientId());
clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
clientCredentialsResourceDetails.setScope(resource.getScope());
clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
return auth2RestTemplate;
}
示例5: ClientCredentialsResourceDetails
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(
ClientCredentialsResourceDetails resource) {
ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
clientCredentialsResourceDetails.setClientId(resource.getClientId());
clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
clientCredentialsResourceDetails.setScope(resource.getScope());
clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
return auth2RestTemplate;
}
開發者ID:kbastani,項目名稱:cloud-native-microservice-strangler-example,代碼行數:16,代碼來源:LegacyEdgeApplication.java
示例6: ShoppingCartServiceV1
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Autowired
public ShoppingCartServiceV1(CartEventRepository cartEventRepository,
@LoadBalanced OAuth2RestTemplate oAuth2RestTemplate,
@LoadBalanced RestTemplate normalRestTemplate) {
this.cartEventRepository = cartEventRepository;
this.oAuth2RestTemplate = oAuth2RestTemplate;
this.restTemplate = normalRestTemplate;
}
示例7: OrderServiceV1
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Autowired
public OrderServiceV1(OrderRepository orderRepository,
OrderEventRepository orderEventRepository,
@LoadBalanced OAuth2RestTemplate oAuth2RestTemplate) {
this.orderRepository = orderRepository;
this.orderEventRepository = orderEventRepository;
this.oAuth2RestTemplate = oAuth2RestTemplate;
}
示例8: maturingServiceUpdater
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
MaturingServiceUpdater maturingServiceUpdater(IngredientsProperties ingredientsProperties,
IngredientWarehouse ingredientWarehouse,
MaturingService maturingService,
@LoadBalanced RestTemplate restTemplate,
EventGateway eventGateway) {
return new MaturingServiceUpdater(ingredientsProperties,
ingredientWarehouse, maturingService, restTemplate, eventGateway);
}
示例9: bottlingServiceUpdater
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
BottlingServiceUpdater bottlingServiceUpdater(Tracer trace, PresentingServiceClient presentingServiceClient,
BottlingService bottlingService,
@LoadBalanced RestTemplate restTemplate,
EventGateway eventGateway) {
return new BottlingServiceUpdater(brewProperties(), trace, presentingServiceClient,
bottlingService, restTemplate, eventGateway);
}
示例10: bottlingService
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
BottlerService bottlingService(BottlingWorker bottlingWorker,
PresentingClient presentingClient,
@LoadBalanced RestTemplate restTemplate,
AsyncRestTemplate asyncRestTemplate,
Tracer tracer) {
return new BottlerService(bottlingWorker, presentingClient, restTemplate, asyncRestTemplate, tracer);
}
示例11: BottlingWorker
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Autowired
public BottlingWorker(Tracer tracer,
PresentingClient presentingClient,
@LoadBalanced RestTemplate restTemplate, EventGateway eventGateway) {
this.tracer = tracer;
this.presentingClient = presentingClient;
this.restTemplate = restTemplate;
this.eventGateway = eventGateway;
}
示例12: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
clientHttpRequestFactory.setReadTimeout(1);
clientHttpRequestFactory.setConnectTimeout(1);
return new RestTemplate(clientHttpRequestFactory);
}
示例13: testAppClient
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
@DependsOnLoadBalancedClient //TODO: can this be avoided?
public TestAppClient testAppClient(@LoadBalanced OkHttpClient.Builder builder) {
Retrofit retrofit = new Retrofit.Builder()
// here you use a service id, or virtual hostname
// rather than an actual host:port, ribbon will
// resolve it
.baseUrl("http://testapp")
.client(builder.build())
.addConverterFactory(JacksonConverterFactory.create())
.build();
return retrofit.create(TestAppClient.class);
}
開發者ID:spring-cloud-incubator,項目名稱:spring-cloud-square,代碼行數:14,代碼來源:OkHttpRibbonInterceptorTests.java
示例14: restTemplate
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
}
示例15: restTempalte
import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
@LoadBalanced
public RestTemplate restTempalte(){
return new RestTemplate();
}