@Override protected Object createEntry(String name) { return ActiveMQJMSClient.createQueue(name); } });
@Override protected Object createEntry(String name) { return ActiveMQJMSClient.createTopic(name); } });
@Override protected ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception { JMSConnectionOptions options = newConectionOptions(uri, query); List<TransportConfiguration> configurations = TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName()); TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()]; configurations.toArray(tcs); ActiveMQConnectionFactory factory; if (options.isHa()) { factory = ActiveMQJMSClient.createConnectionFactoryWithHA(options.getFactoryTypeEnum(), tcs); } else { factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs); } return BeanSupport.setData(uri, factory, query); }
@Override protected ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception { JMSConnectionOptions options = newConectionOptions(uri, query); ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory")); return BeanSupport.setData(uri, factory, query); }
private ActiveMQConnectionFactory createConnectionFactory() throws Exception { Map<String, Object> params = new HashMap<>(); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "1"); final ActiveMQConnectionFactory activeMQConnectionFactory; if (configuration.getUrl() != null) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactory(configuration.getUrl(), null); } else { if (configuration.getHost() != null) { params.put(TransportConstants.HOST_PROP_NAME, configuration.getHost()); params.put(TransportConstants.PORT_PROP_NAME, configuration.getPort()); } if (configuration.isHa()) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); } else { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); } } if (configuration.hasAuthentication()) { activeMQConnectionFactory.setUser(configuration.getUsername()); activeMQConnectionFactory.setPassword(configuration.getPassword()); } // The CF will probably be GCed since it was injected, so we disable the finalize check return activeMQConnectionFactory.disableFinalizeChecks(); } }
@Override @Before public void setUp() throws Exception { super.setUp(); topic = ActiveMQJMSClient.createTopic(T_NAME); topic2 = ActiveMQJMSClient.createTopic(T2_NAME); jmsServer.createQueue(false, JmsConsumerTest.Q_NAME, null, true, JmsConsumerTest.Q_NAME); jmsServer.createTopic(true, T_NAME, "/topic/" + T_NAME); jmsServer.createTopic(true, T2_NAME, "/topic/" + T2_NAME); cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); }
@Override @Before public void setUp() throws Exception { super.setUp(); executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); server = createServer(createBasicConfig() .setPersistenceEnabled(false) .setAddressesSettings(Collections.singletonMap("#", new AddressSettings() .setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE) .setPageSizeBytes(50000) .setMaxSizeBytes(404850))) .setAcceptorConfigurations(Collections.singleton(new TransportConfiguration(NettyAcceptorFactory.class.getName())))); server.start(); cf = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616", "cf"); queue = ActiveMQJMSClient.createQueue("simple"); barrierLatch = new CyclicBarrier(PRODUCERS + 1); runnersLatch = new CountDownLatch(PRODUCERS + 1); msgReceived = new AtomicLong(0); msgSent = new AtomicLong(0); }
public static void waitForServerToStart(String uri, long timeout) throws InterruptedException { long realTimeout = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < realTimeout) { try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) { cf.createConnection().close(); System.out.println("server " + uri + " started"); } catch (Exception e) { System.out.println("awaiting server " + uri + " start at "); Thread.sleep(500); continue; } break; } }
ActiveMQConnectionFactory cf1 = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY, generateInVMParams(1))); cf1.setMinLargeMessageSize(200 * 1024);
/** * @return */ private ActiveMQConnectionFactory createConnectionFactory() { ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(NETTY_CONNECTOR_FACTORY)); connectionFactories.add(cf); return cf; } }
private ActiveMQConnectionFactory createConnectionFactory() throws Exception { Map<String, Object> params = new HashMap<>(); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "1"); final ActiveMQConnectionFactory activeMQConnectionFactory; if (configuration.getUrl() != null) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactory(configuration.getUrl(), null); } else { if (configuration.getHost() != null) { params.put(TransportConstants.HOST_PROP_NAME, configuration.getHost()); params.put(TransportConstants.PORT_PROP_NAME, configuration.getPort()); } if (configuration.isHa()) { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); } else { activeMQConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(configuration.getConnectorFactory(), params)); } } if (configuration.hasAuthentication()) { activeMQConnectionFactory.setUser(configuration.getUsername()); activeMQConnectionFactory.setPassword(configuration.getPassword()); } // The CF will probably be GCed since it was injected, so we disable the finalize check return activeMQConnectionFactory.disableFinalizeChecks(); } }
@Test public void testLargeJmsTextMessage() throws Exception { basicSetUp(); ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory("vm://0", "test"); Connection c = cf.createConnection(); Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE); server.createQueue(SimpleString.toSimpleString("A"), RoutingType.ANYCAST, SimpleString.toSimpleString("A"), null, true, false); MessageProducer p = s.createProducer(ActiveMQJMSClient.createQueue("A")); p.setDeliveryMode(DeliveryMode.PERSISTENT); StringBuilder stringBuilder = new StringBuilder(); MessageConsumer mc = s.createConsumer(ActiveMQJMSClient.createQueue("A")); c.start(); javax.jms.Message msg = mc.receive(CONSUMER_TIMEOUT);
public static void waitForServerToStart(String uri, long timeout) throws InterruptedException { long realTimeout = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < realTimeout) { try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) { cf.createConnection().close(); System.out.println("server " + uri + " started"); } catch (Exception e) { System.out.println("awaiting server " + uri + " start at "); Thread.sleep(500); continue; } break; } }
@Test public void testCreateQueue() throws Exception { liveJMSServer.createQueue(true, "queue1", null, true, "/queue/queue1"); assertNotNull(ctx1.lookup("/queue/queue1")); ActiveMQConnectionFactory jbcf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, livetc); jbcf.setReconnectAttempts(-1); Connection conn = null; try { conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); ClientSession coreSession = ((ActiveMQSession) sess).getCoreSession(); JMSUtil.crash(liveServer, coreSession); assertNotNull(ctx2.lookup("/queue/queue1")); } finally { if (conn != null) { conn.close(); } } }
@Override public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception { JMSConnectionOptions options = newConectionOptions(uri, query); DiscoveryGroupConfiguration dcConfig = JGroupsServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, name); ActiveMQConnectionFactory factory; if (options.isHa()) { factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dcConfig, options.getFactoryTypeEnum()); } else { factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum()); } return BeanSupport.setData(uri, factory, query); }
/** * Factory method to create new Queue instances */ protected Queue createQueue(String name) { return ActiveMQJMSClient.createQueue(name); }
/** * Factory method to create new Topic instances */ protected Topic createTopic(String name) { return ActiveMQJMSClient.createTopic(name); }
@Override protected ConnectionFactory getCF() throws Exception { ActiveMQJMSConnectionFactory cf1 = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); cf1.setAutoGroup(true); return cf1; }
break; case ArtemisCore: cf = ActiveMQJMSClient.createConnectionFactory(url, ""); break;
@Test public void testCreateTopic() throws Exception { liveJMSServer.createTopic(true, "topic", "/topic/t1"); assertNotNull(ctx1.lookup("//topic/t1")); ActiveMQConnectionFactory jbcf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, livetc); jbcf.setReconnectAttempts(-1); Connection conn = null; try { conn = JMSUtil.createConnectionAndWaitForTopology(jbcf, 2, 5); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); ClientSession coreSession = ((ActiveMQSession) sess).getCoreSession(); JMSUtil.crash(liveServer, coreSession); assertNotNull(ctx2.lookup("/topic/t1")); } finally { if (conn != null) { conn.close(); } } }