Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
schmika committed Dec 14, 2023
1 parent 5c79d61 commit fdad0be
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void reject(Envelope envelope, boolean requeue) {
}

public Message receive(String queueName, boolean autoAck) throws InvalidMessageException {
GetResponse response = (GetResponse) execute(commands.basicGet(queueName, autoAck));
GetResponse response = execute(commands.basicGet(queueName, autoAck));
if (response == null) {
return null;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public void bindQueue(String name, String exchange, String routingKey) {
}

public Long getMessageCount(String queue) {
return (Long) execute(commands.messageCount(queue));
return execute(commands.messageCount(queue));
}

public boolean isChannelAvailable() {
Expand All @@ -185,7 +185,7 @@ public AMQP.Queue.PurgeOk queuePurge(String name) {
return (AMQP.Queue.PurgeOk) execute(commands.queuePurge(name));
}

private Object execute(ChannelCommand channelCommand) {
private <T> T execute(ChannelCommand<T> channelCommand) {
// The channel might not be available or become unavailable due to a connection error. In this
// case, we wait until the connection becomes available again.
while (true) {
Expand Down

0 comments on commit fdad0be

Please sign in to comment.