diff --git a/build.gradle.kts b/build.gradle.kts index 15c73f56..516dc46e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ @Suppress("PropertyName") -var VERSION = "3.6.1.8-SNAPSHOT" +var VERSION = "3.6.1.8" plugins { // needed for the allprojects section to work id("java") diff --git a/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQAPI.java b/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQAPI.java index 11955dfe..33581583 100644 --- a/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQAPI.java +++ b/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQAPI.java @@ -7,6 +7,8 @@ import com.kamikazejam.kamicommon.amqp.data.RabbitStdConsumer; import com.rabbitmq.client.AMQP; import com.rabbitmq.client.BuiltinExchangeType; +import com.rabbitmq.client.Channel; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import java.util.concurrent.CompletableFuture; @@ -169,4 +171,41 @@ public void publishFanout(@NotNull String exchangeName, @NotNull AMQP.BasicPrope manager.declareExchange(exchangeName, BuiltinExchangeType.FANOUT); manager.publishFanout(exchangeName, props, message); } + + /** + * Declares a queue with a default TTL of 60 seconds (iff not declared already) + * @param queueName the name of the queue to declare + */ + public void declareQueue(@NotNull String queueName) { + this.manager.declareQueue(queueName); + } + + /** + * Declares a queue with a specified TTL (iff not declared already) + * @param queueName the name of the queue to declare + * @param TTL_MS the time-to-live of the queue (in milliseconds) + */ + public void declareQueue(@NotNull String queueName, long TTL_MS) { + this.manager.declareQueue(queueName, TTL_MS); + } + + /** + * Declares a queue with a specified TTL (iff not declared already) + * @param queueName the name of the queue to declare + * @param durable whether the queue should survive a broker restart + * @param exclusive whether the queue should be exclusive to the connection + * @param autoDelete whether the queue should be auto-deleted when no longer in use + * @param TTL_MS the time-to-live of the queue (in milliseconds) + */ + public void declareQueue(@NotNull String queueName, boolean durable, boolean exclusive, boolean autoDelete, long TTL_MS) { + this.manager.declareQueue(queueName, durable, exclusive, autoDelete, TTL_MS); + } + + /** + * Get the underlying RabbitMQ {@link Channel} for direct access + */ + @ApiStatus.Internal + public @NotNull Channel getChannel() { + return this.manager.getChannel(); + } } diff --git a/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQManager.java b/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQManager.java index f31b50cc..c533e167 100644 --- a/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQManager.java +++ b/shared-jar/src/main/java/com/kamikazejam/kamicommon/amqp/RabbitMQManager.java @@ -84,7 +84,7 @@ private Connection getConnection() { } @ApiStatus.Internal - private Channel getChannel() { + protected Channel getChannel() { if (channel == null || !channel.isOpen()) { try { channel = getConnection().createChannel();