Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.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
Java 在Camel中调用运行时延迟_Java_Apache Camel_Delay - Fatal编程技术网

Java 在Camel中调用运行时延迟

Java 在Camel中调用运行时延迟,java,apache-camel,delay,Java,Apache Camel,Delay,我不熟悉Camel,我正在尝试通过为路由设置新延迟来实现更改Camel默认延迟的功能。我正在停止路线并启动它,但是它似乎考虑默认延迟而不是考虑新的延迟。我的SpringCamelTester.java代码如下: public class SpringCamelTester { private ApplicationContext context = null; public static void main(String[] args) throws Exception {

我不熟悉Camel,我正在尝试通过为路由设置新延迟来实现更改Camel默认延迟的功能。我正在停止路线并启动它,但是它似乎考虑默认延迟而不是考虑新的延迟。我的SpringCamelTester.java代码如下:

public class SpringCamelTester {

    private ApplicationContext context = null;

    public static void main(String[] args) throws Exception {

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Context.xml");
        CamelContext cc = (CamelContext) context.getBean("testingDelay");

        RouteContext cc2 = cc.getRoute("s2d").getRouteContext();

        cc2.setDelayer((long) 5000);
        cc.stopRoute("s2d");
        cc.startRoute("s2d");

        Thread.sleep(50000);
    }
}
<camelContext id="testingDelay" xmlns="http://camel.apache.org/schema/spring">
    <route id="s2d">
        <from uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Source?noop=true" />

        <!-- <log message="Output of message from Queue: ${in.body}"/> -->
        <bean ref="fileProcessor" method="propcess"/>

        <to uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Destination" />
    </route>
</camelContext>
My Context.xml如下所示:

public class SpringCamelTester {

    private ApplicationContext context = null;

    public static void main(String[] args) throws Exception {

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("Context.xml");
        CamelContext cc = (CamelContext) context.getBean("testingDelay");

        RouteContext cc2 = cc.getRoute("s2d").getRouteContext();

        cc2.setDelayer((long) 5000);
        cc.stopRoute("s2d");
        cc.startRoute("s2d");

        Thread.sleep(50000);
    }
}
<camelContext id="testingDelay" xmlns="http://camel.apache.org/schema/spring">
    <route id="s2d">
        <from uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Source?noop=true" />

        <!-- <log message="Output of message from Queue: ${in.body}"/> -->
        <bean ref="fileProcessor" method="propcess"/>

        <to uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Destination" />
    </route>
</camelContext>
请帮忙


谢谢。

驼峰只支持在加载路线时设置延迟器时间。 您可以像这样在路由上设置延迟器值

<camelContext id="testingDelay" xmlns="http://camel.apache.org/schema/spring">
    <route id="s2d" delayer="20000">
        <from uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Source?noop=true" />

        <!-- <log message="Output of message from Queue: ${in.body}"/> -->
        <bean ref="fileProcessor" method="propcess"/>

        <to uri="file:D:/Workshop/Rough/CamelTest/CamelSink/Destination" />
    </route>
</camelContext>