本文整理了Java中org.apache.activemq.artemis.api.core.Message.setPriority()
方法的一些代码示例,展示了Message.setPriority()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setPriority()
方法的具体详情如下:
包路径:org.apache.activemq.artemis.api.core.Message
类名称:Message
方法名:setPriority
[英]Sets the message priority.
Value must be between 0 and 9 inclusive.
[中]
代码示例来源:origin: apache/activemq-artemis
msg.setPriority(Byte.parseByte(priority));
} else {
msg.setPriority(Byte.parseByte(DEFAULT_MESSAGE_PRIORITY));
代码示例来源:origin: org.apache.activemq/artemis-stomp-protocol
msg.setPriority(Byte.parseByte(priority));
} else {
msg.setPriority(Byte.parseByte(DEFAULT_MESSAGE_PRIORITY));
代码示例来源:origin: apache/activemq-artemis
@Override
public synchronized boolean changeReferencePriority(final long messageID, final byte newPriority) throws Exception {
try (LinkedListIterator<MessageReference> iter = iterator()) {
while (iter.hasNext()) {
MessageReference ref = iter.next();
if (ref.getMessage().getMessageID() == messageID) {
iter.remove();
refRemoved(ref);
ref.getMessage().setPriority(newPriority);
addTail(ref, false);
return true;
}
}
return false;
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public synchronized int changeReferencesPriority(final Filter filter, final byte newPriority) throws Exception {
try (LinkedListIterator<MessageReference> iter = iterator()) {
int count = 0;
while (iter.hasNext()) {
MessageReference ref = iter.next();
if (filter == null || filter.match(ref.getMessage())) {
count++;
iter.remove();
refRemoved(ref);
ref.getMessage().setPriority(newPriority);
addTail(ref, false);
}
}
return count;
}
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testWithPriorities() throws Exception {
QueueImpl queue = getTemporaryQueue();
final int numMessages = 10;
List<MessageReference> refs = new ArrayList<>();
for (int i = 0; i < numMessages; i++) {
MessageReference ref = generateReference(queue, i);
ref.getMessage().setPriority((byte) i);
refs.add(ref);
queue.addTail(ref);
}
queue.deliverNow();
FakeConsumer consumer = new FakeConsumer();
queue.addConsumer(consumer);
queue.deliverNow();
List<MessageReference> receivedRefs = consumer.getReferences();
// Should be in reverse order
Assert.assertEquals(refs.size(), receivedRefs.size());
for (int i = 0; i < numMessages; i++) {
Assert.assertEquals(refs.get(i), receivedRefs.get(9 - i));
}
}
代码示例来源:origin: apache/activemq-artemis
@Test
public void testAMQPriority() throws Exception {
filter = FilterImpl.createFilter(new SimpleString("AMQPriority=3"));
for (int i = 0; i < 10; i++) {
message.setPriority((byte) i);
if (i == 3) {
Assert.assertTrue(filter.match(message));
} else {
Assert.assertFalse(filter.match(message));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!