use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.
the class OpenWireProtocolManagerTest method testVtAutoConversion.
@Test
public void testVtAutoConversion() throws Exception {
underTest = new OpenWireProtocolManager(null, new DummyServer()) {
@Override
public ActiveMQDestination virtualTopicConsumerToFQQN(ActiveMQDestination destination) {
if (lruCacheRef == null) {
lruCacheRef = vtDestMapCache;
}
return super.virtualTopicConsumerToFQQN(destination);
}
};
final int maxCacheSize = 10;
underTest.setVirtualTopicConsumerLruCacheMax(10);
underTest.setVirtualTopicConsumerWildcards("A.>;1,B.*.>;2,C.*.*.*.EE;3");
ActiveMQDestination A = new org.apache.activemq.command.ActiveMQQueue("A.SomeTopic");
assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic::A"), underTest.virtualTopicConsumerToFQQN(A));
ActiveMQDestination B = new org.apache.activemq.command.ActiveMQQueue("B.b.SomeTopic.B");
assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic.B::B.b"), underTest.virtualTopicConsumerToFQQN(B));
ActiveMQDestination C = new org.apache.activemq.command.ActiveMQQueue("C.c.c.SomeTopic.EE");
assertEquals(new org.apache.activemq.command.ActiveMQQueue("SomeTopic.EE::C.c.c"), underTest.virtualTopicConsumerToFQQN(C));
for (int i = 0; i < maxCacheSize; i++) {
ActiveMQDestination identity = new org.apache.activemq.command.ActiveMQQueue("Identity" + i);
assertEquals(identity, underTest.virtualTopicConsumerToFQQN(identity));
}
assertFalse(lruCacheRef.containsKey(A));
}
use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.
the class BacklogNetworkCrossTalkTest method testProduceConsume.
public void testProduceConsume() throws Exception {
createBroker("A");
createBroker("B");
NetworkConnector nc = bridgeBrokers("A", "B");
nc.setDuplex(true);
nc.setDispatchAsync(false);
startAllBrokers();
waitForBridgeFormation();
final int numMessages = 10000;
// Create queue
ActiveMQDestination destA = createDestination("AAA", false);
sendMessages("A", destA, numMessages);
ActiveMQDestination destB = createDestination("BBB", false);
sendMessages("B", destB, numMessages);
// consume across network
LOG.info("starting consumers..");
// Setup consumers
MessageConsumer clientA = createConsumer("A", destB);
// Setup consumers
MessageConsumer clientB = createConsumer("B", destA);
final long maxWait = 5 * 60 * 1000L;
MessageIdList listA = getConsumerMessages("A", clientA);
listA.setMaximumDuration(maxWait);
listA.waitForMessagesToArrive(numMessages);
MessageIdList listB = getConsumerMessages("B", clientB);
listB.setMaximumDuration(maxWait);
listB.waitForMessagesToArrive(numMessages);
assertEquals("got all on A" + listA.getMessageCount(), numMessages, listA.getMessageCount());
assertEquals("got all on B" + listB.getMessageCount(), numMessages, listB.getMessageCount());
}
use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.
the class BatchedMessagePriorityConsumerTest method doTestBatchWithLowPriorityFirst.
public void doTestBatchWithLowPriorityFirst(boolean clientPrioritySupport) throws Exception {
connection.start();
connection.setMessagePrioritySupported(clientPrioritySupport);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
MessageProducer producer = session.createProducer(destination);
producer.setPriority(0);
sendMessages(session, producer, 2);
producer.close();
MessageProducer producer2 = session.createProducer(destination);
producer2.setPriority(9);
sendMessages(session, producer2, 3);
producer2.close();
session.close();
Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageConsumer messageConsumer = consumerSession.createConsumer(destination);
for (int i = 0; i < 5; i++) {
Message message = messageConsumer.receive(4000);
LOG.info("MessageID: " + message.getJMSMessageID());
}
consumerSession.commit();
consumerSession.close();
// should be nothing left
consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
messageConsumer = consumerSession.createConsumer(destination);
assertNull("No message left", messageConsumer.receive(1000));
consumerSession.close();
}
use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.
the class GeneralInteropTest method sendBytesMessageUsingOpenWire.
private void sendBytesMessageUsingOpenWire(byte[] bytesData) throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
System.out.println("destination: " + destination);
final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
BytesMessage bytesMessage = session.createBytesMessage();
bytesMessage.writeBytes(bytesData);
bytesMessage.writeBoolean(true);
bytesMessage.writeLong(99999L);
bytesMessage.writeChar('h');
bytesMessage.writeInt(987);
bytesMessage.writeShort((short) 1099);
bytesMessage.writeUTF("hellobytes");
producer.send(bytesMessage);
}
use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.
the class GeneralInteropTest method sendObjectMessageUsingOpenWire.
private void sendObjectMessageUsingOpenWire(SimpleSerializable obj) throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
System.out.println("destination: " + destination);
final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
ObjectMessage objectMessage = session.createObjectMessage(obj);
producer.send(objectMessage);
}
Aggregations