use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class QueueDuplicatesFromStoreTest method getMessage.
private Message getMessage(int i) throws Exception {
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setMessageId(new MessageId(mesageIdRoot + i));
message.setDestination(destination);
message.setPersistent(true);
message.setResponseRequired(true);
message.setText("Msg:" + i + " " + text);
assertEquals(message.getMessageId().getProducerSequenceId(), i);
return message;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class QueueOptimizedDispatchExceptionTest method getMessage.
private Message getMessage(int i) throws Exception {
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setMessageId(new MessageId(mesageIdRoot + i));
message.setDestination(destination);
message.setPersistent(false);
message.setResponseRequired(true);
message.setText("Msg:" + i + " " + text);
assertEquals(message.getMessageId().getProducerSequenceId(), i);
return message;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class SubscriptionAddRemoveQueueTest method testNoDispatchToRemovedConsumers.
public void testNoDispatchToRemovedConsumers() throws Exception {
final AtomicInteger producerId = new AtomicInteger();
Runnable sender = new Runnable() {
@Override
public void run() {
AtomicInteger id = new AtomicInteger();
int producerIdAndIncrement = producerId.getAndIncrement();
while (working) {
try {
Message msg = new ActiveMQMessage();
msg.setDestination(destination);
msg.setMessageId(new MessageId(producerIdAndIncrement + ":0:" + id.getAndIncrement()));
queue.send(producerBrokerExchange, msg);
} catch (Exception e) {
e.printStackTrace();
fail("unexpected exception in sendMessage, ex:" + e);
}
}
}
};
Runnable subRemover = new Runnable() {
@Override
public void run() {
for (Subscription sub : subs) {
try {
queue.removeSubscription(context, sub, 0);
} catch (Exception e) {
e.printStackTrace();
fail("unexpected exception in removeSubscription, ex:" + e);
}
}
}
};
for (int i = 0; i < numSubscriptions; i++) {
SimpleImmediateDispatchSubscription sub = new SimpleImmediateDispatchSubscription();
subs.add(sub);
queue.addSubscription(context, sub);
}
assertEquals("there are X subscriptions", numSubscriptions, queue.getDestinationStatistics().getConsumers().getCount());
ExecutorService executor = Executors.newCachedThreadPool();
for (int i = 0; i < senders; i++) {
executor.submit(sender);
}
Thread.sleep(1000);
for (SimpleImmediateDispatchSubscription sub : subs) {
assertTrue("There are some locked messages in the subscription", hasSomeLocks(sub.dispatched));
}
Future<?> result = executor.submit(subRemover);
result.get();
working = false;
assertEquals("there are no subscriptions", 0, queue.getDestinationStatistics().getConsumers().getCount());
for (SimpleImmediateDispatchSubscription sub : subs) {
assertTrue("There are no locked messages in any removed subscriptions", !hasSomeLocks(sub.dispatched));
}
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class StoreQueueCursorNoDuplicateTest method getMessage.
private ActiveMQTextMessage getMessage(int i) throws Exception {
ActiveMQTextMessage message = new ActiveMQTextMessage();
MessageId id = new MessageId(mesageIdRoot + i);
id.setBrokerSequenceId(i);
id.setProducerSequenceId(i);
message.setMessageId(id);
message.setDestination(destination);
message.setPersistent(true);
message.setResponseRequired(true);
message.setText("Msg:" + i + " " + text);
assertEquals(message.getMessageId().getProducerSequenceId(), i);
return message;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class StoreQueueCursorOrderTest method getMessage.
private ActiveMQTextMessage getMessage(int i) throws Exception {
ActiveMQTextMessage message = new ActiveMQTextMessage();
MessageId id = new MessageId(mesageIdRoot + i);
id.setBrokerSequenceId(i);
id.setProducerSequenceId(i);
message.setMessageId(id);
message.setDestination(destination);
message.setPersistent(true);
message.setResponseRequired(true);
message.setText("Msg:" + i + " " + text);
assertEquals(message.getMessageId().getProducerSequenceId(), i);
return message;
}
Aggregations