public void testSSL() throws Exception { String text = RandomUtil.randomString(); tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true); tc.getParams() .put(TransportConstants.KEYSTORE_PATH_PROP_NAME, TransportConstants.DEFAULT_KEYSTORE_PATH); tc.getParams() .put( TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, TransportConstants.DEFAULT_KEYSTORE_PASSWORD); ServerLocator locator = addServerLocator(HornetQClient.createServerLocatorWithoutHA(tc)); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(CoreClientOverSSLTest.QUEUE, CoreClientOverSSLTest.QUEUE, false); ClientProducer producer = session.createProducer(CoreClientOverSSLTest.QUEUE); ClientMessage message = createTextMessage(session, text); producer.send(message); ClientConsumer consumer = session.createConsumer(CoreClientOverSSLTest.QUEUE); session.start(); Message m = consumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); }
public Map<String, Object>[] listMessages(final String filterStr) throws Exception { checkStarted(); clearIO(); try { Filter filter = FilterImpl.createFilter(filterStr); List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>(); queue.flushExecutor(); LinkedListIterator<MessageReference> iterator = queue.iterator(); try { while (iterator.hasNext()) { MessageReference ref = iterator.next(); if (filter == null || filter.match(ref.getMessage())) { Message message = ref.getMessage(); messages.add(message.toMap()); } } return messages.toArray(new Map[messages.size()]); } finally { iterator.close(); } } catch (HornetQException e) { throw new IllegalStateException(e.getMessage()); } finally { blockOnIO(); } }
public Map<String, Object>[] listScheduledMessages() throws Exception { checkStarted(); clearIO(); try { List<MessageReference> refs = queue.getScheduledMessages(); Map<String, Object>[] messages = new Map[refs.size()]; int i = 0; for (MessageReference ref : refs) { Message message = ref.getMessage(); messages[i++] = message.toMap(); } return messages; } finally { blockOnIO(); } }
private void internalTestCleanup(final JournalType journalType) throws Throwable { setupServer(journalType); ClientSession session = sf.createSession(false, true, true); ClientProducer prod = session.createProducer(CompactingStressTest.AD1); for (int i = 0; i < 500; i++) { prod.send(session.createMessage(true)); } session.commit(); prod.close(); ClientConsumer cons = session.createConsumer(CompactingStressTest.Q2); prod = session.createProducer(CompactingStressTest.AD2); session.start(); for (int i = 0; i < 200; i++) { System.out.println("Iteration " + i); // Sending non transactionally, so it would test non transactional stuff on the journal for (int j = 0; j < 1000; j++) { Message msg = session.createMessage(true); msg.getBodyBuffer().writeBytes(new byte[1024]); prod.send(msg); } // I need to guarantee a roundtrip to the server, to make sure everything is persisted session.commit(); for (int j = 0; j < 1000; j++) { ClientMessage msg = cons.receive(2000); Assert.assertNotNull(msg); msg.acknowledge(); } // I need to guarantee a roundtrip to the server, to make sure everything is persisted session.commit(); } Assert.assertNull(cons.receiveImmediate()); session.close(); server.stop(); setupServer(journalType); server.start(); session = sf.createSession(false, true, true); cons = session.createConsumer(CompactingStressTest.Q1); session.start(); for (int i = 0; i < 500; i++) { ClientMessage msg = cons.receive(1000); Assert.assertNotNull(msg); msg.acknowledge(); } Assert.assertNull(cons.receiveImmediate()); prod = session.createProducer(CompactingStressTest.AD2); session.close(); }