public ArtemisBenchmarkProducer(String address, ClientSessionFactory sessionFactory) throws ActiveMQException { session = sessionFactory.createSession(); producer = session.createProducer(address); session.start(); }
protected void createSession() throws ActiveMQException { session = factory.createSession(true, true, 0); ActiveMQRestLogger.LOGGER.debug("Created session: " + session); if (selector == null) { consumer = session.createConsumer(destination); } else { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(selector)); } ActiveMQRestLogger.LOGGER.debug("Created consumer: " + consumer); session.start(); }
@Test public void testBasicReceive() throws Exception { ClientSessionFactory cf = createSessionFactory(locator); ClientSession sendSession = cf.createSession(false, true, true); ClientProducer cp = sendSession.createProducer(addressA); ClientSession session = cf.createSession(false, true, true); session.createQueue(addressA, queueA, false); ClientConsumer cc = session.createConsumer(queueA); session.start(); cp.send(sendSession.createMessage(false)); Assert.assertNotNull(cc.receive()); session.close(); sendSession.close(); }
@Test public void testCreateMessageDurable() throws Exception { cf = createSessionFactory(locator); ClientSession clientSession = cf.createSession(false, true, true); ClientMessage clientMessage = clientSession.createMessage(true); Assert.assertTrue(clientMessage.isDurable()); clientSession.close(); }
@Test public void testAutoDeleteAutoCreatedQueue() throws Exception { // auto-delete-queues defaults to true server.createQueue(addressA, RoutingType.ANYCAST, queueA, null, null, true, false, false, false, true, 1, false, true); assertNotNull(server.locateQueue(queueA)); cf.createSession().createConsumer(queueA).close(); assertNull(server.locateQueue(queueA)); }
private void createClients(final boolean createQueue, final boolean commitACKs) throws Exception { locator = createInVMNonHALocator(); sessionFactory = createSessionFactory(locator); clientSession = sessionFactory.createSession(true, false, commitACKs); if (createQueue) { clientSession.createQueue(atestq, atestq, null, true); } clientProducer = clientSession.createProducer(atestq); clientConsumer = clientSession.createConsumer(atestq); }
@Test public void testStart() throws Exception { cf = createSessionFactory(locator); ClientSession clientSession = cf.createSession(false, true, true); clientSession.createQueue(queueName, queueName, false); clientSession.start(); clientSession.close(); }
@Test public void testCreateMessageType() throws Exception { cf = createSessionFactory(locator); ClientSession clientSession = cf.createSession(false, true, true); ClientMessage clientMessage = clientSession.createMessage((byte) 99, false); Assert.assertEquals((byte) 99, clientMessage.getType()); clientSession.close(); }
@Test public void testAutoDeleteAutoCreatedAddress() throws Exception { // auto-delete-addresses defaults to true server.createQueue(addressA, RoutingType.ANYCAST, queueA, null, null, true, false, false, false, true, 1, false, true); assertNotNull(server.getAddressInfo(addressA)); cf.createSession().createConsumer(queueA).close(); assertNull(server.getAddressInfo(addressA)); }
protected void createSession() throws ActiveMQException { session = factory.createSession(true, true, 0); ActiveMQRestLogger.LOGGER.debug("Created session: " + session); if (selector == null) { consumer = session.createConsumer(destination); } else { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(selector)); } ActiveMQRestLogger.LOGGER.debug("Created consumer: " + consumer); session.start(); }
protected void addPooled() throws ActiveMQException { ClientSession session = sessionFactory.createSession(); ClientProducer producer = session.createProducer(destination); session.start(); pool.add(new Pooled(session, producer)); }
@Test public void testCoreHttpClientIdle() throws Exception { locator.setConnectionTTL(500); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); session.createQueue(QUEUE, QUEUE, null, false); ClientProducer producer = session.createProducer(QUEUE); Thread.sleep(500 * 5); session.close(); }
@Test public void testCreateMessageNonDurable() throws Exception { cf = createSessionFactory(locator); ClientSession clientSession = cf.createSession(false, true, true); ClientMessage clientMessage = clientSession.createMessage(false); Assert.assertFalse(clientMessage.isDurable()); clientSession.close(); }
@Test public void testDefaultConsumerWindowSize() throws Exception { ActiveMQServer messagingService = createServer(false, isNetty()); messagingService.start(); messagingService.createQueue(queueA, RoutingType.ANYCAST, queueA, null, true, false); ClientSessionFactory cf = createSessionFactory(locator); ClientSession session = cf.createSession(false, true, true); ClientConsumerImpl consumer = (ClientConsumerImpl) session.createConsumer(queueA); consumer.start(); assertEquals(ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE / 2, consumer.getClientWindowSize()); }
SomeConsumer(int nr) throws Exception { locator = createNonHALocator(isNetty); factory = locator.createSessionFactory(); consumerSession = factory.createSession(false, false); consumerSession.createQueue(ADDRESS, "Q" + nr, "prodNR=" + nr, true); consumer = consumerSession.createConsumer("Q" + nr); consumerSession.start(); this.nr = nr; }
protected void addPooled() throws ActiveMQException { ClientSession session = sessionFactory.createSession(); ClientProducer producer = session.createProducer(destination); session.start(); pool.add(new Pooled(session, producer)); }
@Test public void testReceiveTimesoutCorrectly() throws Exception { ClientSessionFactory cf = createSessionFactory(locator); ClientSession session = cf.createSession(false, true, true); session.createQueue(addressA, queueA, false); ClientConsumer cc = session.createConsumer(queueA); session.start(); long time = System.currentTimeMillis(); cc.receive(1000); Assert.assertTrue(System.currentTimeMillis() - time >= 1000); session.close(); }
@Test public void testGetVersion() throws Exception { cf = createSessionFactory(locator); ClientSession clientSession = cf.createSession(false, true, true); Assert.assertEquals(server.getVersion().getIncrementingVersion(), clientSession.getVersion()); clientSession.close(); }
@Test public void testNegativeAutoDeleteAutoCreatedAddress() throws Exception { server.getAddressSettingsRepository().addMatch(addressA.toString(), new AddressSettings().setAutoDeleteAddresses(false)); server.createQueue(addressA, RoutingType.ANYCAST, queueA, null, null, true, false, false, false, true, 1, false, true); assertNotNull(server.getAddressInfo(addressA)); cf.createSession().createConsumer(queueA).close(); assertNotNull(server.getAddressInfo(addressA)); } }
@Override @Before public void setUp() throws Exception { super.setUp(); ServerLocator locator = createNettyNonHALocator(); addServerLocator(locator); ClientSessionFactory sf = createSessionFactory(locator); session = sf.createSession(false, true, true); session.createQueue(ClientExitTest.QUEUE, ClientExitTest.QUEUE, null, false); consumer = session.createConsumer(ClientExitTest.QUEUE); session.start(); } }