Spring Cloud AWS (1.0.0.RC2) 中 SimpleMessageListenerContainer 类的当前实现似乎会在消息处理程序完成消息处理并且方法调用返回后自动删除消息。
在我们的应用程序中,我们需要能够处理消息并等待下游队列的异步确认,然后再从 SQS 上游队列中删除消息。就像是
接收SQS消息 -> 处理消息 -> 发布消息到RabbitMQ(线程在此完成)
删除 SQS 消息 <- 我们的应用 <- RabbitMQ 消息成功 Ack(异步)
由于消息确认通过不同的线程异步返回,因此我们需要在检查成功确认后手动从 SQS 删除消息的选项。
理想情况下,SimpleMessageListener 应可配置其运行模式(自动删除或手动删除)。
我们非常希望使用 spring aws 云库(而不是推出我们自己的)来与 SQS 集成,因为它已经负责侦听器容器 bean 生命周期管理。
请告诉我上述建议的功能是否可行,如果可行,何时可以实施和发布。
谢谢。
我目前正在使用 STS 3.6.3SR1 和 Spring 4.1.4。尝试测试 spring-cloud-aws 在我们的应用程序中使用的可行性。
与问题相关的罐子:
spring-cloud-aws-autoconfigure-1.0.0.RC2.jar
spring-cloud-aws-context-1.0.0.RC2.jar
spring-cloud-aws-core-1.0.0.RC2.jar
spring-cloud-aws-messaging-1.0.0.RC2.jar
使用aws-sdk-1.9.3
目前我的 xml 上下文文件中有这个。
<mvc:annotation-driven>
<mvc:argument-resolvers>
<ref bean="notificationResolver"/>
</mvc:argument-resolvers>
</mvc:annotation-driven>
<aws-messaging:notification-argument-resolver id="notificationResolver" />
<aws-messaging:notification-messaging-template id="notificationMessagingTemplate" default-destination="snsChannelTopic"/>
Run Code Online (Sandbox Code Playgroud)
目前已将此控制器类定义为我的端点。
public class AmazonSNSController {
@Autowired
HttpServletRequest request;
@Autowired
HttpServletResponse response;
@NotificationSubscriptionMapping
public void handleSubscriptionMessage(SnsHelper status) throws IOException {
//We subscribe to start receive the message
status.setRequest(request);
status.setResponse(response);
status.confirmSubscription();
}
@NotificationMessageMapping
public void handleNotificationMessage(@NotificationSubject String subject, @NotificationMessage String message) {
System.out.println(subject + message);
}
@NotificationUnsubscribeConfirmationMapping
public void handleUnsubscribeMessage(SnsHelper status) {
//e.g. …Run Code Online (Sandbox Code Playgroud) 我正在寻找使用 Spring Boot 实现一个简单的反向代理,即:
我查看了注释提供的功能@EnableZuulProxy,但它似乎太重量级了,因为我不想使用 Eureka、Ribbon 或 Hystrix。然而,@EnableZuulServer配置有点轻。
有人能提供一个我所追求的例子吗?Netflix Zuul 是正确的选择吗?还是还有其他我应该考虑的库?
谢谢!
我正在尝试使用 BitBucket 私有存储库设置 Spring Cloud 的配置服务器,但没有任何运气。无论我使用什么配置,在尝试加载配置时似乎总是返回 404。
我也尝试过在 中设置断点JGitEnvironmentRepository,但似乎从未在afterPropertiesSet. 如果我在调试时手动触发findOne(application,profile,label),则会收到错误消息Branch name <null> not allowed。如果我为属性指定“master” label,那么我会收到可怕的Ref master cannot be resolved错误。
该应用程序加载正常,但没有结果。从我读过的所有文档来看,这似乎应该是开箱即用的。任何帮助,将不胜感激。
bootstrap.yml
server:
port: 8888
spring:
application:
name: config-service
cloud:
bus.amqp.enabled: false
config:
enabled: false
failFast: true
server:
prefix: /configs
git :
uri: https://bitbucket.org/[team]/[repo].git
username: [user]
password: [pass]
Run Code Online (Sandbox Code Playgroud)
回购文件
- demo.app.yml
Run Code Online (Sandbox Code Playgroud)
尝试的网址
我有配置服务器,应用程序从该服务器获取配置。我想设置抓取的重试机制。如果配置服务器不可用,应用程序应发送 10 分钟的请求。
在 spring 文档中我找到了下一个配置
spring.cloud.config.uri=http://localhost:9090
spring.cloud.config.fail-fast=true
spring.cloud.config.retry.max-interval=10000
spring.cloud.config.retry.max-attempts=2000
Run Code Online (Sandbox Code Playgroud)
但他们什么也改变不了。我的应用程序不执行重试请求,它只是失败了
Caused by: java.net.ConnectException: Connection refused: connect
Run Code Online (Sandbox Code Playgroud)
(配置服务器此时已关闭)
我究竟做错了什么?有办法解决我的问题吗?
我正在尝试使用 Spring boot CLI (1.5.7) 加密密码。
./spring encrypt mysecret --key ashish
Run Code Online (Sandbox Code Playgroud)
我收到此命令的以下错误:
'encypt' is not a valid command. See 'help'.
Run Code Online (Sandbox Code Playgroud)
请让我知道如何解决这个问题。
我在我的应用程序中使用Spring boot 1.5.15。我添加了Redis作为缓存服务器的缓存支持,并使用 Spring Caching 注释来处理缓存操作。
使用 Spring Caching 和 Redis ,无法为我使用的每个缓存提供单独的过期时间。
因此,我自定义了 CacheManager bean,如下所示,并创建了一个配置类来获取我使用的各个缓存的 yaml 文件中的过期值。
@Bean
@RefreshScope
public CacheManager cacheManager() {
RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
cacheManager.setUsePrefix(true);
List<CacheConfig> cacheConfigList = appConfig.getCacheConfig();
if (null != cacheConfigList && cacheConfigList.size() > 0) {
cacheManager.setExpires(getCacheExpirySecondsMap(cacheConfigList));
}
return cacheManager;
}
public Map<String, Long> getCacheExpirySecondsMap(List<CacheConfig> cacheConfigList) {
Map<String, Long> cacheConfigMap = cacheConfigList.stream()
.collect(Collectors.toMap(x -> x.getName(), x -> x.getExpirySeconds()));
return cacheConfigMap;
}
Run Code Online (Sandbox Code Playgroud)
我的 CacheConfig bean 有以下字段,
String name;
Long expirySeconds;
Run Code Online (Sandbox Code Playgroud)
我的 …
redis spring-boot spring-cloud spring-boot-actuator spring-cloud-config
Host我需要 Spring Cloud Gateway 根据标头或路径前缀将请求路由到微服务。在任何情况下,都必须从路径中删除路径前缀,但前提是已设置路径前缀。
我想出了以下代码,我认为只有“sip”是前缀:
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route(r -> r.host("sip")
.or()
.path("/sip/**")
.filters(f -> f.stripPrefix(1))
.uri("http://sip:8080")
)
.build();
}
Run Code Online (Sandbox Code Playgroud)
问题是 Spring 会删除路径的第一段,即使它不是前缀。
例如,具有路径的请求/sip/calls会成功,但/calls设置了 Host 标头则不会成功,因为 Spring 会考虑/calls前缀并将其删除,从而导致路径为空。/calls/calls带有标头的路径Host会成功,因为 Spring 仅删除第一个calls路径段。
如何一起使用主机和路径,仅在与定义的值匹配时才删除前缀?
ps 我正在考虑每个服务有两条路线,但它看起来不太好,尽管它实现了目标:
.route(r -> r.header("Host", "form").uri("http://form:8080"))
.route(r -> r.path("/form/**")
.filters(f -> f.stripPrefix(1))
.uri("http://form:8080"))
Run Code Online (Sandbox Code Playgroud) 我正在从链接开发代码: https: //howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/当我更新Spring Boot版本2.1.2.RELEASE pom.xml 时给了我以下错误。
项目构建错误:org.springframework.cloud:spring-cloud-starter-config:jar 的“dependency.dependency.version”丢失。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我很困惑何时使用spring cloud config server和consul。两者都会以自己的方式读取配置文件。你能告诉我什么时候使用spring cloud 配置服务器以及什么时候使用consul吗?
spring-cloud ×10
spring-boot ×5
spring ×4
java ×3
amazon-sns ×1
consul ×1
git ×1
kotlin ×1
netflix ×1
netflix-zuul ×1
redis ×1