获取警报 - Activemq 骆驼

Get alert - Activemq camel(获取警报 - Activemq 骆驼)

本文介绍了获取警报 - Activemq 骆驼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序:activemq的消费者已经在运行,所以如果Activemq中有消息,它就会消费并处理它.

My Application: Consumer of activemq is already running so it will consume if there is message in Activemq and process it.

如果我的逻辑有任何故障,我想得到警报.首先,如果我的逻辑有任何故障,我会尝试重新发送我的消息 3 次,然后发送到 DLQ,在 3 次重新发送后,我想通过邮件获得警报.我已经完成了通过单击 sendMail.bat 文件发送邮件的代码.我在 java 中有消费者代码,现在我想在消息转到 DLQ 之前运行 sendMail.bat 文件.这是我在 bean.xml 中的代码.

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>

让我们假设要从 java 应用程序运行 sendMail.bat 文件.所以我要在我的应用程序(ActivemqCamel) 中再创建一个java(TriggerMail.class) 文件并执行我的sendMail.bat.我不知道在我的 bean.xml 中将这个 TriggerMail.class 链接到哪里?谁能帮帮我?

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?

推荐答案

如果你当前将失败的消息发送到 activemq:queue:ThermalMap.DLQ 你可以做的是

If you currently send your failed messages to activemq:queue:ThermalMap.DLQ what you could do is

将你的 errorHandler 的 deadLetterUri 更改为 activemq:queue:ThermalMap.TMP,

change the deadLetterUri of your errorHandler to activemq:queue:ThermalMap.TMP,

然后创建一个简单的路由

then create a simple route that would

  • 使用来自 activemq:queue:ThermalMap.TMP 的消息
  • 发送电子邮件
  • 然后将消息发送到activemq:queue:ThermalMap.DLQ

我相信还有很多其他方法可以实现您想要的.

I'm sure there are plenty of other ways to accomplish what you want.

这篇关于获取警报 - Activemq 骆驼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:获取警报 - Activemq 骆驼

基础教程推荐