Apache Camel自定义组件迁移端点异常错误

uoifb46i  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(154)

嗨,我写了我的自定义 Camel 组件,它是工作,直到我升级版本。我升级我的版本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.]

我查到 Camel 的文件,但不明白清楚。
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 直接到我的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";
    }
}

它可能已经存在于我的应用程序上下文中。当自动连接它时,我可以访问它

xtfmy6hx

xtfmy6hx1#

当我更改getEndpointUri方法返回值并将其等同于在camel 3.11中开始工作时我的endpointbeanname时,我找到了答案。另一种方法是将enpoint添加到camel启动器上下文中,并在开头使用新名称。

Component("MYClientEndpoint")
public class MYClientEndpoint

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

相关问题