Skip to content

Conversation

@artembilan
Copy link
Member

Copy link
Contributor

@garyrussell garyrussell left a 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()));
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a

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.
Copy link
Contributor

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants