简体   繁体   English

是否可以在Java中的MQ队列启动中加载消息

[英]Is it possible to load a message in Start of MQ Queue in java

I am using IBM MQ API to connect to the queue to load my messages from a file. 我正在使用IBM MQ API连接到队列以从文件加载消息。 I use javax.jms.QueueSender to load the messages to my queue 'TEST.IBM.Q'. 我使用javax.jms.QueueSender将消息加载到队列“ TEST.IBM.Q”。

I have a functionality to load the number of valid messages from a file to be loaded as the first message. 我有一个功能,可以从文件中加载有效消息的数量,以作为第一条消息加载。

Example: Say I have a file called File1.txt: 示例:说我有一个名为File1.txt的文件:

Valid
Valid
Valid
Invalid
Valid

Here, I will load 5 messages to my queue like below, 在这里,我将加载5条消息到我的队列中,如下所示,

Count-4
Valid
Valid
Valid
Valid

Currently, I am iterating throughout the file to find the number of valid messages and loading it in the start & iterating again to load the messages. 目前,我正在遍历整个文件以查找有效消息的数量,并在开始时将其加载并再次进行迭代以加载消息。

I know, its a bad way of doing it. 我知道,这样做很不好。 Some one could you please let me know, Is there any possibility to load a message in the start of the queue once everything is done? 您可能会让我知道,一旦一切完成,是否有可能在队列的开头加载一条消息?

Thanks in advance to everyone!! 在此先感谢大家!

By default, in IBM MQ, messages are delivered on a priority basis, higher priority messages are delivered first followed by lower priority messages. 缺省情况下,在IBM MQ中,消息是按优先级传递的,优先级较高的消息先传递,然后优先级较低的消息。

You can make use of this feature. 您可以使用此功能。 Set different priorities for valid and invalid messages. 为有效和无效消息设置不同的优先级。 If you want the valid messages to be delivered first, then set a higher priority for valid messages and lower priority to invalid messages. 如果要先发送有效消息,则为有效消息设置较高的优先级,为无效消息设置较低的优先级。

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

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