हमारी ओर से हम ActiveMQ सेवा में तैनात ऊंट मार्ग का उपयोग कर विशिष्ट स्थलों पर समाप्ति समय जोड़ना चुनते हैं।
ऐसा करने के लिए एकमात्र चीज एक्सएमएल फ़ाइल बनाना जैसे नाम के साथ निम्नलिखित है। setJMSExpiration.xml
:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel-set-expiration" xmlns="http://camel.apache.org/schema/spring">
<!-- Copy route for each destination to expire -->
<route id="setJMSExpiration.my.queue.dlq">
<from uri="broker:queue:MY.QUEUE.DLQ"/>
<setHeader headerName="JMSExpiration">
<!-- Message will expire after 1 day -->
<spel>#{T(java.lang.System).currentTimeMillis() + 86400000}</spel>
</setHeader>
<to uri="broker:queue:MY.QUEUE.DLQ"/>
</route>
<route id="setJMSExpiration.another.queue">
<from uri="broker:queue:ANOTHER.QUEUE"/>
<setHeader headerName="JMSExpiration">
<!-- Message will expire after 5 days -->
<spel>#{T(java.lang.System).currentTimeMillis() + 432000000}</spel>
</setHeader>
<to uri="broker:queue:ANOTHER.QUEUE"/>
</route>
</camelContext>
</beans>
और के साथ अपने activemq.xml
config में आयात:
<!-- Add default Expiration (file in the same directory) -->
<import resource="setJMSExpiration.xml"/>
वैकल्पिक रूप से आप भी विशिष्ट per destination policies प्रदान कर सकते हैं यदि आप नहीं करते की अवधि समाप्त हो गए संदेशों ActiveMQ.DLQ कतार पहुंचना चाहते हैं।
<policyEntry queue="MY.QUEUE.DLQ">
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
<policyEntry queue="ANOTHER.QUEUE">
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
इस तरह का केवल सीमा यह है कि आप आसानी से वाइल्डकार्ड का उपयोग नहीं कर सकते हैं के रूप में यह यहाँ कोडित है (आप कर सकते हैं, लेकिन यह ऊंट मार्ग में JMS गंतव्य हैडर का उपयोग करके कुछ रूपांतरों की आवश्यकता होगी) है।
हम निर्माता को समय को परिभाषित करने की कोशिश करते हैं (और जितना संभव हो सके उन्हें मजबूर करें) लेकिन इन मार्गों की संख्या को कम करने के लिए उन्हें अपने कोड को बदलने के लिए मजबूर करना हमेशा संभव नहीं होता है।
स्रोत
2017-07-21 12:24:01
वादा करता है, मैं इसे एक शॉट –