Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Camel:将消息转发到动态目标(从数据库)_Spring_Validation_Apache Camel_Message - Fatal编程技术网

Spring Camel:将消息转发到动态目标(从数据库)

Spring Camel:将消息转发到动态目标(从数据库),spring,validation,apache-camel,message,Spring,Validation,Apache Camel,Message,我正在我的应用程序中使用camel 2.8.4。我的应用程序将从队列接收请求,然后该请求将由验证器验证。根据消息的内容,验证器将请求转发到不同的目的地。验证器将是一个pojobean。目标将从数据库中获取(这是必须的)。我更喜欢使用SpringDSL作为上下文 1. I dont know how to write the validator to forward req to destinations. 2. Can we use something similar like this

我正在我的应用程序中使用camel 2.8.4。我的应用程序将从队列接收请求,然后该请求将由验证器验证。根据消息的内容,验证器将请求转发到不同的目的地。验证器将是一个pojobean。目标将从数据库中获取(这是必须的)。我更喜欢使用SpringDSL作为上下文

1. I dont know how to write the validator to forward req to destinations.
2. Can we use something similar like this 
    <to uri='method=getURI() bean='Validator''> in camelContext

<camelContext>
       <route id="route-1">
          <from uri="mq:queue:QUEUE"/>
          <bean ref="Validator" method="validate"/>
               <!--i would be great if we can use <to uri="dynamicURI-from-database"> here  -->
       </route> 
</camelContext>

Class Validator{
    public void validate(String req){
     if (...)
         //get uri1 from database 
         String uri1=getURI(..);
         //forward req to uri1
           ...........
     else 
         //get uri2 from database 
          String uri2=getURI(...);
         //forward req to uri2
           ...........

    }

   public String getURI(..){
        ......
      return uri;
    }
1。我不知道如何编写验证器将req转发到目的地。
2.我们能用类似的东西吗
上下文中
类验证器{
公共无效验证(字符串请求){
如果(…)
//从数据库中获取uri1
字符串uri1=getURI(…);
//将请求转发到uri1
...........
其他的
//从数据库中获取uri2
字符串uri2=getURI(…);
//转发请求到uri2
...........
}
公共字符串getURI(…){
......
返回uri;
}
}使用该功能在运行时生成URI。您可以调用在exchange中设置URI的处理器,然后在to子句中使用该处理器

比如:

process(new Procesor()
   public void process(Exchange exchange){
          exchange.setHeader("myURI",someURI);
});
在to条款中

<to uri="${header.myURI}"/>

使用该功能在运行时生成URI。您可以调用在exchange中设置URI的处理器,然后在to子句中使用该处理器

比如:

process(new Procesor()
   public void process(Exchange exchange){
          exchange.setHeader("myURI",someURI);
});
在to条款中

<to uri="${header.myURI}"/>

使用该功能在运行时生成URI。您可以调用在exchange中设置URI的处理器,然后在to子句中使用该处理器

比如:

process(new Procesor()
   public void process(Exchange exchange){
          exchange.setHeader("myURI",someURI);
});
在to条款中

<to uri="${header.myURI}"/>

使用该功能在运行时生成URI。您可以调用在exchange中设置URI的处理器,然后在to子句中使用该处理器

比如:

process(new Procesor()
   public void process(Exchange exchange){
          exchange.setHeader("myURI",someURI);
});
在to条款中

<to uri="${header.myURI}"/>


您看过动态收件人列表模式吗:?

您看过动态收件人列表模式吗:?

您看过动态收件人列表模式吗:?

您看过动态收件人列表模式吗:?

如果目标端点是Http API,您可以使用toD。请参阅链接:

如果目标端点是Http API,则可以使用toD。请参阅链接:

如果目标端点是Http API,则可以使用toD。请参阅链接:

如果目标端点是Http API,则可以使用toD。请参阅以下连结: