0
Я попытался написать собственный процессор, который отправляет несколько сообщений в цикле, как:Apache Camel процессор с ProducerTemplate
public class ListAllAttributes implements Processor {
static final transient Logger LOG = LoggerFactory.getLogger(ListAllAttributes.class);
ProducerTemplate producer;
public void setProducer(ProducerTemplate producer) {
this.producer = producer;
}
@Override
public void process(Exchange exchange) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
Document doc = exchange.getIn().getBody(Document.class);
NodeList entries = doc.getElementsByTagNameNS("*", "ItemId");
int length = entries.getLength();
for (int i = 0; i < length; ++i) {
.........
producer.requestBodyAndHeaders(newdoc,headers);
}
}
конечной точки для ProducerTemplate, я настроил в XML:
<template id="myTemplate" defaultEndpoint="https4..."/>
<bean class="ru.devprg.ruspace.bus.messages.ListAllAttributes" id="ListAllAttributes">
<property name="producer" ref="myTemplate"/>
</bean>
В журнале I пила, что запрос выполнен:
HttpProducer | 296 - org.apache.camel.camel-http4 - 2.16.3 | Executing http POST method: https://172.17.10.105/ews/exchange.asmx
Но доставка не удалось:
Caused by: org.apache.http.client.ClientProtocolException at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.camel.component.http4.HttpProducer.executeMethod(HttpProducer.java:278)[296:org.apache.camel.camel-http4:2.16.3] at org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:164)[296:org.apache.camel.camel-http4:2.16.3] at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:238)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)[126:org.apache.camel.camel-core:2.16.3] at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:253)[126:org.apache.camel.camel-core:2.16.3] ... 24 more Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity. at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:225)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)[294:org.apache.httpcomponents.httpclient:4.5.1] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)[294:org.apache.httpcomponents.httpclient:4.5.1]
Что может быть не так?
Пожалуйста, покажите свой маршрут на верблюде. –