У меня проблема с Camel и ActiveMQ.
Иногда возникает исключение преждевременного EOF при чтении HTTP-ответа на запрос SOAP внешних веб-служб. Я не знаю, почему это происходит, но это другой вопрос.
Моя проблема в том, что исключение, похоже, неправильно обрабатывается Camel. Откат транзакции отсутствует, и, что еще хуже, Camel прекращает потребление сообщений из исходной очереди сообщения (в следующем примере с именем myqueue). Все новые сообщения застряли в очереди. Нам нужно перезапустить приложение (не ActiveMQ), чтобы снова получать сообщения.
Мы используем Camel 2.15, ActiveMQ 5.15 с JMSComponent, а не компонент activeMQ (у нас были некоторые проблемы с ним во время создания приложение).
Маршруты следующие:
<route id="sendSOAPMessage" errorHandlerRef="noErrorHandler">
<from uri="activemq:queue:myqueue" />
<transacted />
<bean ref="unmarshallMetaDataFromBodyProcessor" />
<bean ref="getInformationFooProcessor" />
<bean ref="getInformationBarProcessor" />
<bean ref="prepareMessageForSoapRequestProcessor" />
<choice>
<when>
<simple>${property.VERSION} == 'V1'</simple>
<to uri="cxf:bean:sendRequestEndpointV1" />
</when>
<when>
<simple>${property.VERSION} == 'V2'</simple>
<to uri="cxf:bean:sendRequestEndpointV2" />
</when>
</choice>
<bean ref="deleteSomethingProcessor" />
</route>
<cxf:cxfEndpoint id="sendRequestEndpointV2"
address="externalAddress"
serviceClass="com.external.company.WSDLPortType"
wsdlURL="/wsdl/2/WSDL_V2.wsdl" serviceName="s:WSDL_V2"
endpointName="s:WSDL_SOAPPort" xmlns:s="http://company.external.com/2">
<cxf:inInterceptors>
<ref bean="gzipInInterceptor" />
</cxf:inInterceptors>
<cxf:properties>
<entry key="mtom-enabled" value="false" />
<entry key="schema-validation-enabled" value="true" />
</cxf:properties>
</cxf:cxfEndpoint>
Вот исключение:
2020-04-23,17:33:55,634 WARN [735467f3-0d82-4d62-b995-f2b873c84fb1 default-workqueue-55] [XXX in o.a.c.p.PhaseInterceptorChain] java.io.IOException: Premature EOF
at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:565) ~[na:1.8.0_242]
at sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:609) ~[na:1.8.0_242]
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:696) ~[na:1.8.0_242]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[na:1.8.0_242]
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3454) ~[na:1.8.0_242]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[na:1.8.0_242]
at java.io.PushbackInputStream.read(PushbackInputStream.java:186) ~[na:1.8.0_242]
at org.apache.cxf.attachment.MimeBodyPartInputStream.read(MimeBodyPartInputStream.java:79) ~[cxf-core-3.0.4.jar:3.0.4]
at java.io.InputStream.read(InputStream.java:101) ~[na:1.8.0_242]
at org.apache.cxf.attachment.DelegatingInputStream.read(DelegatingInputStream.java:98) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:192) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:142) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.attachment.AttachmentDeserializer.cache(AttachmentDeserializer.java:216) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.attachment.AttachmentDeserializer.cacheStreamedAttachments(AttachmentDeserializer.java:187) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeserializer.java:168) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachmentCollection.java:95) ~[cxf-core-3.0.4.jar:3.0.4]
Wrapped by: java.lang.RuntimeException: java.io.IOException: Premature EOF
at org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachmentCollection.java:103) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.jaxb.attachment.JAXBAttachmentSchemaValidationHack.handleMessage(JAXBAttachmentSchemaValidationHack.java:55) ~[cxf-rt-databinding-jaxb-3.0.4.jar:3.0.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) ~[cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:784) [cxf-core-3.0.4.jar:3.0.4]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1644) [cxf-rt-transports-http-3.0.4.jar:3.0.4]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1155) [cxf-rt-transports-http-3.0.4.jar:3.0.4]
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428) [cxf-core-3.0.4.jar:3.0.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_242]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_242]
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353) [cxf-core-3.0.4.jar:3.0.4]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_242] Interceptor for {http://company.external.com/2}WSDL_V2#{http://company.external.com/2}EndPoint has thrown exception, unwinding now