Skip to content

Commit

Permalink
3.6.1.8
Browse files Browse the repository at this point in the history
- Added some methods to control the queue declaration in RabbitMQAPI

Took 3 minutes
  • Loading branch information
Jake-Moore committed Dec 8, 2024
1 parent fbbd26c commit 297024f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private Connection getConnection() {
}

@ApiStatus.Internal
private Channel getChannel() {
protected Channel getChannel() {
if (channel == null || !channel.isOpen()) {
try {
channel = getConnection().createChannel();
Expand Down

0 comments on commit 297024f

Please sign in to comment.