大约24小时的溃烂停止消耗后,处理来自INNER_QUEUE的消息。邮件数在INNER_QUEUE中不断增加。
环境:
骆驼2.23版;
activemq-artemis 2.6.3持续存在,嵌入;
ubuntu 18
48小时后运行时间:
INNER_QUEUE jmx属性:消息数= 287,已确认消息= 188,已添加消息= 479
UNDELIVERED jmx属性:消息数= 77
http 409经常发生-这是正常现象。
//CamelContext
ConnectionFactory cf ... - create activemq-artemis connection factory
JmsComponent jmsComponent = JmsComponent.jmsComponentClientAcknowledge(cf);
jmsComponent.setConcurrentConsumers(4);
camelContext.addComponent("activemq", jmsComponent);
camelContext.addRoutes(new MyRoute(properties));
camelContext.start();
//Route
class MyRoute extends RouteBuilder {
public void configure() throws Exception {
errorHandling();
from("activemq:queue:INNER_QUEUE").routeId("innet-queue-consumer")
.process((exchange)->exchange.setProperty(TRACE_ID,exchange.getIn().getHeader(TRACE_ID)))
.removeHeaders("*",TRACE_ID)
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.process((exchange)->exchange.getIn().setHeader(AUTHORIZATION_HEADER,"Basic DSJFKLJ=="))
.process((exchange)->exchange.getIn().setHeader("Content-Type","application/json"))
.inOut("http://192.168.0.1:8008/api/product?disconnect=true&keepAlive=false")
.log(INFO,log,TAG + "was sent to service ${in.body}");
}
private void errorHandling() {
errorHandler(deadLetterChannel("activemq:queue:deadLetter")
.maximumRedeliveries(0)
.redeliveryDelay(10_000)
.log(log)
.logExhaustedMessageBody(true)
.retryAttemptedLogLevel(LoggingLevel.ERROR));
onException(HttpOperationFailedException.class).onWhen(
exceptionMessage().contains("statusCode: 409"))
.maximumRedeliveries(60)
.redeliveryDelay(60_000)
.handled(true)
.removeHeaders("*",TRACE_ID)
.to("activemq:queue:UNDELIVERED");
}
}
线程堆栈:
"Camel (camel-1) thread #18 - JmsConsumer[INNER_QUEUE]" #132 daemon prio=5 os_prio=0 cpu=8589.56ms elapsed=333032.69s tid=0x00007fc2d96a9800 nid=0x134 in Object.wait() [0x00007fc2342c2000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.2/Native Method)
- waiting on <no object reference available>
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:518)
- waiting to re-lock in wait() <0x000000074e1c2bd8> (a org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ConnectionPool)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.apache.camel.component.http.HttpProducer.executeMethod(HttpProducer.java:287)
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:169)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:76)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:113)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:736)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:696)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:318)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:257)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.2/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.2/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.2/Thread.java:834)
似乎消费者无法从池中获取http连接,即过去没有将http连接返回到连接池中? 也许配置错误?也许最好使用其他技术,例如队列,http客户端?