Skip to content

Commit 156b3aa

Browse files
committed
add durable as parameter when connecting to queues
1 parent 744740e commit 156b3aa

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

context-monitoring/src/main/java/de/atb/context/monitoring/monitors/messagebroker/util/MessageBrokerUtil.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public static Channel connectToTopicExchange(final MessageBrokerDataSource dataS
9999
* @param userName the username to use when connecting to message broker - optional
100100
* @param password the password to use when connecting to message broker - optional
101101
* @param queue the queue's name
102+
* @param durable whether the queue should be durable or not
102103
* @return a {@link Channel} object representing the established connection to the message broker
103104
* @throws IOException in case of error
104105
* @throws TimeoutException in case of error
@@ -107,13 +108,14 @@ public static Channel connectToQueue(final String host,
107108
final int port,
108109
final String userName,
109110
final String password,
110-
final String queue) throws IOException, TimeoutException {
111+
final String queue,
112+
final boolean durable) throws IOException, TimeoutException {
111113
final Connection connection = getConnection(host, port, userName, password);
112114

113115
final Channel channel = connection.createChannel();
114116

115117
LOGGER.info("Creating queue {}", queue);
116-
channel.queueDeclare(queue, true, false, false, null);
118+
channel.queueDeclare(queue, durable, false, false, null);
117119

118120
return channel;
119121
}
@@ -198,7 +200,8 @@ public static void convertAndSendToTopic(final Channel channel,
198200
/**
199201
* Converts the given {@code payload} object to a JSON string and sends it to the given {@code queue}.
200202
* <p>
201-
* Use {@link MessageBrokerUtil#connectToQueue(String, int, String, String, String)} to create {@link Channel}.
203+
* Use {@link MessageBrokerUtil#connectToQueue(String, int, String, String, String, boolean)}
204+
* to create {@link Channel}.
202205
*
203206
* @param channel the {@link Channel} object representing the established connection to the message broker
204207
* @param queue the queue's name

smartclide-monitoring/src/main/java/eu/smartclide/contexthandling/dle/listener/DleGitMonitorProgressListener.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public DleGitMonitorProgressListener(final MessageBrokerDataSource messageBroker
4646
messageBrokerDataSource.getMessageBrokerPort(),
4747
messageBrokerDataSource.getUserName(),
4848
messageBrokerDataSource.getPassword(),
49-
dleQueue
49+
dleQueue,
50+
false
5051
);
5152
}
5253

smartclide-monitoring/src/test/java/de/atb/context/monitoring/TestDataRetrieval.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ private void createFakeDleListener(final String rabbitMQContainerHost, final Int
157157
rabbitMQContainerAmqpPort,
158158
null,
159159
null,
160-
QUEUE_NAME_DLE
160+
QUEUE_NAME_DLE,
161+
false
161162
);
162163
channel.basicConsume(
163164
QUEUE_NAME_DLE,

0 commit comments

Comments
 (0)