Полученное сообщение запроса изменяется с TCP-сервера после обновления Spring boot до 3.4.2.JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Полученное сообщение запроса изменяется с TCP-сервера после обновления Spring boot до 3.4.2.

Сообщение Anonymous »

После обновления Spring Boot с версии 2.7 до 3.4 получение сообщения от TCP-сервера в нашу службу меняется с использованием другого кода. Например, ранее после десериализации этого сообщения было получено сообщение с номером 1784, а теперь оно изменилось на 1684, то есть ответное сообщение, которое нам нужно отправить обратно на сервер.
Ниже приведена ошибка, с которой мы столкнулись в настоящее время:
ERROR [Regi-service,,,,,,,] 8 --- [pool-2-thread-3] [ ] a.s.o.d.m.r.DeserializedIsoMessage : Extracted raw message type value: 6292 (int), hex: 1894
2025-10-31T09:02:41.411+01:00 ERROR [otis-service,,,,,,,] 8 --- [pool-2-thread-3] [ ] at.regi.otis.api.oli.OliController : Deserialization failed

java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.orElseThrow(Optional.java:377) ~[na:na]
at at.regi.otis.domain.message.request.RequestMessageType.byType(RequestMessageType.java:549) ~[!/:3.0.0]
at at.regi.otis.domain.message.request.DeserializedIsoMessage.type(DeserializedIsoMessage.java:36) ~[!/:3.0.0]
at at.regi.otis.domain.message.request.DeserializedRequestMessageWithType.type(DeserializedRequestMessageWithType.java:15) ~[!/:3.0.0]
at at.regi.otis.domain.message.request.RequestMessage.type(RequestMessage.java:41) ~[!/:3.0.0]
at at.regi.otis.api.oli.OliController.handle(OliController.java:60) ~[!/:3.0.0]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:169) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.integration.handler.support.IntegrationInvocableHandlerMethod.doInvoke(IntegrationInvocableHandlerMethod.java:45) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:119) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper$HandlerMethod.invoke(MessagingMethodInvokerHelper.java:1086) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.invokeHandlerMethod(MessagingMethodInvokerHelper.java:569) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:482) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:360) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:114) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:95) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:145) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.AbstractMessageHandler.handleWithMetrics(AbstractMessageHandler.java:90) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:70) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:145) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:378) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.channel.AbstractMessageChannel.sendWithMetrics(AbstractMessageChannel.java:349) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:329) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:234) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:47) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:46) ~[spring-messaging-6.2.2.jar!/:6.2.2]
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:107) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:687) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveWithMetrics(MessagingGatewaySupport.java:675) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:612) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:588) ~[spring-integration-core-6.2.4.jar!/:6.2.4]
at org.springframework.integration.ip.tcp.TcpInboundGateway.doOnMessage(TcpInboundGateway.java:125) ~[spring-integration-ip-6.2.4.jar!/:6.2.4]
at org.springframework.integration.ip.tcp.TcpInboundGateway.onMessage(TcpInboundGateway.java:103) ~[spring-integration-ip-6.2.4.jar!/:6.2.4]
at org.springframework.integration.ip.tcp.connection.TcpNetConnection.receiveAndProcessMessage(TcpNetConnection.java:233) ~[spring-integration-ip-6.2.4.jar!/:6.2.4]
at org.springframework.integration.ip.tcp.connection.TcpNetConnection.run(TcpNetConnection.java:206) ~[spring-integration-ip-6.2.4.jar!/:6.2.4]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]

2025-10-31T09:02:41.412+01:00 INFO [Regi-service,,,,,,,] 8 --- [pool-2-thread-3] [ ] at.regi.otis.api.oli.OliController : Started errorResponse method

Некоторые полученные сообщения с запросами работают правильно, но между ними возникают ошибки, описанные выше.
Это код десериализации:
@Override
public RequestMessageType type() {
int rawType = deserializedMessage().getType();
String formattedType = String.format("%02x", rawType);
log.error("Extracted raw message type value: {} (int), hex: {}", rawType, formattedType);
return RequestMessageType.byType(formattedType);
}

мы используем Spring-intergation-ip-6.4.2.jar, у него есть такой класс ByteArrayRawSerializer
public abstract class AbstractByteArraySerializer implements Serializer, Deserializer, ApplicationEventPublisherAware {
public static final int DEFAULT_MAX_MESSAGE_SIZE = 2048;
protected final LogAccessor logger = new LogAccessor(this.getClass());
private int maxMessageSize = 2048;
private ApplicationEventPublisher applicationEventPublisher;

public AbstractByteArraySerializer() {
}

public int getMaxMessageSize() {
return this.maxMessageSize;
}

public void setMaxMessageSize(int maxMessageSize) {
this.maxMessageSize = maxMessageSize;
}

public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}

protected void checkClosure(int bite) throws IOException {
if (bite < 0) {
this.logger.debug("Socket closed during message assembly");
throw new IOException("Socket closed during message assembly");
}
}

protected void publishEvent(Exception cause, byte[] buffer, int offset) {
TcpDeserializationExceptionEvent event = new TcpDeserializationExceptionEvent(this, cause, buffer, offset);
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(event);
} else {
this.logger.trace(() -> {
return "No event publisher for " + event;
});
}

}
}

RequestMessageType
public static RequestMessageType byType(String type) {
Optional match = Arrays.stream(RequestMessageType.values())
.filter(message -> message.type.equals(type))
.findFirst();

if (match.isEmpty()) {
log.error("RequestMessageType lookup FAILED for type string: '{}'. No matching enum found.", type);
}

return match.orElseThrow();
}


Подробнее здесь: https://stackoverflow.com/questions/798 ... pring-boot
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»