use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class MultipleProducersPagingTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory());
AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE).setPageSizeBytes(50000).setMaxSizeBytes(404850);
Configuration config = createBasicConfig().setPersistenceEnabled(false).setAddressesSettings(Collections.singletonMap("#", addressSettings)).setAcceptorConfigurations(Collections.singleton(new TransportConfiguration(NettyAcceptorFactory.class.getName()))).setConnectorConfigurations(Collections.singletonMap("netty", new TransportConfiguration(NettyConnectorFactory.class.getName())));
final JMSConfiguration jmsConfig = new JMSConfigurationImpl();
jmsConfig.getConnectionFactoryConfigurations().add(new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("netty")).setBindings("/cf"));
jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName("simple").setSelector("").setDurable(false).setBindings("/queue/simple"));
jmsServer = new EmbeddedJMS();
jmsServer.setConfiguration(config);
jmsServer.setJmsConfiguration(jmsConfig);
jmsServer.start();
cf = (ConnectionFactory) jmsServer.lookup("/cf");
queue = (Queue) jmsServer.lookup("/queue/simple");
barrierLatch = new CyclicBarrier(PRODUCERS + 1);
runnersLatch = new CountDownLatch(PRODUCERS + 1);
msgReceived = new AtomicLong(0);
msgSent = new AtomicLong(0);
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class JMSDynamicConfigTest method testStart.
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testStart() throws Exception {
ArrayList<String> connectors = new ArrayList<>();
connectors.add("invm");
ConnectionFactoryConfiguration cfg = new ConnectionFactoryConfigurationImpl().setName("tst").setConnectorNames(connectors).setBindings("tt");
jmsServer.createConnectionFactory(true, cfg, "tst");
assertNotNull(namingContext.lookup("tst"));
jmsServer.removeConnectionFactoryFromBindingRegistry("tst");
try {
namingContext.lookup("tst");
fail("failure expected");
} catch (NamingException excepted) {
}
jmsServer.stop();
OperationContextImpl.clearContext();
jmsServer.start();
try {
namingContext.lookup("tst");
fail("failure expected");
} catch (NamingException excepted) {
}
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project camel by apache.
the class Jms2TestSupport method configureBroker.
protected void configureBroker(EmbeddedJMS broker) throws Exception {
Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setJournalDirectory("target/data/journal").setSecurityEnabled(false).addAcceptorConfiguration("connector", brokerUri + "?protocols=CORE,AMQP,HORNETQ,OPENWIRE").addAcceptorConfiguration("vm", "vm://broker").addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("connector")).setBindings("cf");
jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
jmsConfig.getQueueConfigurations().add(queueConfig);
broker.setConfiguration(configuration).setJmsConfiguration(jmsConfig);
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class HornetQProtocolManagerTest method testLegacy2.
/**
* This test will use an ArtemisConnectionFactory with clientProtocolManager=
*/
@Test
public void testLegacy2() throws Exception {
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl();
configuration.setConnectorNames("legacy");
configuration.setName("legacy");
configuration.setProtocolManagerFactoryStr(HornetQClientProtocolManagerFactory.class.getName());
embeddedJMS.getJMSServerManager().createConnectionFactory(false, configuration, "legacy");
// WORKAROUND: the 2.0.0 broker introduced addressing change and the 2.2.0 broker added compatibility for old
// client libraries relying on the legacy prefixes. The new client being used in this test needs prefix explicitly.
Queue queue = new ActiveMQQueue("jms.queue.testQueue");
ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) embeddedJMS.lookup("legacy");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
TextMessage message = session.createTextMessage("Test");
for (int i = 0; i < 5; i++) {
message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "duplicate");
producer.send(message);
}
connection.start();
MessageConsumer consumer = session.createConsumer(queue);
TextMessage messageRec = (TextMessage) consumer.receive(5000);
Assert.assertNotNull(messageRec);
Assert.assertEquals("Test", messageRec.getText());
Assert.assertNull(consumer.receiveNoWait());
connection.close();
connectionFactory.close();
}
use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.
the class JMSConnectionFactoryConfigurationStorageTest method testSettingsWithConnectorConfigs.
@Test
public void testSettingsWithConnectorConfigs() throws Exception {
createJMSStorage();
String[] str = new String[5];
for (int i = 0; i < 5; i++) {
str[i] = "str" + i;
}
List<String> connectorConfigs = new ArrayList<>();
Map<String, Object> liveParams = new HashMap<>();
liveParams.put(TransportConstants.PORT_PROP_NAME, 5665);
Map<String, Object> backupParams = new HashMap<>();
backupParams.put(TransportConstants.PORT_PROP_NAME, 5775);
Map<String, Object> liveParams2 = new HashMap<>();
liveParams2.put(TransportConstants.PORT_PROP_NAME, 6665);
ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName("some-name").setConnectorNames(connectorConfigs).setBindings(str).setCallTimeout(RandomUtil.randomPositiveLong());
List<Pair<String, String>> connectors = new ArrayList<>();
connectors.add(new Pair<String, String>(RandomUtil.randomString(), null));
// config.setConnectorNames(connectors);
addSetting(new PersistedConnectionFactory(config));
jmsJournal.stop();
createJMSStorage();
List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
assertEquals(1, cfs.size());
assertEquals("some-name", cfs.get(0).getName());
assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
}
Aggregations