INT-4081: Custom PreparedStSetter for JdbcMChStore
JIRA: https://jira.spring.io/browse/INT-4081 * Add `MessageGroupPreparedStatementSetter` to let end-user to override the message insertion logic * Add tests and Docs
This commit is contained in:
committed by
Artem Bilan
parent
bf1fef39db
commit
34d0859515
@@ -365,6 +365,37 @@ If your database is not listed, you can easily extend the `AbstractChannelMessag
|
||||
|
||||
Since _version 4.0_, the `MESSAGE_SEQUENCE` column has been added to the table to ensure first-in-first-out (FIFO) queueing even when messages are stored in the same millisecond.
|
||||
|
||||
Since_version 5.0, by overloading `MessageGroupPreparedStatementSetter` class you can provide custom
|
||||
implementation to `PreparedStatementSetter` to support different columns or table structure
|
||||
or serialization strategy.
|
||||
For example, instead of default serialization to byte[], we can store its structure in JSON string.
|
||||
|
||||
Below example uses the default implementation of `setValues` to store common columns and overrides the behavior
|
||||
just to store the message payload as varchar.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
|
||||
public class CustomMessageGroupPreparedStatementSetter
|
||||
extends MessageGroupPreparedStatementSetter {
|
||||
|
||||
public CustomMessageGroupPreparedStatementSetter() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement preparedStatement, Message<?> requestMessage,
|
||||
Object groupId, String region, boolean priorityEnabled) throws SQLException {
|
||||
// Populate common columns
|
||||
super.setValues(preparedStatement, requestMessage, groupId, region, priorityEnabled);
|
||||
// Store message payload as varchar
|
||||
preparedStatement.setString(6, requestMessage.getPayload().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
----
|
||||
|
||||
[IMPORTANT]
|
||||
=====
|
||||
Generally it is not recommended to use a relational database for the purpose of queuing.
|
||||
|
||||
@@ -291,3 +291,10 @@ See <<ip>> for more information.
|
||||
The `GemfireMetadataStore` now implements `ListenableMetadataStore`, allowing users to listen to cache events by providing `MetadataStoreListener` instances to the store.
|
||||
|
||||
See <<gemfire>> for more information.
|
||||
|
||||
==== Jdbc Message Channel Store Changes
|
||||
|
||||
The `JdbcMessageChannelStore` now provides setter to set `MessageGroupPreparedStatementSetter`,
|
||||
allowing users to easily customize `PreparedStatementSetter` in the store.
|
||||
|
||||
See <<jdbc-message-store-channels>> for more information.
|
||||
|
||||
Reference in New Issue
Block a user