簡體   English   中英

刷新apache駱駝路線

[英]refresh apache camel routes

我使用spring camel作為獨立應用程序,該應用程序根據從psql database返回的內容構建許多routes

private void addEndpoint(String urlName, String type, String host, String port, String username, String password) {


        String endpointUrl = String.format("https://%s:%s?username=%s&password=%s", host, port, username, password);

        from("direct:endpoint_" + urlName)
            .throttle(1).timePeriodMillis(60000)
            .to(endpointUrl);

    }

並在一個循環中創建route ,該循環取決於從數據庫返回的內容,如下所示:

@Override
    public void configure() throws Exception {

        final List<Url> url= dbUrlDAO.getUrl();

        for (Url urlInfo : urls) {


            addEndpoint(urlInfo.getName(), urlInfo.getType(), urlInfo.getIp(), urlInfo.getPort(),urlInfo.getUsername(), urlInfo.getPassword());

        }

我想要實現的是能夠在不重新啟動應用程序的情況下添加route (路由構建器由camel-context.xml初始化)。

無論如何,有強制運行應用程序刷新camel context嗎?

是的,您可以在運行時添加/刪除路由。 CamelContest上有API可以做到這一點,並且您可以在Google上查找/閱讀示例的示例等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM