Skip to content

Commit f64b602

Browse files
committed
Fix code smell in the JdbcChannelMessageStore
* Refine JavaDocs in the `JdbcChannelMessageStore`
1 parent 5ec8913 commit f64b602

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,14 @@
6565
* database via JDBC.
6666
*
6767
* This message store shall be used for message channels only.
68-
* </p>
6968
* <p>
7069
* As such, the {@link JdbcChannelMessageStore} uses database specific SQL queries.
71-
* </p>
7270
* <p>
7371
* Contrary to the {@link JdbcMessageStore}, this implementation uses a single database table,
7472
* optimized to operate like a queue.
7573
* The SQL scripts for creating the table are packaged
7674
* under {@code org/springframework/integration/jdbc/schema-*.sql},
7775
* where {@code *} denotes the target database type.
78-
* </p>
7976
*
8077
* @author Gunnar Hillert
8178
* @author Artem Bilan
@@ -114,6 +111,8 @@ private enum Query {
114111
DELETE_MESSAGE
115112
}
116113

114+
private final Map<Query, String> queryCache = new ConcurrentHashMap<>();
115+
117116
private final Set<String> idCache = new HashSet<>();
118117

119118
private final ReadWriteLock idCacheLock = new ReentrantReadWriteLock();
@@ -140,8 +139,6 @@ private enum Query {
140139

141140
private ChannelMessageStorePreparedStatementSetter preparedStatementSetter;
142141

143-
private final Map<Query, String> queryCache = new ConcurrentHashMap<>();
144-
145142
private MessageGroupFactory messageGroupFactory = new SimpleMessageGroupFactory();
146143

147144
private boolean usingIdCache = false;
@@ -229,7 +226,7 @@ public void setLobHandler(LobHandler lobHandler) {
229226
}
230227

231228
/**
232-
* Allows for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper}
229+
* Allow for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper}
233230
* is used to convert the selected database row representing the persisted
234231
* message into the actual {@link Message} object.
235232
* @param messageRowMapper Must not be null
@@ -252,7 +249,7 @@ public void setPreparedStatementSetter(ChannelMessageStorePreparedStatementSette
252249
}
253250

254251
/**
255-
* Sets the database specific {@link ChannelMessageStoreQueryProvider} to use.
252+
* Set the database specific {@link ChannelMessageStoreQueryProvider} to use.
256253
* The {@link JdbcChannelMessageStore} provides the SQL queries to retrieve messages from
257254
* the database. See the JavaDocs {@link ChannelMessageStoreQueryProvider} (all known
258255
* implementing classes) to see those implementations provided by the framework.
@@ -269,7 +266,7 @@ public void setChannelMessageStoreQueryProvider(ChannelMessageStoreQueryProvider
269266
/**
270267
* A unique grouping identifier for all messages persisted with this store.
271268
* Using multiple regions allows the store to be partitioned (if necessary)
272-
* for different purposes. Defaults to <code>{@link #DEFAULT_REGION}</code>.
269+
* for different purposes. Defaults to {@link #DEFAULT_REGION}.
273270
* @param region the region name to set
274271
*/
275272
public void setRegion(String region) {
@@ -333,7 +330,7 @@ public void setTablePrefix(String tablePrefix) {
333330
* </int:poller>
334331
* }
335332
* </pre>
336-
* @param usingIdCache When <code>true</code> the id cache will be used.
333+
* @param usingIdCache When {@code true} the id cache will be used.
337334
*/
338335
public void setUsingIdCache(boolean usingIdCache) {
339336
this.usingIdCache = usingIdCache;
@@ -439,9 +436,8 @@ public MessageGroup getMessageGroup(Object groupId) {
439436
}
440437

441438
/**
442-
* Method not implemented.
439+
* Return the number of message groups in the store for configured region.
443440
* @return The message group count.
444-
* @throws UnsupportedOperationException Method not supported.
445441
*/
446442
@ManagedAttribute
447443
public int getMessageGroupCount() {
@@ -465,7 +461,7 @@ protected String getQuery(Query queryName, Supplier<String> queryProvider) {
465461
}
466462

467463
/**
468-
* Returns the number of messages persisted for the specified channel id (groupId)
464+
* Return the number of messages persisted for the specified channel id (groupId)
469465
* and the specified region ({@link #setRegion(String)}).
470466
* @return The message group size.
471467
*/
@@ -488,7 +484,7 @@ public void removeMessageGroup(Object groupId) {
488484
}
489485

490486
/**
491-
* Polls the database for a new message that is persisted for the given
487+
* Poll the database for a new message that is persisted for the given
492488
* group id which represents the channel identifier.
493489
*/
494490
@Override
@@ -582,21 +578,20 @@ private boolean doRemoveMessageFromGroup(Object groupId, Message<?> messageToRem
582578

583579
boolean result = updated != 0;
584580
if (result) {
585-
LOGGER.debug(LogMessage.format("Message with id '%s' was deleted.", id));
581+
LOGGER.debug(() -> "Message with id '" + id + "' was deleted.");
586582
}
587583
else {
588-
LOGGER.warn(LogMessage.format("Message with id '%s' was not deleted.", id));
584+
LOGGER.warn(() -> "Message with id '" + id + "' was not deleted.");
589585
}
590586
return result;
591587
}
592588

593589
/**
594-
* <p>Remove a Message Id from the idCache. Should be used in conjunction
590+
* Remove a Message Id from the idCache. Should be used in conjunction
595591
* with the Spring Integration Transaction Synchronization feature to remove
596592
* a message from the Message Id cache once a transaction either succeeded or
597-
* rolled back.</p>
598-
* <p>Only applicable if {@link #setUsingIdCache(boolean)} is set to
599-
* <code>true</code></p>.
593+
* rolled back.
594+
* Only applicable if {@link #setUsingIdCache(boolean)} is set to{@code true}.
600595
* @param messageId The message identifier.
601596
*/
602597
public void removeFromIdCache(String messageId) {
@@ -611,7 +606,7 @@ public void removeFromIdCache(String messageId) {
611606
}
612607

613608
/**
614-
* Returns the size of the Message Id Cache, which caches Message Ids for
609+
* Return the size of the Message Id Cache, which caches Message Ids for
615610
* those messages that are currently being processed.
616611
* @return The size of the Message Id Cache
617612
*/

0 commit comments

Comments
 (0)