class PingInvoker { public PingInvoker() { // TODO Auto-generated constructor stub Timer timer = new Timer(); timer.schedule(new Mytask(), 0, period); } public void ping() { List<Server> svr = Manager.getList(); for (Server i : svr) i.ping(); } static class MyTask extends TimerTask { @Override public void run() { ping(); } }
protected void setSecurityConfigOnManager(final String destination, final boolean isQueue, final Set<Role> roles) throws Exception { ActiveMQServerTestCase.servers.get(0).configureSecurityForDestination(destination, isQueue, roles); }
public void createQueue(final String name) throws Exception { ActiveMQServerTestCase.servers.get(0).createQueue(name, null); }
protected boolean assertRemainingMessages(final int expected) throws Exception { String queueName = "Queue1"; Binding binding = servers.get(0).getActiveMQServer().getPostOffice().getBinding(SimpleString.toSimpleString(queueName)); if (binding != null && binding instanceof LocalQueueBinding) { ((LocalQueueBinding) binding).getQueue().flushExecutor(); } Long messageCount = null; for (int i = 0; i < 10; i++) { messageCount = servers.get(0).getMessageCountForQueue(queueName); if (messageCount.longValue() == expected) { break; } else { Thread.sleep(100); } } ProxyAssertSupport.assertEquals(expected, messageCount.intValue()); return expected == messageCount.intValue(); }
public static void deployConnectionFactory(final String clientId, final String objectName, final String... jndiBindings) throws Exception { ActiveMQServerTestCase.servers.get(0).deployConnectionFactory(clientId, objectName, jndiBindings); }
protected ActiveMQServer getJmsServer() throws Exception { return ActiveMQServerTestCase.servers.get(0).getActiveMQServer(); }
protected Long getMessageCountForQueue(final String s) throws Exception { return ActiveMQServerTestCase.servers.get(0).getMessageCountForQueue(s); }
public void destroyQueue(final String name, final int i) throws Exception { ActiveMQServerTestCase.servers.get(i).destroyQueue(name, null); }
public void createTopic(final String name) throws Exception { ActiveMQServerTestCase.servers.get(0).createTopic(name, null); }
public void destroyTopic(final String name) throws Exception { ActiveMQServerTestCase.servers.get(0).destroyTopic(name, null); }
protected Set<Role> getSecurityConfig() throws Exception { return ActiveMQServerTestCase.servers.get(0).getSecurityConfig(); }
public static void deployConnectionFactory(final int server, final String objectName, final int prefetchSize, final String... jndiBindings) throws Exception { ActiveMQServerTestCase.servers.get(server).deployConnectionFactory(objectName, prefetchSize, jndiBindings); }
protected static void assertActiveConnectionsOnTheServer(final int expectedSize) throws Exception { ProxyAssertSupport.assertEquals(expectedSize, ActiveMQServerTestCase.servers.get(0).getActiveMQServer().getActiveMQServerControl().getConnectionCount()); }
public boolean checkEmpty(final Queue queue) throws Exception { Long messageCount = ActiveMQServerTestCase.servers.get(0).getMessageCountForQueue(queue.getQueueName()); if (messageCount > 0) { removeAllMessages(queue.getQueueName(), true); } return true; }
public void destroyQueue(final String name) throws Exception { ActiveMQServerTestCase.servers.get(0).destroyQueue(name, null); }
public void createTopic(final String name, final int i) throws Exception { ActiveMQServerTestCase.servers.get(i).createTopic(name, null); }
public static void deployConnectionFactory(final int server, JMSFactoryType type, final String objectName, final String... jndiBindings) throws Exception { ActiveMQServerTestCase.servers.get(server).deployConnectionFactory(objectName, type, jndiBindings); }
@Test public void testSendToQueueOnlyWhenTopicWithSameAddress() throws Exception { SimpleString addr = SimpleString.toSimpleString("testAddr"); EnumSet<RoutingType> supportedRoutingTypes = EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST); servers.get(0).getActiveMQServer().addAddressInfo(new AddressInfo(addr, supportedRoutingTypes)); servers.get(0).getActiveMQServer().createQueue(addr, RoutingType.ANYCAST, addr, null, false, false); Connection pconn = createConnection(); pconn.start(); Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = ps.createQueue(addr.toString()); Topic topic = ps.createTopic(addr.toString()); MessageConsumer queueConsumer = ps.createConsumer(queue); MessageConsumer topicConsumer = ps.createConsumer(topic); MessageProducer queueProducer = ps.createProducer(queue); queueProducer.send(ps.createMessage()); assertNotNull(queueConsumer.receive(1000)); assertNull(topicConsumer.receive(1000)); MessageProducer topicProducer = ps.createProducer(topic); topicProducer.send(ps.createMessage()); assertNull(queueConsumer.receive(1000)); assertNotNull(topicConsumer.receive(1000)); }
public void createQueue(final String name, final int i) throws Exception { ActiveMQServerTestCase.servers.get(i).createQueue(name, null); }