gpt4 book ai didi

java - 如何启用Camel NettyChannelBufferStreamCache类型转换?

转载 作者:行者123 更新时间:2023-12-02 09:41:51 24 4
gpt4 key购买 nike

尝试让这个例子工作: https://github.com/apache/camel/tree/master/examples/camel-example-micrometer

当我转到指标端点时,例如 curl http://0.0.0.0:8088/metrics我收到此错误:

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache to the required type: java.io.Writer with value org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache@1030cc69

我想知道是否有办法注册新的类型转换器或对此错误的其他解释。

堆栈跟踪

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-charlie-1562961691767-0-4]
at org.apache.camel.CamelExecutionException.wrapCamelExecutionException(CamelExecutionException.java:47) ~[camel-api-3.0.0-20190712.122633-479.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.builder.ExpressionBuilder$34.evaluate(ExpressionBuilder.java:839) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:34) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.MethodInfo$ParameterExpression.evaluateParameterBinding(MethodInfo.java:762) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.MethodInfo$ParameterExpression.evaluateParameterExpressions(MethodInfo.java:654) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.MethodInfo$ParameterExpression.evaluate(MethodInfo.java:622) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:207) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:294) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:187) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:128) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager.process(DefaultAsyncProcessorAwaitManager.java:77) ~[camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.AsyncProcessorSupport.process(AsyncProcessorSupport.java:40) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
at org.apache.camel.language.bean.BeanExpression.invokeBean(BeanExpression.java:295) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:159) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:170) ~[camel-bean-3.0.0-20190712.122827-171.jar:3.0.0-SNAPSHOT]
at org.apache.camel.processor.TransformProcessor.process(TransformProcessor.java:44) ~[camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryState.run(RedeliveryErrorHandler.java:480) [camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:185) [camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) [camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:87) [camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:222) [camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.netty4.handlers.ServerChannelHandler.processAsynchronously(ServerChannelHandler.java:141) [camel-netty4-3.0.0-20190712.132550-469.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.netty4.handlers.ServerChannelHandler.channelRead0(ServerChannelHandler.java:112) [camel-netty4-3.0.0-20190712.132550-469.jar:3.0.0-SNAPSHOT]
at org.apache.camel.component.netty4.http.handlers.HttpServerChannelHandler.channelRead0(HttpServerChannelHandler.java:197) [camel-netty4-http-3.0.0-20190712.135212-462.jar:3.0.0-SNAPSHOT]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at org.apache.camel.component.netty4.http.handlers.HttpServerMultiplexChannelHandler.channelRead0(HttpServerMultiplexChannelHandler.java:144) [camel-netty4-http-3.0.0-20190712.135212-462.jar:3.0.0-SNAPSHOT]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:56) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:365) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.37.Final.jar:4.1.37.Final]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: java.io.Writer but has value: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache@1030cc69 of type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache on: Message[ID-charlie-1562961691767-0-5]. Caused by: No type converter available to convert from type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache to the required type: java.io.Writer with value org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache@1030cc69. Exchange[ID-charlie-1562961691767-0-4]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache to the required type: java.io.Writer with value org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache@1030cc69]
at org.apache.camel.support.MessageSupport.getMandatoryBody(MessageSupport.java:115) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.builder.ExpressionBuilder$34.evaluate(ExpressionBuilder.java:837) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
... 32 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache to the required type: java.io.Writer with value org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache@1030cc69
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:138) ~[camel-base-3.0.0-20190712.122747-410.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.MessageSupport.getMandatoryBody(MessageSupport.java:113) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
at org.apache.camel.support.builder.ExpressionBuilder$34.evaluate(ExpressionBuilder.java:837) ~[camel-support-3.0.0-20190712.122719-414.jar:3.0.0-SNAPSHOT]
... 32 more

最佳答案

我偶然发现了同样的问题。问题出在 ScrapeRouteBuilder 中。具体来说这部分:

.transform().method(prometheusMeterRegistry, "scrape")

scrape 有两种实现:

public String scrape()
public void scrape(Writer writer) throws IOException

所以你需要帮助 Camel 找出要调用哪一个。例如:

.transform().method(prometheusMeterRegistry, "scrape()")

我对 Camel master 分支进行了修复。

关于java - 如何启用Camel NettyChannelBufferStreamCache类型转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57013500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com