Yaylı bulut kullanarak bir yaylı önyükleme uygulaması oluşturdum ve RestTemplate uygulamasını istemci uygulamda kullanmak istiyorum (ki bu da bir microservice). Bütünleştirme testi için mockMvc kullanmaya devam edebilirim. Ben çağırıyorum hizmet içinde müşteri microservice ve eureka istemci ile varsayılan şerit/eureka/hystrix istemci kurulumunu kullanıyorum. Bu çalışmaktadır (serviceTDS, restTemplate içinde bir hizmet son noktasını tanımlayan şey olduğunu anladım). Benim sorunum, restTemplate okuma ve bağlantı zaman aşımını 300ms'lik bir varsayılan gibi görünenlerden değiştiremiyorum. çağrı üzerineYaylı şerit/eureka/hystrix restTemplate kullanarak bağlanamaz/zaman aşımlarını ayarlayamıyor
Detayları:
spring:
cloud:
client:
serviceIds:
- someservice
someservice:
ribbon:
#listOfServers: localhost:7080
#NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
# the eureka vipAddress of the target service (Disabled)
DeploymentContextBasedVipAddresses: someservice
# Interval to refresh the server list from the source
ServerListRefreshInterval: 1000
# Connect timeout used by Apache HttpClient.. apparently not by restTemplate
ConnectTimeout: 30000
# Read timeout used by Apache HttpClient.. apparently not by restTemplate
ReadTimeout: 30000
eureka:
client:
#Region where eureka is deployed -For AWS specify one of the AWS regions, for other datacenters specify a arbitrary string
#indicating the region.This is normally specified as a -D option (eg) -Deureka.region=us-east-1
region: default
#For eureka clients running in eureka server, it needs to connect to servers in other zones
preferSameZone: false
us-east-1:
availabilityZones: default
instance:
#Virtual host name by which the clients identifies this service
virtualHostName: ${spring.application.name}
appGroupName: ericGroup
# disable Ribbon's cicruit breaker and rely soley on Hystrix.
# this helps to avoid confusion.
# see https://github.com/Netflix/ribbon/issues/15
niws:
loadbalancer:
availabilityFilteringRule:
filterCircuitTripped: false
Herkes ben restTemplate varsayılan zaman aşımı değiştirmek için bu kadar set gerekenleri özellikleri biliyorum: içeren application.properties ile
`@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableConfigurationProperties
@EnableHystrix
@EnableEurekaClient
public class Application { ... public static void main(String[] args) {} ... }
@Component
class EricComponentToDoHystrix { // apparently this has to be a component for hystrix to work btw
@Autowired
RestTemplate restTemplate;
..
@HystrixCommand(fallbackMethod="defaultRestTemplateCall")
public void doRestTemplateCall()
ResponseEntity<String> result = restTemplate.getForEntity("http://someservice/doSomething", String.class); // actually make a call
..
}
}`
? Dokümantasyon bu konuda çok açık ve kod yakın bir zamanda, restTemplate'in şerit/eureka yay önyükleme varsayılanlarına karşı kullanılmasına izin verilmiş gibi görünüyor. Belki de bu henüz inşa edilmemiştir.
İkinize de çok hızlı cevap verdiğiniz için teşekkür ederiz! Hem bu hem de @ spencergibb'in cevabı bana yardımcı oldu. Ribonun konfigürasyonunun RestTemplate ile hiçbir ilgisi olmadığını ve RibbonInterceptor dışındaki vanilin de test edilmesine yardımcı olacağını bilmek. Kendimi yukarıda listelendiği gibi ayarlayacağım. btw, burada oyunda başka bir zaman aşımı var ve bu da hystrix'in execution.isolation.thread.timeoutInMilliseconds. Yani şimdi oyunda 3 zaman aşımı var, Şeritler, RestTemplate ve Hystrix'ler. – RubesMN
@DaveSyer "RibbonInterceptor" RELEASE sürümünde kaybolmuş gibi görünüyor. Beni şimdi RestTemplate'i nasıl yapılandıracağınıza yönlendirebilir misiniz? –
'LoadBalancerInterceptor' ı deneyin. –