【问题标题】:How to use a dynamic endpoint while using the validator component of apache camel?如何在使用 apache camel 的验证器组件时使用动态端点?
【发布时间】:2022-01-06 04:05:23
【问题描述】:

我想使用 apache camel 进行 xml 验证休息服务,但是我希望文件的路径是动态的,但我无法做到:

package com.example.XMLValidator;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;


import core.ErrorProcessor;

@Component
public class XMLValidatorRestService extends RouteBuilder{
    
        @Override
        public void configure() throws Exception {
            
            onException(Exception.class).handled(true)
            .process(new ErrorProcessor());
            
            

            rest("/xmlValidator/{xsdLocation}")
            .post()
            
            .to("direct:xmlValidator");
            
 
            from("direct:xmlValidator")
            .choice()
                .when(header("ebmName").isEqualTo("pers.marriage.ebm.marrInfo_1.0")).to("validator:${header.xsdLocation}")
      .log("${body}");
        }   
}

但是这段代码给了我以下错误:

Cannot find resource: ${header.ebmName} for URI: ${header.ebmName}

这是正确的路线:.to("validator:file:C:/ISF/trunk/ISFApplications/ServiceBusApplications/Applications/MarriageServiceBusApplication/MarriageSBProject/apps/pers.marriage/ebm/pers.marriage.ebm.marrInfo_1.0.xsd") 那么知道如何使这条路径动态化吗?谢谢

【问题讨论】:

    标签: java eclipse spring-boot apache-camel


    【解决方案1】:

    使用toD 代替totoD 用于向动态端点发送消息。

    请参考:Camel docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多