private void handleRegularMessage(ClientMessageInternal message) { if (message.getAddress() == null) { message.setAddressTransient(queueInfo.getAddress()); } message.onReceipt(this); if (!ackIndividually && message.getPriority() != 4 && !message.containsProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE)) { // We have messages of different priorities so we need to ack them individually since the // order // of them in the ServerConsumerImpl delivery list might not be the same as the order they are // consumed in, which means that acking all up to won't work ackIndividually = true; } // Add it to the buffer buffer.addTail(message, message.getPriority()); if (handler != null) { // Execute using executor if (!stopped) { queueExecutor(); } } else { notify(); } }
private boolean subscriptionExists(String subscriptionId) { ClientSession session = null; try { session = sessionFactory.createSession(); ClientSession.QueueQuery query = session.queueQuery(new SimpleString(subscriptionId)); return query.isExists(); } catch (ActiveMQException e) { throw new RuntimeException(e); } finally { if (session != null) { try { session.close(); } catch (ActiveMQException e) { } } } }
public void testDuplicate() throws Exception { ActiveMQDestination queue = (ActiveMQDestination) session.createQueue("TEST,TEST"); for (int i = 0; i < data.length; i++) { Message message = createMessage(i); configureMessage(message); if (verbose) { LOG.info("About to send a message: " + message + " with text: " + data[i]); } producer.send(queue, message); } Thread.sleep(200); // wait for messages to be queue; try (ServerLocator locator = ServerLocatorImpl.newLocator("tcp://localhost:61616"); ClientSessionFactory factory = locator.createSessionFactory(); ClientSession session = factory.createSession()) { ClientSession.QueueQuery query = session.queueQuery(new SimpleString("jms.queue.TEST")); assertNotNull(query); assertEquals(data.length, query.getMessageCount()); } }
@Test public void testBindingAttributes() throws Exception { ClientSession session = basicSetUp(); session.createQueue("addressName1", "queueName1", true); session.createQueue("addressName1", "queueName2", "bob", true); session.close(); locator.close(); server.stop(); ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream(); XmlDataExporter xmlDataExporter = new XmlDataExporter(); xmlDataExporter.process( xmlOutputStream, server.getConfiguration().getBindingsDirectory(), server.getConfiguration().getJournalDirectory(), server.getConfiguration().getPagingDirectory(), server.getConfiguration().getLargeMessagesDirectory()); System.out.print(new String(xmlOutputStream.toByteArray())); clearDataRecreateServerDirs(); server.start(); locator = createInVMNonHALocator(); factory = createSessionFactory(locator); session = factory.createSession(false, true, true); ByteArrayInputStream xmlInputStream = new ByteArrayInputStream(xmlOutputStream.toByteArray()); XmlDataImporter xmlDataImporter = new XmlDataImporter(); xmlDataImporter.process(xmlInputStream, session); ClientSession.QueueQuery queueQuery = session.queueQuery(new SimpleString("queueName1")); assertEquals("addressName1", queueQuery.getAddress().toString()); assertNull(queueQuery.getFilterString()); queueQuery = session.queueQuery(new SimpleString("queueName2")); assertEquals("addressName1", queueQuery.getAddress().toString()); assertEquals("bob", queueQuery.getFilterString().toString()); assertEquals(true, queueQuery.isDurable()); }