问题
My Application: Consumer of activemq is already running so it will consume if there is message in Activemq and process it.
I want to get alert If there is any failure in my logic. First I try to re delivery my message 3 times if there is any failure in my logic and then send to DLQ
, after 3 times re delivery I want to get alert by mail. I have done code to send mail by click a sendMail.bat
file. I have consumer code in java, now I want to run sendMail.bat
file before the message go to DLQ
. This is code I have in bean.xml.
<!-- here we configure our DeadLetterChannel -->
<bean id="myDeadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
<property name="deadLetterUri" value="activemq:queue:ThermalMap.DLQ"/>
<property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>
</bean>
<!-- here we set the redelivery settings -->
<bean id="myRedeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy">
<property name="maximumRedeliveries" value="3"/>
<property name="redeliveryDelay" value="250"/>
</bean>
<camelContext id="activeContext1" xmlns="http://camel.apache.org/schema/spring">
<route startupOrder="1" errorHandlerRef="myDeadLetterErrorHandler">
<from uri="activemq:queue:ThermalMap"/>
<transacted/>
<to uri="bean:msgPro1?Method=Processor1"/>
</route>
</camelContext>
Let us assume am going to run sendMail.bat
file from java application. so am going to create one more java(TriggerMail.class) file in my application(ActivemqCamel) and execute my sendMail.bat
. I don't know where to link this TriggerMail.class
in my bean.xml? Can any one help me?
回答1:
If you currently send your failed messages to activemq:queue:ThermalMap.DLQ what you could do is
change the deadLetterUri of your errorHandler to activemq:queue:ThermalMap.TMP,
then create a simple route that would
- consume message from activemq:queue:ThermalMap.TMP,
- send an email
- and then send the message to activemq:queue:ThermalMap.DLQ
I'm sure there are plenty of other ways to accomplish what you want.
来源:https://stackoverflow.com/questions/19045781/get-alert-activemq-camel