【问题标题】:Apache Camel Custom Component Migration Endpoint ExceptionApache Camel 自定义组件迁移端点异常
【发布时间】:2021-09-20 15:03:47
【问题描述】:

您好,我编写了我的自定义骆驼组件,它一直在工作,直到我升级版本。 我将我的版本 3.1 升级到 3.2,但出现错误

 Resolved [org.apache.camel.NoSuchEndpointException: No endpoint could be found for: my-rest-client, please check your classpath contains the needed Camel component jar.]

我查看了骆驼文档但不清楚。

https://camel.apache.org/manual/latest/camel-3x-upgrade-guide-3_2.html

我尝试了一些东西,但没有任何改变 这不起作用

  //camelContext.getRestConfiguration("servlet",true); 3.1 code deleted to upgrade 3.2
            CamelContextHelper.getRestConfiguration(camelContext,"servlet"); 3.2

我尝试将 camel-http,camel-direct 添加到我的 pom 中,但没有效果。

Component("MYClientEndpoint")
@UriEndpoint(scheme = "my-rest-client",title = "my-rest-client",syntax = "my-rest-client")
public class MYClientEndpoint extends DefaultEndpoint {
    @Autowired
    private MYClientProducer MYClientProducer;
    @Override
    public Producer createProducer() {
        return MYClientProducer;
    }

    @Override
    public Consumer createConsumer(Processor processor) {
        throw new UnsupportedOperationException("Operation not supported");
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    @Override
    public String getEndpointUri() {
        return "my-rest-client";
    }
}

它已经存在于我的应用程序上下文中。我可以在自动装配时访问它

【问题讨论】:

  • 您需要提供更多关于您的路线和设置的信息。
  • @LucaBurgazzoli 我添加了我的端点定义。camelContext.getEndpoints().add(myRestClientEndpoint);我尝试手动添加。它通过了这一步,但是当尝试调用生产者发送时,我没有这样的端点
  • 我建议使用最新版本的骆驼(3.11.x)并创建一个完整的组件(camel.apache.org/manual/latest/writing-components.html),因为这里看起来端点不是由组件实例化的。我还建议创建一个复制器。

标签: java apache-camel apache-camel-cdi


【解决方案1】:

当我更改 getEndpointUri 方法的返回值并将它与我的端点beanname 相等时它开始在骆驼 3.11 中工作时,我找到了答案 另一种方法是在骆驼启动器上下文中添加 enpoint,并在开头使用新名称。

Component("MYClientEndpoint")
public class MYClientEndpoint

@Override
    public String getEndpointUri() {
        return "my-rest-client";--> I change to  return "MYClientEndpoint"
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多