当前位置: 首页>>代码示例>>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;未经允许,请勿转载。