use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class MessageIdTest method createObject.
@Override
public Object createObject() throws Exception {
MessageId info = new MessageId();
populateObject(info);
return info;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class MessageIdTest method createObject.
@Override
public Object createObject() throws Exception {
MessageId info = new MessageId();
populateObject(info);
return info;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class FailoverTransportBrokerTest method createMessage.
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
ActiveMQTextMessage message = new ActiveMQTextMessage();
message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
message.setDestination(destination);
message.setPersistent(false);
try {
message.setText("Test Message Payload.");
} catch (MessageNotWriteableException e) {
}
return message;
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class PriorityNetworkDispatchPolicyTest method init.
@Before
public void init() throws Exception {
info.setDestination(ActiveMQDestination.createDestination("test", ActiveMQDestination.TOPIC_TYPE));
info.setConsumerId(id);
info.setNetworkSubscription(true);
info.setNetworkConsumerPath(new ConsumerId[] { id });
node.setMessageId(new MessageId("test:1:1:1:1"));
}
use of org.apache.activemq.command.MessageId in project activemq-artemis by apache.
the class DurableSubscriptionOfflineTest method testNoDuplicateOnConcurrentSendTranCommitAndActivate.
@Test(timeout = 60 * 1000)
public void testNoDuplicateOnConcurrentSendTranCommitAndActivate() throws Exception {
final int messageCount = 1000;
Connection con = null;
Session session = null;
final int numConsumers = 10;
for (int i = 0; i <= numConsumers; i++) {
con = createConnection("cli" + i);
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
session.createDurableSubscriber(topic, "SubsId", null, true);
session.close();
con.close();
}
class CheckForDupsClient implements Runnable {
HashSet<Long> ids = new HashSet<>();
final int id;
public CheckForDupsClient(int id) {
this.id = id;
}
@Override
public void run() {
try {
Connection con = createConnection("cli" + id);
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
for (int j = 0; j < 2; j++) {
MessageConsumer consumer = session.createDurableSubscriber(topic, "SubsId", null, true);
for (int i = 0; i < messageCount / 2; i++) {
Message message = consumer.receive(4000);
assertNotNull(message);
long producerSequenceId = new MessageId(message.getJMSMessageID()).getProducerSequenceId();
assertTrue("ID=" + id + " not a duplicate: " + producerSequenceId, ids.add(producerSequenceId));
}
consumer.close();
}
// verify no duplicates left
MessageConsumer consumer = session.createDurableSubscriber(topic, "SubsId", null, true);
Message message = consumer.receive(4000);
if (message != null) {
long producerSequenceId = new MessageId(message.getJMSMessageID()).getProducerSequenceId();
assertTrue("ID=" + id + " not a duplicate: " + producerSequenceId, ids.add(producerSequenceId));
}
assertNull(message);
session.close();
con.close();
} catch (Throwable e) {
e.printStackTrace();
exceptions.add(e);
}
}
}
final String payLoad = new String(new byte[1000]);
con = createConnection();
final Session sendSession = con.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer producer = sendSession.createProducer(topic);
for (int i = 0; i < messageCount; i++) {
producer.send(sendSession.createTextMessage(payLoad));
}
ExecutorService executorService = Executors.newCachedThreadPool();
// concurrent commit and activate
executorService.execute(new Runnable() {
@Override
public void run() {
try {
sendSession.commit();
} catch (JMSException e) {
e.printStackTrace();
exceptions.add(e);
}
}
});
for (int i = 0; i < numConsumers; i++) {
executorService.execute(new CheckForDupsClient(i));
}
executorService.shutdown();
executorService.awaitTermination(5, TimeUnit.MINUTES);
con.close();
assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
}
Aggregations