如何在ActiveMQ中查看出队消息 [英] How to see Dequeued messages in ActiveMQ

查看:184
本文介绍了如何在ActiveMQ中查看出队消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从动态队列(ActiveMQ)中读取消息时(待处理消息= 1000),我已经确认了每条消息,现在已出队的消息数= 1000。

While reading messages from a dynamic queue(ActiveMQ)(Pending Messages=1000), i had acknowledge each message,now the number of Messages Dequeued=1000.

有什么办法可以将所有出队消息再次放入Queue。
任何可物理备份所有消息的解决方案。

Is there any way to place all dequeued messages again into Queue. Any solution to get all messages backup physically.

预先感谢

推荐答案

当需要邮件正文时备份已排队的邮件:
可以将其添加到 activemq.xml
中,这会将邮件副本保存到 $ {activemq.base} / bin / data / activemq /
a下的文件按天和队列排列

to backup enqueued messages when you need the body of messages : you can add this to your activemq.xml this will save a copy of messages to a file under ${activemq.base}/bin/data/activemq/ a file by day and queue

<bean  id="ActiveMQVMConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="vm://localhost?create=false&amp;waitForStart=10000"/>
    <property name="userName" value="${activemq.username}"/>
    <property name="password" value="${activemq.password}"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
    <property name="connectionFactory" ref="ActiveMQVMConnectionFactory"/>
</bean>


<camelContext id="camel" trace="false" xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="activemq:queue:*?mapJmsMessage=false&amp;selector=CamelFileNameProduced IS NULL" />
        <choice>
            <when>
                <simple>${in.headers.CamelFileNameProduced} == null</simple>
                <setHeader headerName="CamelJmsDestinationName">
                    <simple>${in.header.JMSDestination.physicalName}</simple>
                </setHeader>
                <transform>
                    <simple>${in.body}\n</simple>
                </transform> 
                <to uri="file://data/activemq/?fileExist=Append&amp;fileName=routeMessages-${in.header.JMSDestination.physicalName}-${date:now:yyyyMMdd}.txt" />
                <to uri="activemq:dummy" />
            </when>
        </choice>
    </route> 
</camelContext>

如果只需要元数据:

        Destination advisoryDestination = session.createTopic("ActiveMQ.Advisory.MessageConsumed.>");
        MessageConsumer consumer = session.createConsumer(advisoryDestination);
        consumer.setMessageListener(new MessageListener() {
            @Override
            public void onMessage(Message msg) {
                System.out.println(msg);
                System.out.println(((ActiveMQMessage) msg).getMessageId());
            }
        });

http://activemq.apache.org/advisory-message.html

这篇关于如何在ActiveMQ中查看出队消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆