Browse Source

Expose current cached session count

Closes gh-26811
pull/26940/head
Juergen Hoeller 5 years ago
parent
commit
0865abef83
  1. 19
      spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -179,6 +179,23 @@ public class CachingConnectionFactory extends SingleConnectionFactory { @@ -179,6 +179,23 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
}
/**
* Return a current session count, indicating the number of sessions currently
* cached by this connection factory.
* @since 5.3.7
*/
public int getCachedSessionCount() {
int count = 0;
synchronized (this.cachedSessions) {
for (Deque<Session> sessionList : this.cachedSessions.values()) {
synchronized (sessionList) {
count += sessionList.size();
}
}
}
return count;
}
/**
* Resets the Session cache as well.
*/

Loading…
Cancel
Save