當前位置: 首頁>>代碼示例>>Java>>正文


Java LoadBalanced類代碼示例

本文整理匯總了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());
}
 
開發者ID:yangdd1205,項目名稱:spring-cloud-master,代碼行數:11,代碼來源:RetryApplication.java

示例2: restTemplate

import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@LoadBalanced
@Bean
RestTemplate restTemplate() {
	RestTemplate template = new RestTemplate();
	template.setErrorHandler(getResponseErrorHandler());

	return template;
}
 
開發者ID:daflockinger,項目名稱:poppynotes,代碼行數:9,代碼來源:CloudConfig.java

示例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;
}
 
開發者ID:jkazama,項目名稱:sample-boot-micro,代碼行數:14,代碼來源:MicroWebConfig.java

示例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;
}
 
開發者ID:kbastani,項目名稱:cloud-native-microservice-strangler-example,代碼行數:15,代碼來源:UserApplication.java

示例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;
}
 
開發者ID:kbastani,項目名稱:spring-cloud-event-sourcing-example,代碼行數:9,代碼來源:ShoppingCartServiceV1.java

示例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;
}
 
開發者ID:kbastani,項目名稱:spring-cloud-event-sourcing-example,代碼行數:9,代碼來源:OrderServiceV1.java

示例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);
}
 
開發者ID:spring-cloud-samples,項目名稱:brewery,代碼行數:10,代碼來源:AggregationConfiguration.java

示例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);
}
 
開發者ID:spring-cloud-samples,項目名稱:brewery,代碼行數:9,代碼來源:BrewConfiguration.java

示例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);
}
 
開發者ID:spring-cloud-samples,項目名稱:brewery,代碼行數:9,代碼來源:BottlingConfiguration.java

示例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;
}
 
開發者ID:spring-cloud-samples,項目名稱:brewery,代碼行數:10,代碼來源:BottlingWorker.java

示例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);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-sleuth,代碼行數:9,代碼來源:WebClientExceptionTests.java

示例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();
}
 
開發者ID:twb0223,項目名稱:springcloudproject,代碼行數:6,代碼來源:ServiceRibbonApplication.java

示例15: restTempalte

import org.springframework.cloud.client.loadbalancer.LoadBalanced; //導入依賴的package包/類
@Bean
@LoadBalanced
public RestTemplate restTempalte(){
	return new RestTemplate();
}
 
開發者ID:QNJR-GROUP,項目名稱:EasyTransaction,代碼行數:6,代碼來源:RestRibbonEasyTransRpcConfiguration.java


注:本文中的org.springframework.cloud.client.loadbalancer.LoadBalanced類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。