Skip to content

Commit 0865abe

Browse files
committed
Expose current cached session count
Closes gh-26811
1 parent 90af2d5 commit 0865abe

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -179,6 +179,23 @@ public boolean isCacheConsumers() {
179179
}
180180

181181

182+
/**
183+
* Return a current session count, indicating the number of sessions currently
184+
* cached by this connection factory.
185+
* @since 5.3.7
186+
*/
187+
public int getCachedSessionCount() {
188+
int count = 0;
189+
synchronized (this.cachedSessions) {
190+
for (Deque<Session> sessionList : this.cachedSessions.values()) {
191+
synchronized (sessionList) {
192+
count += sessionList.size();
193+
}
194+
}
195+
}
196+
return count;
197+
}
198+
182199
/**
183200
* Resets the Session cache as well.
184201
*/

0 commit comments

Comments
 (0)