我使用 RabbitMQ AMQP 2.2.7。我在 2 个 Spring boot 应用程序之间运行 RabbitMQ 集群。一个应用程序向另一个应用程序发送一些消息。它运行良好一段时间,但突然在过去几天,我看到使用消息的应用程序中的 MessageListener 由于某种原因出现故障(可能是主服务器节点出现故障)。
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>2.2.7.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
2020-07-22 00:26:33.007 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Stopping container from aborted consumer
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - home node 'rabbit@rad497159-mq-1.node.dc1.a9ssvc' of durable queue 'ORDER' in vhost '/' is down or inaccessible, class-id=50, method-id=10)
Caused by: java.io.IOException: null
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2020-07-22 00:26:33.005 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Consumer threw missing queues exception, fatal=true
at …Run Code Online (Sandbox Code Playgroud) 我正在读取一个文件并形成一个整数列表。
示例文件:
1 1 2 3 4
2 2 5 abc
4 2 8
Run Code Online (Sandbox Code Playgroud)
运行以下代码时会失败,因为“abc”无法转换为整数。
您能否让我知道是否可以在 Java 8 中以更清晰的方式过滤掉非整数字段,例如:使用过滤器?
try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file)))) {
List<Integer> allValues = new ArrayList<>();
br.lines().forEach(
strLine -> {
List<String> wordsList = Arrays.asList(strLine.trim().split(" "));
List<Integer> routes = wordsList.stream()
.filter(e -> e != null && !e.isEmpty())
.map(Integer::valueOf)
.collect(Collectors.toList());
allValues.addAll(routes);
});
allValues.forEach(str -> System.out.print(str));
}
Run Code Online (Sandbox Code Playgroud)