Apache camel 在Apache Camel中,有没有一种方法可以通过另一条路由上的一条路由获得并释放锁

Apache camel 在Apache Camel中,有没有一种方法可以通过另一条路由上的一条路由获得并释放锁,apache-camel,Apache Camel,我正在寻找一种方法,通过这种方法,一条路由可以获得并释放另一条路由上的锁,下面是我的代码片段,我正在寻找一种解决方案,其中snmp陷阱路由和snmp定时器路由可以获得业务逻辑路由上的排他锁,并且当一条路由正在处理另一条路由时,应该等待它完成 <route id="snmp-trap-route"> <from uri="snmp:{{snmp.host}}:{{snmp.port}}?protocol=udp&amp;type=TRAP" /> <to ur

我正在寻找一种方法,通过这种方法,一条路由可以获得并释放另一条路由上的锁,下面是我的代码片段,我正在寻找一种解决方案,其中snmp陷阱路由和snmp定时器路由可以获得业务逻辑路由上的排他锁,并且当一条路由正在处理另一条路由时,应该等待它完成

<route id="snmp-trap-route">
<from uri="snmp:{{snmp.host}}:{{snmp.port}}?protocol=udp&amp;type=TRAP" />
<to uri="direct:snmp-main-route"/>



${property[batch.end]}==true
${property[batch.started]}==true
试验路线
java.lang.Exception
真的

使用队列可以达到相同的结果

队列逐个处理消息。如果您的路线在相同的上下文中,您可以使用Seda组件来实现这一点。否则,您可以使用activemq

<route id="snmp-trap-route">
<from uri="snmp:{{snmp.host}}:{{snmp.port}}?protocol=udp&amp;type=TRAP" />
<to uri="seda:business-logic-route"/>

<route id="snmp-timer-route">
<from uri="timer://pulse?fixedRate=true&amp;period=1000" />
<to uri="seda:business-logic-route"/>

<route id="business-logic-route">
<from uri="seda:business-logic-endpoint"/>            
<setProperty propertyName="esq.route.name">
    <constant>TestRoute</constant>
</setProperty>
<process ref="messageMultiplierProcessor" />
<process ref="calculatedFieldsProcessor" />      

试验路线

这样,只有在
业务逻辑路由
完成后,才会处理
业务逻辑路由
中的下一条消息。也许这就是你想要的。

@Ewout-谢谢你的回复,但在我的案例中它不起作用,因为seda的异步行为是在与制作人不同的线程中调用消费者的,而且我编辑了我的问题以显示完整的驼峰上下文我的错误,我尝试了另一种方法,但没有达到预期效果,它现在起作用了。谢谢你的帮助
<route id="snmp-main-route">
        <from uri="direct:snmp-main-route" />
            <choice>
                <when>
                    <simple>${property[batch.ended]} == true </simple>                      
                    <to uri="direct:transacted-endpoint" />
                </when>
                <when>
                    <simple>${property[batch.started]} == true </simple>                        
                    <to uri="direct:business-logic-endpoint" />
                </when>
                <otherwise>                 
                    <to uri="direct:business-logic-endpoint" />
                </otherwise>
            </choice>               
    </route>

<route id="business-logic-route">
        <from uri="direct:business-logic-endpoint"/>
        <setProperty propertyName="route.name">
            <constant>TestRoute</constant>
        </setProperty>
        <process ref="messageMultiplierProcessor" />
        <process ref="calculatedFieldsProcessor" />
        <process ref="tableProcessor" />                        
    </route>

<route id="transacted-route">
        <from uri="direct:transacted-endpoint"/>
        <transacted/>
        <to uri="direct:business-logic-endpoint"/>
        <onException>
            <exception>java.lang.Exception</exception>
            <handled>
                <constant>true</constant>
            </handled>
            <rollback markRollbackOnly="true"/>
        </onException>
    </route>
<route id="snmp-trap-route">
<from uri="snmp:{{snmp.host}}:{{snmp.port}}?protocol=udp&amp;type=TRAP" />
<to uri="seda:business-logic-route"/>

<route id="snmp-timer-route">
<from uri="timer://pulse?fixedRate=true&amp;period=1000" />
<to uri="seda:business-logic-route"/>

<route id="business-logic-route">
<from uri="seda:business-logic-endpoint"/>            
<setProperty propertyName="esq.route.name">
    <constant>TestRoute</constant>
</setProperty>
<process ref="messageMultiplierProcessor" />
<process ref="calculatedFieldsProcessor" />