gpt4 book ai didi

java - 尝试使用camel路由执行shell脚本并面临以下问题

转载 作者:太空宇宙 更新时间:2023-11-04 11:05:54 24 4
gpt4 key购买 nike

我正在尝试使用camel执行shell脚本并尝试了以下代码,一切看起来都很好,但我有以下两个问题

  1. Shell 脚本文件未选择并执行其中的命令。
  2. 甚至没有收到我保留在代码中的日志消息。

以下是我正在使用的路线

@component
public class ShellRoute extends RouteBuilder
{
@override
public void configure()
{
final Logger logger = LoggerFactory.getLogger(ShellRoute.class);
logger.info("shellRoute");

boolean startupRoute=true;

from("direct:start")
.log(LoggingLevel.INFO, "Enter into Route:")
.routeID("ShellRoute")
.autoStartup(startupRoute)
.onException(Exception.class);
.logExhausted(false)
.logStackTrace(false)
.end()
.log(LoggingLevel.INFO, "Starting Script:")
.to("exec:./run_setup.sh?args=dev")
.log(LoggingLevel.INFO, "End of Script:");
}
}

以下是日志:

2017-09-29 08:32:53 INFO Version:30 - HV000001: Hibernate Validator 5.2.4.Final

2017-09-29 08:32:53 INFO SupportMain:48 - Starting SupportMain on VDDP13C-52C8C99.mis.lmig.com with PID 13002 (/data/userdata/workspaces/ClaimDownload/support/target/classes started by mani in /data/userdata/workspaces/ClaimDownload/support)

2017-09-29 08:32:53 INFO SupportMain:669 - The following profiles are active: local

2017-09-29 08:32:53 INFO AnnotationConfigApplicationContext:581 - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@776aec5c: startup date [Fri Sep 29 08:32:53 EDT 2017]; root of context hierarchy 2017-09-29 08:32:55 INFO PostProcessorRegistrationDelegate$BeanPostProcessorChecker:328 - Bean 'org.apache.camel.spring.boot.CamelAutoConfiguration' of type [class org.apache.camel.spring.boot.CamelAutoConfiguration$$EnhancerBySpringCGLIB$$9509da1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2017-09-29 08:32:56 INFO DefaultTypeConverter:56 - Loaded 209 type converters

2017-09-29 08:32:57 INFO AnnotationMBeanExporter:431 - Registering beans for JMX exposure on startup

2017-09-29 08:32:57 INFO ShellRoute:33 - ShellRoute

2017-09-29 08:32:57 INFO RoutesCollector:148 - Loading additional Camel XML routes from: classpath:camel/*.xml

2017-09-29 08:32:57 INFO RoutesCollector:162 - Loading additional Camel XML rests from: classpath:camel-rest/*.xml

2017-09-29 08:32:57 INFO SpringCamelContext:2800 - Apache Camel 2.17.2 (CamelContext: camel-1) is starting

2017-09-29 08:32:57 INFO ManagedManagementStrategy:191 - JMX is enabled

2017-09-29 08:32:57 INFO DefaultRuntimeEndpointRegistry:203 - Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)

2017-09-29 08:32:57 INFO SpringCamelContext:3039 - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.

2017-09-29 08:32:57 INFO SpringCamelContext:3049 - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html

2017-09-29 08:32:57 INFO SpringCamelContext:3570 - Route: ShellRoute started and consuming from: Endpoint[direct://start]

2017-09-29 08:32:57 INFO SpringCamelContext:2840 - Total 1 routes, of which 1 are started.

2017-09-29 08:32:57 INFO SpringCamelContext:2841 - Apache Camel 2.17.2 (CamelContext: camel-1) started in 0.667 seconds

2017-09-29 08:32:57 INFO SupportMain:57 - Started SupportMain in 4.963 seconds (JVM running for 6.767)

2017-09-29 08:32:57 INFO AnnotationConfigApplicationContext:982 - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@776aec5c: startup date [Fri Sep 29 08:32:53 EDT 2017]; root of context hierarchy

2017-09-29 08:32:57 INFO AnnotationMBeanExporter:449 - Unregistering JMX-exposed beans on shutdown

2017-09-29 08:32:57 INFO SpringCamelContext:3066 - Apache Camel 2.17.2 (CamelContext: camel-1) is shutting down

最佳答案

在 Apache Camel 中执行 shell 脚本命令,根据 exec 组件文档 http://camel.apache.org/exec.html

以下示例使用构建文件 CamelExecBuildFile.xml 执行 Apache Ant(仅限 Windows),前提是 ant.bat 位于系统路径中,并且 CamelExecBuildFile.xml 位于当前目录中。

from("direct:exec").to("exec:ant.bat?args=-f CamelExecBuildFile.xml")

同样如此from("direct:exec").to("exec:{path}/Cygwin/bin/bash?args=run_setup.sh")

关于java - 尝试使用camel路由执行shell脚本并面临以下问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46489184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com