Skip to content

Commit 43bb0fe

Browse files
vishnu-alapatiVishnu
andauthored
Made changes to create a new channel when it is closed while publishing (#263)
Co-authored-by: Vishnu <vishnu.alapati@ericsson.com>
1 parent 9267287 commit 43bb0fe

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 2.0.28
22
- Made changes to override AMQP Basic properties.
33
- Swagger don't display default status codes
4+
- Made changes to create a new RabbitMQ Channel when it is closed in the middle of publishing.
45

56
## 2.0.27
67
- Degraded the spring-boot-maven-plugin version to 2.7.5

publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,20 @@ private Channel giveMeRandomChannel() throws RemRemPublishException {
540540
if ((rabbitConnection == null || !rabbitConnection.isOpen())) {
541541
createRabbitMqConnection();
542542
}
543-
return rabbitChannels.get(random.nextInt(rabbitChannels.size()));
543+
for (Channel channel : rabbitChannels) {
544+
if (channel.isOpen()) {
545+
return channel;
546+
}
547+
}
548+
try {
549+
Channel channel = rabbitConnection.createChannel();
550+
channel.confirmSelect();
551+
rabbitChannels.add(channel);
552+
return channel;
553+
} catch (IOException e) {
554+
log.error(e.getMessage(), e);
555+
throw new RemRemPublishException("Failed to create new channel for Rabbitmq :: ",
556+
factory, e);
557+
}
544558
}
545-
546559
}

0 commit comments

Comments
 (0)