-
Notifications
You must be signed in to change notification settings - Fork 1.1k
INT-3364: Add batchUpdate into JdbcMessageHandler #2534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
garyrussell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of typos, and one question.
| if (message.getPayload() instanceof Iterable) { | ||
| Stream<? extends MutableMessage<?>> messageStream = | ||
| StreamSupport.stream(((Iterable<?>) message.getPayload()).spliterator(), false) | ||
| .map(payload -> new MutableMessage<>(payload, message.getHeaders())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about...
Stream<Message<?>> messageStream =
StreamSupport.stream(((Iterable<?>) message.getPayload()).spliterator(), false)
.map(payload -> new Message<Object>() {
@Override
public Object getPayload() {
return payload;
}
@Override
public MessageHeaders getHeaders() {
return message.getHeaders();
}
});...to avoid wrapping the headers in a new map for each iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good optimization! 👍
Will address a bit later.
Thanks
| * </pre> | ||
| * | ||
| * <p> | ||
| * When message payload is an instance of {@link Iterable}, a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a
src/reference/asciidoc/jdbc.adoc
Outdated
| Starting with version 5.1, the `JdbcMessageHandler` performs a `JdbcOperations.batchUpdate()` if the payload of the request message is an `Iterable` instance. | ||
| Each element of the `Iterable` is wrapped to the `MutableMessage` with a copy of headers from the request message. | ||
| In case of regular `SqlParameterSourceFactory`-based configuration these messages are used to build an `SqlParameterSource[]` for an argument used in the mentioned `JdbcOperations.batchUpdate()` function. | ||
| Inb case if `MessagePreparedStatementSetter`, a `BatchPreparedStatementSetter` variant is used to iterate over those messages for each item and provided `MessagePreparedStatementSetter` ise called against them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Inb/In the/
and the provided
s/ise/is/
* Polishing Docs and Javadocs
JIRA: https://jira.spring.io/browse/INT-3364