简体   繁体   English

如何在不使用数据库的情况下将消息存储在JMS队列中?

[英]How can I store messages in a JMS Queue without using a Database?

I have sent messages to a JMS Queue using a Servlet; 我已经使用Servlet将消息发送到JMS队列;
and there is Message Listener for that Queue 并且该队列有消息侦听器
but I m not using those messages anywhere; 但我不在任何地方使用这些消息;
but when I check the Messages in the Queue using WebLogic Admin console; 但是当我使用WebLogic管理控制台检查队列中的消息时; it is not displaying any messages although it is indicating that there are 20 messages in Total. 尽管它表示总共有20条消息,但它没有显示任何消息。
Kindly tell me what I can do to save the sent messages in the JMS Queue?? 请告诉我如何将发送的消息保存在JMS队列中?
Any guidance or suggestion would be highly appreciable. 任何指导或建议都是非常可取的。 Thank you! 谢谢!

I am not WebLogic expert but generally speaking: 我不是WebLogic专家,但通常来说:

The messages are saved by a JMS provider till they are consumed. 消息由JMS提供者保存,直到被使用为止。 So you don't need to do anything to save those message in a JMS queue. 因此,您无需执行任何操作即可将这些消息保存在JMS队列中。

It is possible that the message listener has already consumed those messages and the Admin Console is showing "Total messages processed" and not currently available messages? 消息侦听器可能已经使用了这些消息,并且管理控制台显示“已处理的消息总数”而不是当前不可用的消息?

Update 更新资料

Sample for sending persistent messages. 发送持久消息的示例。 Set the DeliverMode as PERSISTENT. 将DeliverMode设置为PERSISTENT。 All message sent using this producer will be Persistent. 使用此生产者发送的所有消息将保持不变。

            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue("TESTQ");

            // Create a MessageProducer from the Session to the Topic or Queue
            MessageProducer producer = session.createProducer(destination);
            // We want persistent messages
            producer.setDeliveryMode(DeliveryMode.PERSISTENT);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM