Search in sources :

Example 41 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class SimpleJNDIClientTest method testRemoteCFWithJGroups.

@Test
public void testRemoteCFWithJGroups() throws Exception {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
    props.put("connectionFactory.myConnectionFactory", "jgroups://mychannelid?file=test-jgroups-file_ping.xml");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
    connectionFactory.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory().createBroadcastEndpoint().close(false);
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 42 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class SimpleJNDIClientTest method testXACF.

@Test
public void testXACF() throws NamingException, JMSException {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
    props.put("connectionFactory.myConnectionFactory", "vm://0?type=XA_CF");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
    Assert.assertEquals(JMSFactoryType.XA_CF.intValue(), connectionFactory.getFactoryType());
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 43 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class SimpleJNDIClientTest method testRemoteCFWithJgroupsWithTransportConfigProps.

@Test
public void testRemoteCFWithJgroupsWithTransportConfigProps() throws Exception {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
    props.put("connectionFactory.ConnectionFactory", "jgroups://testChannelName?properties=param=value&" + ActiveMQInitialContextFactory.REFRESH_TIMEOUT + "=5000&" + ActiveMQInitialContextFactory.DISCOVERY_INITIAL_WAIT_TIMEOUT + "=6000");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("ConnectionFactory");
    DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
    Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());
    Assert.assertEquals(6000, discoveryGroupConfiguration.getDiscoveryInitialWaitTimeout());
    BroadcastEndpointFactory broadcastEndpointFactory = cf.getDiscoveryGroupConfiguration().getBroadcastEndpointFactory();
    Assert.assertTrue(broadcastEndpointFactory instanceof JGroupsPropertiesBroadcastEndpointFactory);
    JGroupsPropertiesBroadcastEndpointFactory endpointFactory = (JGroupsPropertiesBroadcastEndpointFactory) broadcastEndpointFactory;
    Assert.assertEquals(endpointFactory.getProperties(), "param=value");
    Assert.assertEquals(endpointFactory.getChannelName(), "testChannelName");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) ActiveMQInitialContextFactory(org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory) InitialContext(javax.naming.InitialContext) JGroupsPropertiesBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFactory) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) BroadcastEndpointFactory(org.apache.activemq.artemis.api.core.BroadcastEndpointFactory) Test(org.junit.Test)

Example 44 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class SimpleJNDIClientTest method testQueueCF.

@Test
public void testQueueCF() throws NamingException, JMSException {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
    props.put("connectionFactory.myConnectionFactory", "vm://0?type=QUEUE_CF");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
    Assert.assertEquals(JMSFactoryType.QUEUE_CF.intValue(), connectionFactory.getFactoryType());
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 45 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class SimpleJNDIClientTest method testRemoteCFWithTransportConfig.

@Test
public void testRemoteCFWithTransportConfig() throws NamingException, JMSException {
    Hashtable<String, String> props = new Hashtable<>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
    props.put("connectionFactory.myConnectionFactory", "tcp://127.0.0.1:61616?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=mySSLEnabledPropValue&" + TransportConstants.HTTP_ENABLED_PROP_NAME + "=myHTTPEnabledPropValue&" + TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME + "=myHTTPClientIdlePropValue&" + TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD + "=myHTTPClientIdleScanPeriodValue&" + TransportConstants.HTTP_REQUIRES_SESSION_ID + "=myHTTPRequiresSessionIDValue&" + TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME + "=myHTTPUpgradeEnabledPropValue&" + TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME + "=myHTTPUpgradeEndpointPropValue&" + TransportConstants.USE_SERVLET_PROP_NAME + "=myUseServletPropValue&" + TransportConstants.SERVLET_PATH + "=myServletPathValue&" + TransportConstants.USE_NIO_PROP_NAME + "=myUseNIOPropValue&" + TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME + "=myUseNIOGlobalWorkerPoolPropValue&" + TransportConstants.LOCAL_ADDRESS_PROP_NAME + "=myLocalAddressPropValue&" + TransportConstants.LOCAL_PORT_PROP_NAME + "=myLocalPortPropValue&" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=myKeystoreProviderPropValue&" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=myKeystorePathPropValue&" + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=myKeystorePasswordPropValue&" + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=myTruststoreProviderPropValue&" + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=myTruststorePathPropValue&" + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=myTruststorePasswordPropValue&" + TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME + "=myEnabledCipherSuitesPropValue&" + TransportConstants.ENABLED_PROTOCOLS_PROP_NAME + "=myEnabledProtocolsPropValue&" + TransportConstants.TCP_NODELAY_PROPNAME + "=myTCPNoDelayPropValue&" + TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME + "=myTCPSendbufferSizePropValue&" + TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME + "=myTCPReceivebufferSizePropValue&" + TransportConstants.NIO_REMOTING_THREADS_PROPNAME + "=myNIORemotingThreadsPropValue&" + TransportConstants.BATCH_DELAY + "=myBatchDelay&" + ActiveMQDefaultConfiguration.getPropMaskPassword() + "=myPropMaskPassword&" + ActiveMQDefaultConfiguration.getPropPasswordCodec() + "=myPropPasswordCodec&" + TransportConstants.NETTY_CONNECT_TIMEOUT + "=myNettyConnectTimeout&");
    Context ctx = new InitialContext(props);
    ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");
    Map<String, Object> parametersFromJNDI = cf.getServerLocator().getStaticTransportConfigurations()[0].getParams();
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.SSL_ENABLED_PROP_NAME), "mySSLEnabledPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_ENABLED_PROP_NAME), "myHTTPEnabledPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME), "myHTTPClientIdlePropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD), "myHTTPClientIdleScanPeriodValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_REQUIRES_SESSION_ID), "myHTTPRequiresSessionIDValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME), "myHTTPUpgradeEnabledPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME), "myHTTPUpgradeEndpointPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.USE_SERVLET_PROP_NAME), "myUseServletPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.SERVLET_PATH), "myServletPathValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.USE_NIO_PROP_NAME), "myUseNIOPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME), "myUseNIOGlobalWorkerPoolPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.LOCAL_ADDRESS_PROP_NAME), "myLocalAddressPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.LOCAL_PORT_PROP_NAME), "myLocalPortPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME), "myKeystoreProviderPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.KEYSTORE_PATH_PROP_NAME), "myKeystorePathPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME), "myKeystorePasswordPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME), "myTruststoreProviderPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TRUSTSTORE_PATH_PROP_NAME), "myTruststorePathPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME), "myTruststorePasswordPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME), "myEnabledCipherSuitesPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME), "myEnabledProtocolsPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TCP_NODELAY_PROPNAME), "myTCPNoDelayPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME), "myTCPSendbufferSizePropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME), "myTCPReceivebufferSizePropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.NIO_REMOTING_THREADS_PROPNAME), "myNIORemotingThreadsPropValue");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.BATCH_DELAY), "myBatchDelay");
    Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropMaskPassword()), "myPropMaskPassword");
    Assert.assertEquals(parametersFromJNDI.get(ActiveMQDefaultConfiguration.getPropPasswordCodec()), "myPropPasswordCodec");
    Assert.assertEquals(parametersFromJNDI.get(TransportConstants.NETTY_CONNECT_TIMEOUT), "myNettyConnectTimeout");
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Hashtable(java.util.Hashtable) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)221 Test (org.junit.Test)141 Connection (javax.jms.Connection)84 Session (javax.jms.Session)84 MessageProducer (javax.jms.MessageProducer)63 MessageConsumer (javax.jms.MessageConsumer)60 TextMessage (javax.jms.TextMessage)49 Queue (javax.jms.Queue)48 ConnectionFactory (javax.jms.ConnectionFactory)35 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)27 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)26 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)24 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)24 URI (java.net.URI)22 JMSException (javax.jms.JMSException)20 Message (javax.jms.Message)19 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)19 InitialContext (javax.naming.InitialContext)16 Context (javax.naming.Context)15 Hashtable (java.util.Hashtable)14