我正在努力注册我的节点应用程序,使用Netflix的Eureka,在谷歌搜索后,我仍在寻找解决方案.我能想到的最大值是我们有Prana但是我遇到的问题仍然在Prana的问题列表中(我猜这意味着我的REST模板无法发现这个应用程序).
Sidecar,是另一个建议的解决方案,我没有得到任何回应.除了这两个,我找到了一个节点模块Eureka-Node-client,但它们都没有达到我的目的.
我正在尝试Spring Cloud和Spring Boot.它使用Netflix OSS应用程序,其中有Ribbon和Hystrix.
色带是负载平衡器,具有一些功能,其中一个是断路器.
Hystrix是一种断路器应用.
我不知道他们俩之间的区别.如果Ribbon已经带有断路器功能,为什么要使用Hystrix.
我可以在同一个连接器中使用这两个应用程序
我研究 spring cloud eureka,cloud 并且它们工作得很好。但是在eureka服务中添加了安全性后,却遇到了一些错误。
所有代码和错误细节都在https://github.com/keryhu/eureka-security
eureka 服务 application.yml
security:
user:
name: user
password: password
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
wait-time-in-ms-when-sync-empty: 0
Run Code Online (Sandbox Code Playgroud)
和 config-service application.java
@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
Run Code Online (Sandbox Code Playgroud)
配置服务应用程序.yml
eureka:
client:
registry-fetch-interval-seconds: 5
serviceUrl:
defaultZone: http://user:password@${domain.name:localhost}:8761/eureka/
spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
basedir: target/config
Run Code Online (Sandbox Code Playgroud)
启动config-service后有错误导出:
2016-04-10 11:22:39.402 ERROR 80526 --- [get_localhost-3] c.n.e.cluster.ReplicationTaskProcessor : Batch update failure with HTTP status code 401; discarding 1 replication tasks
2016-04-10 11:22:39.402 WARN 80526 --- [get_localhost-3] c.n.eureka.util.batcher.TaskExecutors : Discarding 1 tasks …Run Code Online (Sandbox Code Playgroud) spring spring-security spring-cloud netflix-eureka spring-cloud-netflix
是否可以延长正在传输的消息的可见时间。
看:
http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html。
部分:更改消息的可见性超时。
总之,我希望能够延长正在运行的给定消息的第一组可见性超时。
例如,如果 15 秒过去了,我想将超时再延长 20 秒。上面的 java 文档中有更好的例子。
根据我对上面链接的理解,您可以在亚马逊方面执行此操作。
以下是我当前的设置;
SqsMessageDrivenChannelAdapter adapter =
new SqsMessageDrivenChannelAdapter(queue);
adapter.setMessageDeletionPolicy(SqsMessageDeletionPolicy.ON_SUCCESS);
adapter.setMaxNumberOfMessages(1);
adapter.setSendTimeout(2000);
adapter.setVisibilityTimeout(200);
adapter.setWaitTimeOut(20);
Run Code Online (Sandbox Code Playgroud)
是否可以延长这个超时时间?
我有两个微服务(在 eureka 服务器上注册)。第一个服务使用 FeignA对第二个服务进行 http 调用B。在A我创建了一个
@FeignClient(name="${name-of-service-B}", configuration=FeignConfig.class)
public interface ServiceBProxy
{
@GetMapping("/B/endpoint")
ResponseEntity<String> foo()
}
Run Code Online (Sandbox Code Playgroud)
当两个服务都启动时,一切正常。
问题:当我关闭服务时B,A抛出以下根异常
2018-08-13 18:14:23.088 WARN 15892 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
....
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
Run Code Online (Sandbox Code Playgroud)
这是完整的堆栈跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean …Run Code Online (Sandbox Code Playgroud) 我是 Spring Cloud Gateway 的新手,我想要的是将传入请求记录到相应的路由 url,例如,如果我有以下路由配置:
- id: route1
uri: http://localhost:8585/
predicates:
- Path=/foo/**
filters:
- RewritePath=/foo/(?<segment>.*), /$\{segment}
Run Code Online (Sandbox Code Playgroud)
然后对于“ http://localhost:8080/foo/route1 ”的传入请求,应打印以下日志消息。
“传入请求 url ' http://localhost:8080/foo/route1 ' 被路由到 ' http://localhost:8585/route1 '”
有什么简单的方法可以实现这一点,或者我可以通过设置日志级别来实现这一点。
你能帮忙吗
我使用的是 spring boot 版本 - 2.0.6.RELEASE 和 spring cloud 版本 - Finchley.SR2
我已经创建了我的自定义网关过滤器来修改请求正文。
但是在使用 Flux 将请求正文转换为字符串时,我得到了一个空字符串。我需要一种方法来获取与我的请求正文对应的字符串。
@Override
public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = (ServerHttpRequest) exchange.getRequest();
String s = resolveBodyFromRequest(request);
/* s comes out to be "" */
return chain.filter(newExchange);
}
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest){
//Get the request body
Flux<DataBuffer> body = serverHttpRequest.getBody();
StringBuilder sb = new StringBuilder();
body.subscribe(buffer -> {
byte[] bytes = new byte[buffer.readableByteCount()];
buffer.read(bytes);
DataBufferUtils.release(buffer);
String bodyString = new String(bytes, StandardCharsets.UTF_8);
sb.append(bodyString);
});
return …Run Code Online (Sandbox Code Playgroud) 我正在使用spring-cloud-starter-openfeignclient 编写 Eureka 客户端应用程序。这是我的POM
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>service-registration-and-discovery-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>service-registration-and-discovery-client</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> …Run Code Online (Sandbox Code Playgroud) spring-cloud netflix-eureka spring-cloud-feign feign openfeign
只需添加 spring-cloud-starter-zipkin 也能够生成 spanId 和 TraceId 那么 Sleuth 需要什么?spring-cloud-starter-zipkin 实际上是自己拉 io.zipkin.brave 而不是 Sleuth。
我正在努力为 springboot Rest api 设置wiremock,并使用 spring cloud 中的放心和 spring-cloud-starter-contract-stub-runner 。当我运行示例集成测试时,我遇到模块冲突错误
spring-cloud ×10
spring-boot ×4
spring ×3
aws-sdk ×1
feign ×1
hystrix ×1
java ×1
netflix ×1
node.js ×1
openfeign ×1
rest-assured ×1
wiremock ×1
zipkin ×1