Fix code smell in the JdbcChannelMessageStore
* Refine JavaDocs in the `JdbcChannelMessageStore`
This commit is contained in:
@@ -65,17 +65,14 @@ import org.springframework.util.StringUtils;
|
||||
* database via JDBC.
|
||||
*
|
||||
* This message store shall be used for message channels only.
|
||||
* </p>
|
||||
* <p>
|
||||
* As such, the {@link JdbcChannelMessageStore} uses database specific SQL queries.
|
||||
* </p>
|
||||
* <p>
|
||||
* Contrary to the {@link JdbcMessageStore}, this implementation uses a single database table,
|
||||
* optimized to operate like a queue.
|
||||
* The SQL scripts for creating the table are packaged
|
||||
* under {@code org/springframework/integration/jdbc/schema-*.sql},
|
||||
* where {@code *} denotes the target database type.
|
||||
* </p>
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
@@ -114,6 +111,8 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
DELETE_MESSAGE
|
||||
}
|
||||
|
||||
private final Map<Query, String> queryCache = new ConcurrentHashMap<>();
|
||||
|
||||
private final Set<String> idCache = new HashSet<>();
|
||||
|
||||
private final ReadWriteLock idCacheLock = new ReentrantReadWriteLock();
|
||||
@@ -140,8 +139,6 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
|
||||
private ChannelMessageStorePreparedStatementSetter preparedStatementSetter;
|
||||
|
||||
private final Map<Query, String> queryCache = new ConcurrentHashMap<>();
|
||||
|
||||
private MessageGroupFactory messageGroupFactory = new SimpleMessageGroupFactory();
|
||||
|
||||
private boolean usingIdCache = false;
|
||||
@@ -229,7 +226,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper}
|
||||
* Allow for passing in a custom {@link MessageRowMapper}. The {@link MessageRowMapper}
|
||||
* is used to convert the selected database row representing the persisted
|
||||
* message into the actual {@link Message} object.
|
||||
* @param messageRowMapper Must not be null
|
||||
@@ -252,7 +249,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database specific {@link ChannelMessageStoreQueryProvider} to use.
|
||||
* Set the database specific {@link ChannelMessageStoreQueryProvider} to use.
|
||||
* The {@link JdbcChannelMessageStore} provides the SQL queries to retrieve messages from
|
||||
* the database. See the JavaDocs {@link ChannelMessageStoreQueryProvider} (all known
|
||||
* implementing classes) to see those implementations provided by the framework.
|
||||
@@ -269,7 +266,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
/**
|
||||
* A unique grouping identifier for all messages persisted with this store.
|
||||
* Using multiple regions allows the store to be partitioned (if necessary)
|
||||
* for different purposes. Defaults to <code>{@link #DEFAULT_REGION}</code>.
|
||||
* for different purposes. Defaults to {@link #DEFAULT_REGION}.
|
||||
* @param region the region name to set
|
||||
*/
|
||||
public void setRegion(String region) {
|
||||
@@ -333,7 +330,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
* </int:poller>
|
||||
* }
|
||||
* </pre>
|
||||
* @param usingIdCache When <code>true</code> the id cache will be used.
|
||||
* @param usingIdCache When {@code true} the id cache will be used.
|
||||
*/
|
||||
public void setUsingIdCache(boolean usingIdCache) {
|
||||
this.usingIdCache = usingIdCache;
|
||||
@@ -439,9 +436,8 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Method not implemented.
|
||||
* Return the number of message groups in the store for configured region.
|
||||
* @return The message group count.
|
||||
* @throws UnsupportedOperationException Method not supported.
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public int getMessageGroupCount() {
|
||||
@@ -465,7 +461,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of messages persisted for the specified channel id (groupId)
|
||||
* Return the number of messages persisted for the specified channel id (groupId)
|
||||
* and the specified region ({@link #setRegion(String)}).
|
||||
* @return The message group size.
|
||||
*/
|
||||
@@ -488,7 +484,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Polls the database for a new message that is persisted for the given
|
||||
* Poll the database for a new message that is persisted for the given
|
||||
* group id which represents the channel identifier.
|
||||
*/
|
||||
@Override
|
||||
@@ -582,21 +578,20 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
|
||||
boolean result = updated != 0;
|
||||
if (result) {
|
||||
LOGGER.debug(LogMessage.format("Message with id '%s' was deleted.", id));
|
||||
LOGGER.debug(() -> "Message with id '" + id + "' was deleted.");
|
||||
}
|
||||
else {
|
||||
LOGGER.warn(LogMessage.format("Message with id '%s' was not deleted.", id));
|
||||
LOGGER.warn(() -> "Message with id '" + id + "' was not deleted.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Remove a Message Id from the idCache. Should be used in conjunction
|
||||
* Remove a Message Id from the idCache. Should be used in conjunction
|
||||
* with the Spring Integration Transaction Synchronization feature to remove
|
||||
* a message from the Message Id cache once a transaction either succeeded or
|
||||
* rolled back.</p>
|
||||
* <p>Only applicable if {@link #setUsingIdCache(boolean)} is set to
|
||||
* <code>true</code></p>.
|
||||
* rolled back.
|
||||
* Only applicable if {@link #setUsingIdCache(boolean)} is set to{@code true}.
|
||||
* @param messageId The message identifier.
|
||||
*/
|
||||
public void removeFromIdCache(String messageId) {
|
||||
@@ -611,7 +606,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the Message Id Cache, which caches Message Ids for
|
||||
* Return the size of the Message Id Cache, which caches Message Ids for
|
||||
* those messages that are currently being processed.
|
||||
* @return The size of the Message Id Cache
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user