From c291664a69c1b44cfda708c831fe02726f38fecc Mon Sep 17 00:00:00 2001 From: alexsilaghi Date: Tue, 12 Nov 2024 11:25:33 +0200 Subject: [PATCH] changed concurrency. removed channel transacted --- pom.xml | 2 +- .../webprotege/ipc/impl/RabbitMqConfiguration.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 63fc33e..fd35ddb 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ edu.stanford.protege webprotege-ipc - 1.0.3 + 1.0.6 webprotege-ipc Inter Process Communication framework diff --git a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java index f425d9f..b9aa33a 100644 --- a/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java +++ b/src/main/java/edu/stanford/protege/webprotege/ipc/impl/RabbitMqConfiguration.java @@ -94,7 +94,11 @@ public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { @Bean(name = "asyncRabbitTemplate") @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public AsyncRabbitTemplate asyncRabbitTemplate(@Qualifier("rabbitTemplate") RabbitTemplate rabbitTemplate, SimpleMessageListenerContainer replyListenerContainer) { - return new AsyncRabbitTemplate(rabbitTemplate, replyListenerContainer, getCommandResponseQueue()); + var asyncRabbitTemplate = new AsyncRabbitTemplate(rabbitTemplate, + replyListenerContainer, + getCommandResponseQueue()); + asyncRabbitTemplate.setReceiveTimeout(rabbitMqTimeout); + return asyncRabbitTemplate; } @@ -105,6 +109,8 @@ public SimpleMessageListenerContainer replyListenerContainer(ConnectionFactory c SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setQueues(replyQueue); + container.setChannelTransacted(false); + container.setConcurrency("15-20"); return container; } @@ -120,7 +126,9 @@ public SimpleMessageListenerContainer messageListenerContainers() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setQueueNames(getCommandQueue()); container.setConnectionFactory(connectionFactory); + container.setChannelTransacted(false); container.setMessageListener(rabbitMqCommandHandlerWrapper()); + container.setConcurrency("15-20"); return container; } @@ -128,7 +136,7 @@ public SimpleMessageListenerContainer messageListenerContainers() { @ConditionalOnProperty(prefix = "webprotege.rabbitmq", name = "commands-subscribe", havingValue = "true", matchIfMissing = true) public void createBindings() { try (Connection connection = connectionFactory.createConnection(); - Channel channel = connection.createChannel(true)) { + Channel channel = connection.createChannel(false)) { channel.exchangeDeclare(COMMANDS_EXCHANGE, "direct", true); channel.queueDeclare(getCommandQueue(), true, false, false, null); channel.queueDeclare(getCommandResponseQueue(), true, false, false, null);