Spring引导升级Spring集成问题

Springboot Upgrade Spring Integration Issue

我有一个带有 Spring 集成的应用程序,它在 PriorityChannel 中对传入消息进行排队,这些消息使用使用 MongoDbChannelMessageStore 实现的 messageStore 进行持久化。目前我们在Springboot 2.1.3 版本下。我们进行了所有必要的更改以升级到 2.5.4 版本。 build.gradle、AWS 包重构等方面的许多变化......这没问题,一切都按预期工作。

具体问题是,如果我想升级在生产中使用旧版本存储的传入消息,当具有新版本的应用程序继续处理此负载时,会发生以下错误。似乎是 spring 集成的转换出错了。有什么建议吗?

2022-01-12 16:41:27,214 [1;31mERROR[0;39m [36m[org.springframework.integration.handler.LoggingHandler       catalogue-pool-1         ][0;39m org.springframework.messaging.MessagingException: nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [org.bson.types.Binary] to type [org.springframework.messaging.Message<?>] for value 'org.bson.types.Binary@fb62eb16'; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.util.LinkedCaseInsensitiveMap; local class incompatible: stream classdesc serialVersionUID = -798892522772790821, local class serialVersionUID = 1755438538721305358
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:427)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.lambda$createPoller(AbstractPollingEndpoint.java:348)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.lambda$execute[=11=](ErrorHandlingTaskExecutor.java:57)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [org.bson.types.Binary] to type [org.springframework.messaging.Message<?>] for value 'org.bson.types.Binary@fb62eb16'; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.util.LinkedCaseInsensitiveMap; local class incompatible: stream classdesc serialVersionUID = -798892522772790821, local class serialVersionUID = 1755438538721305358
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:175)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.doConvert(MappingMongoConverter.java:1546)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.doConvert(MappingMongoConverter.java:1538)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleRead(MappingMongoConverter.java:1048)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleRead(MappingMongoConverter.java:1033)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter$ConversionContext.convert(MappingMongoConverter.java:1891)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1640)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter$AssociationAwareMongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1689)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter$AssociationAwareMongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1652)
    at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:74)
    at org.springframework.data.mapping.model.SpELExpressionParameterValueProvider.getParameterValue(SpELExpressionParameterValueProvider.java:53)
    at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:269)
    at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:241)
    at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:89)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:368)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readDocument(MappingMongoConverter.java:341)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:277)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:273)
    at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:102)
    at org.springframework.data.mongodb.core.MongoTemplate$ReadDocumentCallback.doWith(MongoTemplate.java:3178)
    at org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal(MongoTemplate.java:2771)
    at org.springframework.data.mongodb.core.MongoTemplate.doFindAndRemove(MongoTemplate.java:2659)
    at org.springframework.data.mongodb.core.MongoTemplate.findAndRemove(MongoTemplate.java:1089)
    at org.springframework.integration.mongodb.store.MongoDbChannelMessageStore.pollMessageFromGroup(MongoDbChannelMessageStore.java:142)
    at org.springframework.integration.store.MessageGroupQueue.doPoll(MessageGroupQueue.java:357)
    at org.springframework.integration.store.MessageGroupQueue.poll(MessageGroupQueue.java:192)
    at org.springframework.integration.store.MessageGroupQueue.poll(MessageGroupQueue.java:51)
    at org.springframework.integration.channel.QueueChannel.doReceive(QueueChannel.java:144)
    at org.springframework.integration.channel.PriorityChannel.doReceive(PriorityChannel.java:138)
    at org.springframework.integration.channel.AbstractPollableChannel.receive(AbstractPollableChannel.java:95)
    at org.springframework.integration.endpoint.PollingConsumer.receiveMessage(PollingConsumer.java:217)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:444)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.pollForMessage(AbstractPollingEndpoint.java:413)
    ... 5 more
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.util.LinkedCaseInsensitiveMap; local class incompatible: stream classdesc serialVersionUID = -798892522772790821, local class serialVersionUID = 1755438538721305358
    at org.springframework.integration.support.converter.AllowListDeserializingConverter.convert(AllowListDeserializingConverter.java:142)
    at org.springframework.integration.mongodb.support.BinaryToMessageConverter.convert(BinaryToMessageConverter.java:38)
    at org.springframework.integration.mongodb.support.BinaryToMessageConverter.convert(BinaryToMessageConverter.java:31)
    at org.springframework.core.convert.support.GenericConversionService$ConverterAdapter.convert(GenericConversionService.java:386)
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
    ... 39 more
Caused by: java.io.InvalidClassException: org.springframework.util.LinkedCaseInsensitiveMap; local class incompatible: stream classdesc serialVersionUID = -798892522772790821, local class serialVersionUID = 1755438538721305358
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:699)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2001)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1848)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2158)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2403)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2327)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2403)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:631)
    at org.springframework.util.MimeType.readObject(MimeType.java:598)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1185)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2294)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:501)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:459)
    at java.util.HashMap.readObject(HashMap.java:1412)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1185)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2294)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2403)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:631)
    at org.springframework.messaging.MessageHeaders.readObject(MessageHeaders.java:329)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1185)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2294)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2403)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:631)
    at org.springframework.messaging.MessageHeaders.readObject(MessageHeaders.java:329)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1185)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2294)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2403)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2327)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2185)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1665)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:501)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:459)
    at org.springframework.integration.support.converter.AllowListDeserializingConverter.deserialize(AllowListDeserializingConverter.java:160)
    at org.springframework.integration.support.converter.AllowListDeserializingConverter.convert(AllowListDeserializingConverter.java:133)
    ... 43 more

是的...看起来有些 org.springframework.util.LinkedCaseInsensitiveMap class 内部状态在这两者之间发生了变化,并且其之前的序列化版本与新应用程序所期望的不兼容。

您可能需要实施基于旧版本 Spring Boot 的适配器应用程序。卸载这些消息,删除(或转换)具有该 org.springframework.util.MimeType 值的 header 并将它们序列化回 queue 以用于新应用。

我不认为真正存储整个 org.springframework.util.MimeType 真的有重要价值,但不仅仅是它的纯字符串表示...