Skip to content

Commit 9761c7f

Browse files
committed
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
1 parent 9d8393e commit 9761c7f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/ConfigurableMongoDbMessageGroupStoreTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
import org.springframework.integration.support.MessageBuilder;
3737
import org.springframework.messaging.Message;
3838
import org.springframework.messaging.MessageChannel;
39+
import org.springframework.messaging.support.GenericMessage;
3940
import org.springframework.util.StopWatch;
4041

4142
/**
@@ -189,14 +190,12 @@ public interface TestGateway {
189190
}
190191

191192
@ReadingConverter
192-
public static class MessageReadConverter implements Converter<Document, Message<?>> {
193+
public static class MessageReadConverter implements Converter<Document, GenericMessage<?>> {
193194

194195
@Override
195196
@SuppressWarnings("unchecked")
196-
public Message<?> convert(Document source) {
197-
return MessageBuilder.withPayload(source.get("payload"))
198-
.copyHeaders((Map<String, ?>) source.get("headers"))
199-
.build();
197+
public GenericMessage<?> convert(Document source) {
198+
return new GenericMessage<>(source.get("payload"), (Map<String, Object>) source.get("headers"));
200199
}
201200

202201
}

0 commit comments

Comments
 (0)