You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/02/19 07:59:58 UTC

(james-project) branch master updated (49255f7a77 -> d4bf925441)

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


    from 49255f7a77 [UPDATE] sslcontext-kickstart-for-pem to match BC version in #1975
     new 74e17d08ae [RABBITMQ] Prevent some class cast
     new d4bf925441 [RABBITMQ] Reactify some RabbitMQ related health checks

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../rabbitmq/RabbitMQConnectionFactory.java        |  3 +++
 .../events/RabbitEventBusConsumerHealthCheck.java  |  2 --
 .../RabbitMQMailQueueConsumerHealthCheck.java      | 23 +++++++++-------------
 3 files changed, 12 insertions(+), 16 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org


(james-project) 02/02: [RABBITMQ] Reactify some RabbitMQ related health checks

Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d4bf925441267763a3583cd2edd2a0bf5f05cc23
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Sun Feb 11 22:14:27 2024 +0100

    [RABBITMQ] Reactify some RabbitMQ related health checks
---
 .../events/RabbitEventBusConsumerHealthCheck.java  |  2 --
 .../RabbitMQMailQueueConsumerHealthCheck.java      | 23 +++++++++-------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/event-bus/distributed/src/main/java/org/apache/james/events/RabbitEventBusConsumerHealthCheck.java b/event-bus/distributed/src/main/java/org/apache/james/events/RabbitEventBusConsumerHealthCheck.java
index ceb3c8b106..8478561121 100644
--- a/event-bus/distributed/src/main/java/org/apache/james/events/RabbitEventBusConsumerHealthCheck.java
+++ b/event-bus/distributed/src/main/java/org/apache/james/events/RabbitEventBusConsumerHealthCheck.java
@@ -34,7 +34,6 @@ import com.rabbitmq.client.Channel;
 import reactor.core.publisher.Mono;
 
 public class RabbitEventBusConsumerHealthCheck implements HealthCheck {
-    public static final ComponentName COMPONENT_NAME = new ComponentName("EventbusConsumersHealthCheck");
     public static final String COMPONENT = "EventbusConsumers";
 
     private final RabbitMQEventBus eventBus;
@@ -57,7 +56,6 @@ public class RabbitEventBusConsumerHealthCheck implements HealthCheck {
     public Mono<Result> check() {
         return connectionPool.getResilientConnection()
             .map(Throwing.function(connection -> {
-
                 try (Channel channel = connection.createChannel()) {
                     return check(channel);
                 }
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueConsumerHealthCheck.java b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueConsumerHealthCheck.java
index c3b3a44a18..e66fc7a0ca 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueConsumerHealthCheck.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueConsumerHealthCheck.java
@@ -27,10 +27,10 @@ import org.apache.james.backends.rabbitmq.SimpleConnectionPool;
 import org.apache.james.core.healthcheck.ComponentName;
 import org.apache.james.core.healthcheck.HealthCheck;
 import org.apache.james.core.healthcheck.Result;
-import org.apache.james.util.ReactorUtils;
 
 import com.github.fge.lambdas.Throwing;
 import com.rabbitmq.client.Channel;
+import com.rabbitmq.client.Connection;
 
 import reactor.core.publisher.Mono;
 import reactor.core.scheduler.Schedulers;
@@ -58,14 +58,13 @@ public class RabbitMQMailQueueConsumerHealthCheck implements HealthCheck {
     @Override
     public Mono<Result> check() {
         return connectionPool.getResilientConnection()
-            .map(Throwing.function(connection -> {
-                try (Channel channel = connection.createChannel()) {
-                    return check(channel);
-                }
-            })).subscribeOn(ReactorUtils.BLOCKING_CALL_WRAPPER);
+            .flatMap(connection -> Mono.using(connection::createChannel,
+                channel -> check(connection, channel),
+                Throwing.consumer(Channel::close)))
+            .subscribeOn(Schedulers.boundedElastic());
     }
 
-    private Result check(Channel channel) {
+    private Mono<Result> check(Connection connection, Channel channel) {
         boolean queueWithoutConsumers = queueFactory.listCreatedMailQueues()
             .stream()
             .map(org.apache.james.queue.api.MailQueueName::asString)
@@ -74,14 +73,10 @@ public class RabbitMQMailQueueConsumerHealthCheck implements HealthCheck {
             .anyMatch(Throwing.predicate(queue -> channel.consumerCount(queue) == 0));
 
         if (queueWithoutConsumers) {
-            reconnectionHandlers.forEach(r -> connectionPool.getResilientConnection()
-                .flatMap(c -> Mono.from(r.handleReconnection(c)))
-                .subscribeOn(Schedulers.boundedElastic())
-                .block());
-
-            return Result.degraded(COMPONENT, "No consumers");
+            return Mono.fromRunnable(() -> reconnectionHandlers.forEach(r -> r.handleReconnection(connection)))
+                .thenReturn(Result.degraded(COMPONENT, "No consumers"));
         } else {
-            return Result.healthy(COMPONENT);
+            return Mono.just(Result.healthy(COMPONENT));
         }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org


(james-project) 01/02: [RABBITMQ] Prevent some class cast

Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 74e17d08ae7b1c1c783619328018c8406ee6adc1
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Sun Feb 11 22:11:37 2024 +0100

    [RABBITMQ] Prevent some class cast
---
 .../org/apache/james/backends/rabbitmq/RabbitMQConnectionFactory.java  | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConnectionFactory.java
index e38f52430c..18732ab32f 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConnectionFactory.java
@@ -87,6 +87,9 @@ public class RabbitMQConnectionFactory {
                 setupSslConfiguration(connectionFactory);
             }
 
+            // CF https://github.com/rabbitmq/rabbitmq-java-client/issues/708 causes class cast exceptions
+            connectionFactory.setChannelShouldCheckRpcResponseType(true);
+
             return connectionFactory;
         } catch (Exception e) {
             throw new RuntimeException(e);


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org