Add Error Handling to RedisStreamMessageProducer

* Use 'onErrorContinue' to continue receiving messages from Stream
* Send an `ErrorMessage` to the provided `errorChannel` (if any)
* And `@Nullable` to some `MessageProducerSupport` API which definitely
may accept `null`
* Extract common `buildMessageFromRecord()` method in the `ReactiveRedisStreamMessageProducer`,
so all the headers from the stream `Record` are carried to the message independently of the
 record state - normal send or error sending
This commit is contained in:
rohan mukesh
2020-10-13 13:33:17 -05:00
committed by Artem Bilan
parent 5b74db8417
commit b1a383060d
3 changed files with 151 additions and 57 deletions

View File

@@ -248,7 +248,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
* @return true if the error channel is available and message sent.
* @since 4.3.10
*/
protected final boolean sendErrorMessageIfNecessary(Message<?> message, Exception exception) {
protected final boolean sendErrorMessageIfNecessary(@Nullable Message<?> message, Exception exception) {
MessageChannel channel = getErrorChannel();
if (channel != null) {
this.messagingTemplate.send(channel, buildErrorMessage(message, exception));
@@ -265,7 +265,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
* @return the error message.
* @since 4.3.10
*/
protected final ErrorMessage buildErrorMessage(Message<?> message, Exception exception) {
protected final ErrorMessage buildErrorMessage(@Nullable Message<?> message, Exception exception) {
return this.errorMessageStrategy.buildErrorMessage(exception, getErrorMessageAttributes(message));
}
@@ -277,7 +277,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
* @return the attributes.
* @since 4.3.10
*/
protected AttributeAccessor getErrorMessageAttributes(Message<?> message) {
protected AttributeAccessor getErrorMessageAttributes(@Nullable Message<?> message) {
return ErrorMessageUtils.getAttributeAccessor(message, null);
}