Make custom converter compatible with latest S-D
The latest changes in the `MappingMongoConverter` resolves the target type from the document. That type is a `GenericMessage`. The `GenericConversionService` doesn't match such a target type for the `MessageReadConverter implements Converter<Document, Message<?>>` and fail. * Change the `MessageReadConverter` generic type into the `GenericMessage` for matching data in the collection
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
@@ -189,14 +190,12 @@ public class ConfigurableMongoDbMessageGroupStoreTests extends AbstractMongoDbMe
|
||||
}
|
||||
|
||||
@ReadingConverter
|
||||
public static class MessageReadConverter implements Converter<Document, Message<?>> {
|
||||
public static class MessageReadConverter implements Converter<Document, GenericMessage<?>> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Message<?> convert(Document source) {
|
||||
return MessageBuilder.withPayload(source.get("payload"))
|
||||
.copyHeaders((Map<String, ?>) source.get("headers"))
|
||||
.build();
|
||||
public GenericMessage<?> convert(Document source) {
|
||||
return new GenericMessage<>(source.get("payload"), (Map<String, Object>) source.get("headers"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user