Java RabbitMQ连接在调用通道后关闭。关闭()

Java RabbitMQ连接在调用通道后关闭。关闭(),java,rabbitmq,Java,Rabbitmq,我正在使用Java RabbitMQ客户端。我发布一条消息(basicPublish),然后关闭频道。在使用者中,channel.basicAck抛出异常: com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; cause: java.util.concurrent.RejectedExecutionException: Task com.rabbitmq

我正在使用Java RabbitMQ客户端。我发布一条消息(basicPublish),然后关闭频道。在使用者中,channel.basicAck抛出异常:

com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; cause: java.util.concurrent.RejectedExecutionException: Task com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable@665de7c7 rejected from java.util.concurrent.ThreadPoolExecutor@35f53993[Running, pool size = 5, active threads = 5, queued tasks = 0, completed tasks = 5]
如果删除channel.close(),则不会再现错误。当我关闭频道时,为什么连接关闭

已向exchange发送邮件:

Channel channel = connection.createChannel();
Set<String> expectedMessages = new HashSet<>(MESSAGES_COUNT);
for (int i = 0; i < MESSAGES_COUNT; i++) {
    String message = Integer.toString(i);
    channel.basicPublish(
        TEST_EXCHANGE,
        ROUTE_KEY,
        TEXT_PLAIN,
        message.getBytes("UTF-8")
    );
    expectedMessages.add(message);
}
channel.close();

问题出在错误的connectionFactory设置中。 不正确:

    executorService = new ThreadPoolExecutor(
            properties.minThreads, properties.maxThreads,
            properties.maxThreadIdle, TimeUnit.SECONDS,
            new SynchronousQueue<>()
    );
    connectionFactory.setSharedExecutor(executorService);
executorService=新线程池执行器(
properties.minThreads、properties.maxThreads、,
properties.maxThreadIdle,TimeUnit.SECONDS,
新的SynchronousQueue()
);
连接工厂。设置共享执行器(执行器服务);
对于正确的工作:

    executorService = new ThreadPoolExecutor(
            properties.minThreads, properties.maxThreads,
            properties.maxThreadIdle, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>()
    );
    connectionFactory.setSharedExecutor(executorService);
executorService=新线程池执行器(
properties.minThreads、properties.maxThreads、,
properties.maxThreadIdle,TimeUnit.SECONDS,
新建LinkedBlockingQueue()
);
连接工厂。设置共享执行器(执行器服务);

当您关闭频道但未关闭连接时,您的代码中可能存在另一个错误。这种行为的原因是什么?我不能关闭频道吗?没有代码很难知道!
    executorService = new ThreadPoolExecutor(
            properties.minThreads, properties.maxThreads,
            properties.maxThreadIdle, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>()
    );
    connectionFactory.setSharedExecutor(executorService);