用fabric8 maven插件验证Camel路由

x33g5p2x  于2022-09-30 转载在 Maven  
字(2.5k)|赞(0)|评价(0)|浏览(1063)

你可以用Fabric8 Maven plugin做的最酷的事情之一是验证Camel路由,这可以在你最喜欢的IDE中完成,或者只用一个shell就可以了。

让我们看一个快速的例子。我们将使用Camel发行版中提供的任何一个例子,如camel-example-jdbc。移动到pom.xml所在的文件夹并发出。

$ mvn compile -DshowAll=true compile io.fabric8.forge:fabric8-camel-maven-plugin:2.3.80:validate

输出将显示所有被检查的路由和验证结果。

[INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:54)  	dataset:sampleGenerator   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:63)  	jdbc:dataSource?useHeadersAsParameters=true   [WARNING] Endpoint validation error at: META-INF.spring.camel-context(camel-context.xml:64)  	log:insertLog?showHeaders=true  	             showHeaders    Unknown option   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:70)  	timer://timer1?period=2s   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:76)  	jdbc:dataSource   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:79)  	bean:recordProcessor   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:80)  	direct:updateDone   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:84)  	direct:updateDone   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:93)  	jdbc:dataSource?useHeadersAsParameters=true   [INFO] Endpoint validation passsed at: META-INF.spring.camel-context(camel-context.xml:97)  	log:updateDone   [WARNING] Endpoint validation error: (9 = passed, 1 = invalid, 0 = incapable, 0 = unknown components) [INFO] Simple validation passed at: META-INF.spring.camel-context(camel-context.xml:78)  	${body}   [INFO] Simple validation passed at: META-INF.spring.camel-context(camel-context.xml:86)  	${body['ID']}   [INFO] Simple validation passed at: META-INF.spring.camel-context(camel-context.xml:95)  	Record ID=${headers.camelTestId} has been marked as 'DONE'   [INFO] Simple validation success: (3 = passed, 0 = invalid)

让我们来测试一下,如果我们在上述任何一条规则中包含一个错别字会发生什么。

[WARNING] Endpoint validation error at: META-INF.spring.camel-context(camel-context.xml:63)  	jdbc:dataSource?XXuseHeadersAsParameters=true  	XXuseHeadersAsParameters    Unknown option. Did you mean: [useHeadersAsParameters, allowNamedParameters]

正如你所看到的,该插件甚至建议与其他参数或组件进行潜在的匹配

你也可以通过在你的pom.xml文件中加入该插件,使其作为构建的一部分自动运行以捕捉错误。

<plugin>     <groupId>io.fabric8.forge</groupId>     <artifactId>fabric8-camel-maven-plugin</artifactId>     <version>2.3.80</version>     <executions>       <execution>         <phase>process-classes</phase>               <goals>           <goal>validate</goal>         </goals>       </execution>     </executions>   </plugin>

相关文章

最新文章

更多