ARTEMIS-1954 eliminate all possible usage of JMSServerManager
This commit is contained in:
parent
ec8914843d
commit
d35f01d25d
|
@ -35,7 +35,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.artemis.client.cdi.configuration.ArtemisClientConfiguration;
|
||||
|
||||
@ApplicationScoped
|
||||
|
@ -56,8 +55,7 @@ public class ConnectionFactoryProvider {
|
|||
if (configuration.startEmbeddedBroker()) {
|
||||
try {
|
||||
ActiveMQServer activeMQServer = ActiveMQServers.newActiveMQServer(embeddedConfiguration, false);
|
||||
JMSServerManagerImpl jmsServerManager = new JMSServerManagerImpl(activeMQServer);
|
||||
jmsServerManager.start();
|
||||
activeMQServer.start();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unable to start embedded JMS", e);
|
||||
}
|
||||
|
|
|
@ -30,12 +30,17 @@ import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
|||
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ. Since Artemis 2.0 all JMS
|
||||
* specific broker management classes, interfaces, and methods have been deprecated in favor of their more general
|
||||
* counter-parts.
|
||||
*
|
||||
* Simple bootstrap class that parses activemq config files (server and jms and security) and starts
|
||||
* an ActiveMQServer instance and populates it with configured JMS endpoints.
|
||||
* <p>
|
||||
* JMS Endpoints are registered with a simple MapBindingRegistry. If you want to use a different registry
|
||||
* you must set the registry property of this class or call the setRegistry() method if you want to use JNDI
|
||||
*/
|
||||
@Deprecated
|
||||
public class EmbeddedJMS extends EmbeddedActiveMQ {
|
||||
|
||||
protected JMSServerManagerImpl serverManager;
|
||||
|
|
|
@ -56,6 +56,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of EmbeddedActiveMQResource. Since Artemis 2.0 all JMS specific broker management classes,
|
||||
* interfaces, and methods have been deprecated in favor of their more general counter-parts.
|
||||
*
|
||||
* A JUnit Rule that embeds an ActiveMQ Artemis JMS server into a test.
|
||||
*
|
||||
* This JUnit Rule is designed to simplify using embedded servers in unit tests. Adding the rule to a test will startup
|
||||
|
@ -73,6 +76,7 @@ import org.slf4j.LoggerFactory;
|
|||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
@Deprecated
|
||||
public class EmbeddedJMSResource extends ExternalResource {
|
||||
|
||||
static final String SERVER_NAME = "embedded-jms-server";
|
||||
|
|
|
@ -16,23 +16,20 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.rest.integration;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
|
||||
|
||||
public class ActiveMQBootstrapListener implements ServletContextListener {
|
||||
|
||||
private EmbeddedJMS jms;
|
||||
private EmbeddedActiveMQ activeMQ;
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent contextEvent) {
|
||||
ServletContext context = contextEvent.getServletContext();
|
||||
jms = new EmbeddedJMS();
|
||||
jms.setRegistry(new ServletContextBindingRegistry(context));
|
||||
activeMQ = new EmbeddedActiveMQ();
|
||||
try {
|
||||
jms.start();
|
||||
activeMQ.start();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -41,8 +38,8 @@ public class ActiveMQBootstrapListener implements ServletContextListener {
|
|||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
try {
|
||||
if (jms != null)
|
||||
jms.stop();
|
||||
if (activeMQ != null)
|
||||
activeMQ.stop();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ import org.apache.activemq.artemis.rest.MessageServiceManager;
|
|||
import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer;
|
||||
import org.jboss.resteasy.test.TestPortProvider;
|
||||
|
||||
class EmbeddedRestActiveMQ {
|
||||
public class EmbeddedRestActiveMQ {
|
||||
|
||||
private TJWSEmbeddedJaxrsServer tjws = new TJWSEmbeddedJaxrsServer();
|
||||
EmbeddedActiveMQ embeddedActiveMQ;
|
||||
private EmbeddedActiveMQ embeddedActiveMQ;
|
||||
private MessageServiceManager manager = new MessageServiceManager(null);
|
||||
|
||||
EmbeddedRestActiveMQ(ConnectionFactoryOptions jmsOptions) {
|
||||
public EmbeddedRestActiveMQ(ConnectionFactoryOptions jmsOptions) {
|
||||
int port = TestPortProvider.getPort();
|
||||
tjws.setPort(port);
|
||||
tjws.setRootResourcePath("");
|
||||
|
@ -65,4 +65,11 @@ class EmbeddedRestActiveMQ {
|
|||
embeddedActiveMQ.stop();
|
||||
}
|
||||
|
||||
public EmbeddedActiveMQ getEmbeddedActiveMQ() {
|
||||
return embeddedActiveMQ;
|
||||
}
|
||||
|
||||
public void setEmbeddedActiveMQ(EmbeddedActiveMQ embeddedActiveMQ) {
|
||||
this.embeddedActiveMQ = embeddedActiveMQ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions;
|
|||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
||||
|
||||
@Deprecated
|
||||
public class EmbeddedRestActiveMQJMS extends EmbeddedRestActiveMQ {
|
||||
|
||||
public EmbeddedRestActiveMQJMS(ConnectionFactoryOptions jmsOptions) {
|
||||
|
@ -28,14 +29,14 @@ public class EmbeddedRestActiveMQJMS extends EmbeddedRestActiveMQ {
|
|||
|
||||
@Override
|
||||
protected void initEmbeddedActiveMQ() {
|
||||
embeddedActiveMQ = new EmbeddedJMS();
|
||||
super.setEmbeddedActiveMQ(new EmbeddedJMS());
|
||||
}
|
||||
|
||||
public BindingRegistry getRegistry() {
|
||||
return ((EmbeddedJMS) embeddedActiveMQ).getRegistry();
|
||||
return ((EmbeddedJMS) getEmbeddedActiveMQ()).getRegistry();
|
||||
}
|
||||
|
||||
public EmbeddedJMS getEmbeddedJMS() {
|
||||
return (EmbeddedJMS) embeddedActiveMQ;
|
||||
return (EmbeddedJMS) getEmbeddedActiveMQ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,26 +19,22 @@ package org.apache.activemq.artemis.rest.integration;
|
|||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
import org.apache.activemq.artemis.rest.HttpHeaderProperty;
|
||||
import org.apache.activemq.artemis.rest.test.TransformTest;
|
||||
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
||||
import org.apache.activemq.artemis.rest.test.Util;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.jboss.resteasy.client.ClientRequest;
|
||||
import org.jboss.resteasy.client.ClientResponse;
|
||||
import org.jboss.resteasy.spi.Link;
|
||||
import org.jboss.resteasy.test.TestPortProvider;
|
||||
import org.apache.activemq.artemis.rest.test.Util;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -48,22 +44,22 @@ import static org.junit.Assert.assertNotNull;
|
|||
|
||||
public class EmbeddedRestActiveMQJMSTest {
|
||||
|
||||
private static EmbeddedRestActiveMQJMS server;
|
||||
private static EmbeddedRestActiveMQ server;
|
||||
private static ConnectionFactory factory;
|
||||
private static Link consumeNext;
|
||||
|
||||
@BeforeClass
|
||||
public static void startEmbedded() throws Exception {
|
||||
server = new EmbeddedRestActiveMQJMS(null);
|
||||
assertNotNull(server.embeddedActiveMQ);
|
||||
server = new EmbeddedRestActiveMQ(null);
|
||||
assertNotNull(server.getEmbeddedActiveMQ());
|
||||
server.getManager().setConfigResourcePath("activemq-rest.xml");
|
||||
|
||||
SecurityConfiguration securityConfiguration = createDefaultSecurityConfiguration();
|
||||
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
|
||||
server.getEmbeddedJMS().setSecurityManager(securityManager);
|
||||
server.getEmbeddedActiveMQ().setSecurityManager(securityManager);
|
||||
|
||||
server.start();
|
||||
List<String> connectors = createInVmConnector();
|
||||
server.getEmbeddedJMS().getJMSServerManager().createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory");
|
||||
factory = ActiveMQJMSClient.createConnectionFactory("vm://0", "cf");
|
||||
|
||||
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/queues/exampleQueue"));
|
||||
|
||||
|
@ -79,12 +75,6 @@ public class EmbeddedRestActiveMQJMSTest {
|
|||
System.out.println("consume-next: " + consumeNext);
|
||||
}
|
||||
|
||||
private static List<String> createInVmConnector() {
|
||||
List<String> connectors = new ArrayList<>();
|
||||
connectors.add("in-vm");
|
||||
return connectors;
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopEmbedded() throws Exception {
|
||||
server.stop();
|
||||
|
@ -167,12 +157,6 @@ public class EmbeddedRestActiveMQJMSTest {
|
|||
assertNotNull(consumeNext);
|
||||
}
|
||||
|
||||
private static Connection createConnection() throws JMSException {
|
||||
BindingRegistry reg = server.getRegistry();
|
||||
ConnectionFactory factory = (ConnectionFactory) reg.lookup("ConnectionFactory");
|
||||
return factory.createConnection();
|
||||
}
|
||||
|
||||
private static SecurityConfiguration createDefaultSecurityConfiguration() {
|
||||
SecurityConfiguration securityConfiguration = new SecurityConfiguration();
|
||||
securityConfiguration.addUser("guest", "guest");
|
||||
|
@ -189,7 +173,7 @@ public class EmbeddedRestActiveMQJMSTest {
|
|||
}
|
||||
|
||||
private static void publish(String destination, Serializable object, String contentType) throws Exception {
|
||||
Connection conn = createConnection();
|
||||
Connection conn = factory.createConnection();
|
||||
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Destination dest = session.createQueue(destination);
|
||||
|
||||
|
|
|
@ -23,14 +23,11 @@ import javax.jms.MessageProducer;
|
|||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
import org.apache.activemq.artemis.rest.HttpHeaderProperty;
|
||||
import org.apache.activemq.artemis.rest.integration.EmbeddedRestActiveMQJMS;
|
||||
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
||||
import org.apache.activemq.artemis.rest.integration.EmbeddedRestActiveMQ;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.jboss.resteasy.client.ClientRequest;
|
||||
|
@ -44,22 +41,19 @@ import org.junit.Test;
|
|||
|
||||
public class EmbeddedTest {
|
||||
|
||||
public static EmbeddedRestActiveMQJMS server;
|
||||
public static EmbeddedRestActiveMQ server;
|
||||
|
||||
@BeforeClass
|
||||
public static void startEmbedded() throws Exception {
|
||||
server = new EmbeddedRestActiveMQJMS(null);
|
||||
server = new EmbeddedRestActiveMQ(null);
|
||||
server.getManager().setConfigResourcePath("activemq-rest.xml");
|
||||
SecurityConfiguration securityConfiguration = new SecurityConfiguration();
|
||||
securityConfiguration.addUser("guest", "guest");
|
||||
securityConfiguration.addRole("guest", "guest");
|
||||
securityConfiguration.setDefaultUser("guest");
|
||||
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
|
||||
server.getEmbeddedJMS().setSecurityManager(securityManager);
|
||||
server.getEmbeddedActiveMQ().setSecurityManager(securityManager);
|
||||
server.start();
|
||||
List<String> connectors = new ArrayList<>();
|
||||
connectors.add("in-vm");
|
||||
server.getEmbeddedJMS().getJMSServerManager().createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -69,8 +63,7 @@ public class EmbeddedTest {
|
|||
}
|
||||
|
||||
public static void publish(String destination, Serializable object, String contentType) throws Exception {
|
||||
BindingRegistry reg = server.getRegistry();
|
||||
ConnectionFactory factory = (ConnectionFactory) reg.lookup("ConnectionFactory");
|
||||
ConnectionFactory factory = ActiveMQJMSClient.createConnectionFactory("vm://0","cf");
|
||||
Connection conn = factory.createConnection();
|
||||
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Destination dest = session.createQueue(destination);
|
||||
|
|
|
@ -14,40 +14,36 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<configuration xmlns="urn:activemq"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
|
||||
<jms xmlns="urn:activemq:jms">
|
||||
<!--the queue used by the example-->
|
||||
<queue name="exampleQueue"/>
|
||||
</jms>
|
||||
|
||||
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
|
||||
<core xmlns="urn:activemq:core">
|
||||
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
<!-- Connectors -->
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
|
||||
<connectors>
|
||||
<connector name="in-vm">vm://0</connector>
|
||||
</connectors>
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</acceptor>
|
||||
</acceptors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</acceptor>
|
||||
</acceptors>
|
||||
<!-- Other config -->
|
||||
|
||||
<!-- Other config -->
|
||||
<security-settings>
|
||||
<!--security for example queue-->
|
||||
<security-setting match="exampleQueue">
|
||||
<permission type="createDurableQueue" roles="guest"/>
|
||||
<permission type="deleteDurableQueue" roles="guest"/>
|
||||
<permission type="createNonDurableQueue" roles="guest"/>
|
||||
<permission type="deleteNonDurableQueue" roles="guest"/>
|
||||
<permission type="consume" roles="guest"/>
|
||||
<permission type="send" roles="guest"/>
|
||||
</security-setting>
|
||||
</security-settings>
|
||||
|
||||
<security-settings>
|
||||
<!--security for example queue-->
|
||||
<security-setting match="exampleQueue">
|
||||
<permission type="createDurableQueue" roles="guest"/>
|
||||
<permission type="deleteDurableQueue" roles="guest"/>
|
||||
<permission type="createNonDurableQueue" roles="guest"/>
|
||||
<permission type="deleteNonDurableQueue" roles="guest"/>
|
||||
<permission type="consume" roles="guest"/>
|
||||
<permission type="send" roles="guest"/>
|
||||
</security-setting>
|
||||
</security-settings>
|
||||
<addresses>
|
||||
<address name="exampleQueue">
|
||||
<anycast>
|
||||
<queue name="exampleQueue"/>
|
||||
</anycast>
|
||||
</address>
|
||||
</addresses>
|
||||
</core>
|
||||
|
||||
</configuration>
|
||||
|
|
|
@ -22,14 +22,14 @@ These are provided as JUnit "rules" and can make it easier to embed messaging fu
|
|||
### Declare a rule on your JUnit Test
|
||||
|
||||
```java
|
||||
import org.apache.activemq.artemis.junit.EmbeddedJMSResource;
|
||||
import org.apache.activemq.artemis.junit.EmbeddedActiveMQResource;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MyTest {
|
||||
|
||||
@Rule
|
||||
public EmbeddedJMSResource resource = new EmbeddedJMSResource();
|
||||
public EmbeddedActiveMQResource resource = new EmbeddedActiveMQResource();
|
||||
|
||||
@Test
|
||||
public void myTest() {
|
||||
|
@ -45,8 +45,8 @@ This will start a server that will be available for your test:
|
|||
[main] 17:00:16,666 INFO [org.apache.activemq.artemis.core.server] AMQ221045: libaio is not available, switching the configuration into NIO
|
||||
[main] 17:00:16,688 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
|
||||
[main] 17:00:16,801 INFO [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live
|
||||
[main] 17:00:16,801 INFO [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.5.0-SNAPSHOT [embedded-jms-server, nodeID=39e78380-842c-11e6-9e43-f45c8992f3c7]
|
||||
[main] 17:00:16,891 INFO [org.apache.activemq.artemis.core.server] AMQ221002: Apache ActiveMQ Artemis Message Broker version 1.5.0-SNAPSHOT [39e78380-842c-11e6-9e43-f45c8992f3c7] stopped, uptime 0.272 seconds
|
||||
[main] 17:00:16,801 INFO [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.5.0-SNAPSHOT [embedded-server, nodeID=39e78380-842c-11e6-9e43-f45c8992f3c7]
|
||||
[main] 17:00:16,891 INFO [org.apache.activemq.artemis.core.server] AMQ221002: Apache ActiveMQ Artemis Message Broker version 2.5.0-SNAPSHOT [39e78380-842c-11e6-9e43-f45c8992f3c7] stopped, uptime 0.272 seconds
|
||||
```
|
||||
|
||||
### Ordering rules
|
||||
|
|
|
@ -47,9 +47,8 @@ under the License.
|
|||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="EmbeddedJms" class="org.apache.activemq.artemis.integration.spring.SpringJmsBootstrap" init-method="start"
|
||||
destroy-method="close">
|
||||
<property name="SecurityManager" ref="securityManager"/>
|
||||
<bean id="EmbeddedActiveMQ" class="org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ" init-method="start" destroy-method="stop">
|
||||
<property name="SecurityManager" ref="securityManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory">
|
||||
|
|
|
@ -20,6 +20,10 @@ import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
|||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
||||
/**
|
||||
* This has been deprecated since org.apache.activemq.artemis.integration.spring.SpringJmsBootstrap was also deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public class SpringBindingRegistry implements BindingRegistry {
|
||||
|
||||
private ConfigurableBeanFactory factory;
|
||||
|
|
|
@ -22,6 +22,11 @@ import org.springframework.beans.factory.BeanFactory;
|
|||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
||||
/**
|
||||
* This really isn't needed for Spring integration as demonstrated by org.apache.activemq.artemis.tests.integration.spring.SpringIntegrationTest
|
||||
* as well as the "spring-integration" example
|
||||
*/
|
||||
@Deprecated
|
||||
public class SpringJmsBootstrap extends EmbeddedJMS implements BeanFactoryAware {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,6 +41,7 @@ configuration.addAddressesSetting("myQueue", new AddressSettings().setAddressFul
|
|||
configuration.addAddressesSetting("#", new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK).setMaxSizeBytes(10 * 1024).setPageSizeBytes(1024));
|
||||
jmsConfiguration = new JMSConfigurationImpl();
|
||||
|
||||
// used here even though it's deprecated to be compatible with older versions of the broker
|
||||
server = new EmbeddedJMS();
|
||||
server.setConfiguration(configuration);
|
||||
server.setJmsConfiguration(jmsConfiguration);
|
||||
|
|
|
@ -55,6 +55,7 @@ try {
|
|||
|
||||
jmsConfiguration = new JMSConfigurationImpl();
|
||||
|
||||
// used here even though it's deprecated to be compatible with older versions of the broker
|
||||
server = new EmbeddedJMS();
|
||||
server.setConfiguration(configuration);
|
||||
server.setJmsConfiguration(jmsConfiguration);
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.apache.activemq.artemis.core.client.impl.ClientProducerCredits;
|
|||
import org.apache.activemq.artemis.core.protocol.core.Packet;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
|
||||
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
||||
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
|
||||
import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.tests.extras.jms.bridge.BridgeTestBase;
|
||||
import org.jboss.byteman.contrib.bmunit.BMRule;
|
||||
import org.jboss.byteman.contrib.bmunit.BMRules;
|
||||
|
@ -52,7 +52,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
targetLocation = "ENTRY",
|
||||
action = "org.apache.activemq.artemis.tests.extras.byteman.JMSBridgeReconnectionTest.pause2($2,$3,$4);")})
|
||||
public void performCrashDestinationStopBridge() throws Exception {
|
||||
activeMQServer = jmsServer1;
|
||||
activeMQServer = server1;
|
||||
ConnectionFactoryFactory factInUse0 = cff0;
|
||||
ConnectionFactoryFactory factInUse1 = cff1;
|
||||
final JMSBridgeImpl bridge = new JMSBridgeImpl(factInUse0, factInUse1, sourceQueueFactory, targetQueueFactory, null, null, null, null, null, 1000, -1, QualityOfServiceMode.DUPLICATES_OK, 10, -1, null, null, false).setBridgeName("test-bridge");
|
||||
|
@ -106,7 +106,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
static JMSServerManager activeMQServer;
|
||||
static ActiveMQServer activeMQServer;
|
||||
static boolean stopped = false;
|
||||
static int count = 20;
|
||||
static CountDownLatch stopLatch = new CountDownLatch(1);
|
||||
|
|
|
@ -37,6 +37,8 @@ import java.util.Set;
|
|||
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
|
||||
import com.arjuna.ats.arjuna.coordinator.TxControl;
|
||||
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
|
@ -44,7 +46,6 @@ import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
|||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
|
@ -53,13 +54,11 @@ import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
|||
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
|
||||
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -88,16 +87,8 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
|
||||
protected ActiveMQServer server0;
|
||||
|
||||
protected JMSServerManager jmsServer0;
|
||||
|
||||
protected ActiveMQServer server1;
|
||||
|
||||
protected JMSServerManager jmsServer1;
|
||||
|
||||
private InVMNamingContext context0;
|
||||
|
||||
protected InVMNamingContext context1;
|
||||
|
||||
protected HashMap<String, Object> params1;
|
||||
|
||||
protected ConnectionFactoryFactory cff0LowProducerWindow;
|
||||
|
@ -111,11 +102,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
Configuration conf0 = createBasicConfig().setJournalDirectory(getJournalDir(0, false)).setBindingsDirectory(getBindingsDir(0, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
|
||||
|
||||
server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, false));
|
||||
|
||||
context0 = new InVMNamingContext();
|
||||
jmsServer0 = new JMSServerManagerImpl(server0);
|
||||
jmsServer0.setRegistry(new JndiBindingRegistry(context0));
|
||||
jmsServer0.start();
|
||||
server0.start();
|
||||
|
||||
params1 = new HashMap<>();
|
||||
params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
|
||||
|
@ -123,20 +110,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
Configuration conf1 = createBasicConfig().setJournalDirectory(getJournalDir(1, false)).setBindingsDirectory(getBindingsDir(1, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));
|
||||
|
||||
server1 = addServer(ActiveMQServers.newActiveMQServer(conf1, false));
|
||||
|
||||
context1 = new InVMNamingContext();
|
||||
|
||||
jmsServer1 = new JMSServerManagerImpl(server1);
|
||||
jmsServer1.setRegistry(new JndiBindingRegistry(context1));
|
||||
jmsServer1.start();
|
||||
|
||||
createQueue("sourceQueue", 0);
|
||||
|
||||
jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
|
||||
|
||||
createQueue("localTargetQueue", 0);
|
||||
|
||||
createQueue("targetQueue", 1);
|
||||
server1.start();
|
||||
|
||||
setUpAdministeredObjects();
|
||||
TxControl.enable();
|
||||
|
@ -147,11 +121,11 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
protected void createQueue(final String queueName, final int index) throws Exception {
|
||||
JMSServerManager server = jmsServer0;
|
||||
ActiveMQServer server = server0;
|
||||
if (index == 1) {
|
||||
server = jmsServer1;
|
||||
server = server1;
|
||||
}
|
||||
assertTrue("queue '/queue/" + queueName + "' created", server.createQueue(false, queueName, null, true, "/queue/" + queueName));
|
||||
assertTrue("queue '/queue/" + queueName + "' created", server.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), null, true, false) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,8 +144,8 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
if (cff1 instanceof ActiveMQConnectionFactory) {
|
||||
((ActiveMQConnectionFactory) cff1).close();
|
||||
}
|
||||
stopComponent(jmsServer0);
|
||||
stopComponent(jmsServer1);
|
||||
stopComponent(server0);
|
||||
stopComponent(server1);
|
||||
cff0 = cff1 = null;
|
||||
cff0xa = cff1xa = null;
|
||||
|
||||
|
@ -187,18 +161,8 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
|
||||
server0 = null;
|
||||
|
||||
jmsServer0 = null;
|
||||
|
||||
server1 = null;
|
||||
|
||||
jmsServer1 = null;
|
||||
if (context0 != null)
|
||||
context0.close();
|
||||
context0 = null;
|
||||
if (context1 != null)
|
||||
context1.close();
|
||||
context1 = null;
|
||||
|
||||
// Shutting down Arjuna threads
|
||||
TxControl.disable(true);
|
||||
|
||||
|
@ -297,7 +261,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
sourceQueueFactory = new DestinationFactory() {
|
||||
@Override
|
||||
public Destination createDestination() throws Exception {
|
||||
return (Destination) context0.lookup("/queue/sourceQueue");
|
||||
return ActiveMQDestination.createDestination("/queue/sourceQueue", ActiveMQDestination.TYPE.QUEUE);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -306,7 +270,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
targetQueueFactory = new DestinationFactory() {
|
||||
@Override
|
||||
public Destination createDestination() throws Exception {
|
||||
return (Destination) context1.lookup("/queue/targetQueue");
|
||||
return ActiveMQDestination.createDestination("/queue/targetQueue", ActiveMQDestination.TYPE.QUEUE);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -315,7 +279,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
sourceTopicFactory = new DestinationFactory() {
|
||||
@Override
|
||||
public Destination createDestination() throws Exception {
|
||||
return (Destination) context0.lookup("/topic/sourceTopic");
|
||||
return ActiveMQDestination.createDestination("/topic/sourceTopic", ActiveMQDestination.TYPE.TOPIC);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -324,7 +288,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
localTargetQueueFactory = new DestinationFactory() {
|
||||
@Override
|
||||
public Destination createDestination() throws Exception {
|
||||
return (Destination) context0.lookup("/queue/localTargetQueue");
|
||||
return ActiveMQDestination.createDestination("/queue/localTargetQueue", ActiveMQDestination.TYPE.QUEUE);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.activemq.artemis.tests.extras.jms.bridge;
|
|||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
import javax.naming.Context;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
@ -28,6 +27,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
|
||||
import com.arjuna.ats.arjuna.coordinator.TxControl;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
|
||||
|
@ -43,16 +44,13 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
|||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
||||
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMContext;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -113,14 +111,12 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase {
|
|||
private String name;
|
||||
private int id;
|
||||
|
||||
private JMSServerManager liveNode;
|
||||
private JMSServerManager backupNode;
|
||||
private ActiveMQServer liveNode;
|
||||
private ActiveMQServer backupNode;
|
||||
|
||||
private TransportConfiguration liveConnector;
|
||||
private TransportConfiguration backupConnector;
|
||||
|
||||
private Context liveContext;
|
||||
|
||||
private ServerLocator locator;
|
||||
private ClientSessionFactory sessionFactory;
|
||||
|
||||
|
@ -149,30 +145,21 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase {
|
|||
//live
|
||||
Configuration conf0 = createBasicConfig().setJournalDirectory(getJournalDir(id, false)).setBindingsDirectory(getBindingsDir(id, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params0)).addConnectorConfiguration(liveConnector.getName(), liveConnector).setHAPolicyConfiguration(new ReplicatedPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName()));
|
||||
|
||||
ActiveMQServer server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, true));
|
||||
|
||||
liveContext = new InVMContext();
|
||||
liveNode = new JMSServerManagerImpl(server0);
|
||||
liveNode.setRegistry(new JndiBindingRegistry(liveContext));
|
||||
liveNode = addServer(ActiveMQServers.newActiveMQServer(conf0, true));
|
||||
|
||||
//backup
|
||||
ReplicaPolicyConfiguration replicaPolicyConfiguration = new ReplicaPolicyConfiguration();
|
||||
replicaPolicyConfiguration.setQuorumVoteWait(QUORUM_VOTE_WAIT_TIME_SEC);
|
||||
Configuration config = createBasicConfig().setJournalDirectory(getJournalDir(id, true)).setBindingsDirectory(getBindingsDir(id, true)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params)).addConnectorConfiguration(backupConnector.getName(), backupConnector).addConnectorConfiguration(liveConnector.getName(), liveConnector).setHAPolicyConfiguration(replicaPolicyConfiguration).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
|
||||
|
||||
ActiveMQServer backup = addServer(ActiveMQServers.newActiveMQServer(config, true));
|
||||
|
||||
Context context = new InVMContext();
|
||||
|
||||
backupNode = new JMSServerManagerImpl(backup);
|
||||
backupNode.setRegistry(new JndiBindingRegistry(context));
|
||||
backupNode = addServer(ActiveMQServers.newActiveMQServer(config, true));
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
liveNode.start();
|
||||
waitForServerToStart(liveNode.getActiveMQServer());
|
||||
waitForServerToStart(liveNode);
|
||||
backupNode.start();
|
||||
waitForRemoteBackupSynchronization(backupNode.getActiveMQServer());
|
||||
waitForRemoteBackupSynchronization(backupNode);
|
||||
|
||||
locator = ActiveMQClient.createServerLocatorWithHA(liveConnector).setReconnectAttempts(15);
|
||||
sessionFactory = locator.createSessionFactory();
|
||||
|
@ -186,7 +173,7 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
public void createQueue(String queueName) throws Exception {
|
||||
liveNode.createQueue(true, queueName, null, true, "/queue/" + queueName);
|
||||
liveNode.createQueue(SimpleString.toSimpleString(queueName), RoutingType.ANYCAST, SimpleString.toSimpleString(queueName), null, true, false);
|
||||
}
|
||||
|
||||
public ConnectionFactoryFactory getConnectionFactoryFactory() {
|
||||
|
@ -207,7 +194,7 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase {
|
|||
DestinationFactory destFactory = new DestinationFactory() {
|
||||
@Override
|
||||
public Destination createDestination() throws Exception {
|
||||
return (Destination) liveContext.lookup("/queue/" + queueName);
|
||||
return ActiveMQDestination.createDestination(queueName, ActiveMQDestination.TYPE.QUEUE);
|
||||
}
|
||||
};
|
||||
return destFactory;
|
||||
|
@ -261,7 +248,7 @@ public abstract class ClusteredBridgeTestBase extends ActiveMQTestBase {
|
|||
}
|
||||
});
|
||||
|
||||
liveNode.getActiveMQServer().stop();
|
||||
liveNode.stop();
|
||||
|
||||
boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
|
||||
assertTrue(ok);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
@Test
|
||||
public void testRetryConnectionOnStartup() throws Exception {
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
JMSBridgeImpl bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, targetQueueFactory, null, null, null, null, null, 1000, -1, QualityOfServiceMode.DUPLICATES_OK, 10, -1, null, null, false).setBridgeName("test-bridge");
|
||||
bridge.setTransactionManager(newTransactionManager());
|
||||
|
@ -115,7 +115,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
Assert.assertTrue(bridge.isFailed());
|
||||
|
||||
// Restart the server
|
||||
jmsServer1.start();
|
||||
server1.start();
|
||||
|
||||
createQueue("targetQueue", 1);
|
||||
setUpAdministeredObjects();
|
||||
|
@ -131,7 +131,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
*/
|
||||
@Test
|
||||
public void testStopBridgeWithFailureWhenStarted() throws Exception {
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
JMSBridgeImpl bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory, targetQueueFactory, null, null, null, null, null, 500, -1, QualityOfServiceMode.DUPLICATES_OK, 10, -1, null, null, false).setBridgeName("test-bridge");
|
||||
bridge.setTransactionManager(newTransactionManager());
|
||||
|
@ -144,7 +144,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
Assert.assertFalse(bridge.isStarted());
|
||||
|
||||
// we restart and setup the server for the test's tearDown checks
|
||||
jmsServer1.start();
|
||||
server1.start();
|
||||
createQueue("targetQueue", 1);
|
||||
setUpAdministeredObjects();
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeReconnectionTest.log.info("About to crash server");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
// Wait a while before starting up to simulate the dest being down for a while
|
||||
JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
|
||||
|
@ -196,7 +196,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
// Restart the server
|
||||
JMSBridgeReconnectionTest.log.info("Restarting server");
|
||||
jmsServer1.start();
|
||||
server1.start();
|
||||
|
||||
// jmsServer1.createQueue(false, "targetQueue", null, true, "queue/targetQueue");
|
||||
|
||||
|
@ -212,7 +212,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeReconnectionTest.log.info("Sent messages");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
bridge.stop();
|
||||
|
||||
|
@ -248,7 +248,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeReconnectionTest.log.info("About to crash server");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
// Wait a while before starting up to simulate the dest being down for a while
|
||||
JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
|
||||
|
@ -303,10 +303,10 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeReconnectionTest.log.info("About to crash server");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
if (restart) {
|
||||
jmsServer1.start();
|
||||
server1.start();
|
||||
}
|
||||
// Wait a while before starting up to simulate the dest being down for a while
|
||||
JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
|
||||
|
@ -396,7 +396,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeReconnectionTest.log.info("About to crash server");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
// Wait a while before starting up to simulate the dest being down for a while
|
||||
JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
|
||||
|
@ -404,7 +404,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
|
|||
JMSBridgeReconnectionTest.log.info("Done wait");
|
||||
|
||||
// Restart the server
|
||||
jmsServer1.start();
|
||||
server1.start();
|
||||
|
||||
createQueue("targetQueue", 1);
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ public class JMSBridgeTest extends BridgeTestBase {
|
|||
@Test
|
||||
public void testStartBridgeFirst() throws Exception {
|
||||
//stop the source server, we want to start the bridge first
|
||||
jmsServer0.stop();
|
||||
server0.stop();
|
||||
JMSBridgeImpl bridge = null;
|
||||
|
||||
ConnectionFactoryFactory factInUse0 = cff0;
|
||||
|
@ -349,10 +349,8 @@ public class JMSBridgeTest extends BridgeTestBase {
|
|||
bridge.start();
|
||||
|
||||
//now start the server
|
||||
jmsServer0.start();
|
||||
createQueue("sourceQueue", 0);
|
||||
createQueue("localTargetQueue", 0);
|
||||
jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
|
||||
server0.start();
|
||||
|
||||
// Send half the messages
|
||||
|
||||
sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, false, false);
|
||||
|
@ -1327,7 +1325,7 @@ public class JMSBridgeTest extends BridgeTestBase {
|
|||
|
||||
JMSBridgeTest.log.info("About to crash server");
|
||||
|
||||
jmsServer1.stop();
|
||||
server1.stop();
|
||||
|
||||
// Now stop the bridge while the failover is happening
|
||||
|
||||
|
@ -1337,7 +1335,7 @@ public class JMSBridgeTest extends BridgeTestBase {
|
|||
|
||||
// Shutdown the source server
|
||||
|
||||
jmsServer0.stop();
|
||||
server0.stop();
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------------------------------
|
||||
|
|
|
@ -26,20 +26,16 @@ import javax.jms.TextMessage;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.Message;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
import org.apache.activemq.artemis.ra.recovery.RecoveryManager;
|
||||
import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
|
@ -53,32 +49,21 @@ import org.junit.Test;
|
|||
public class HornetQProtocolManagerTest extends ActiveMQTestBase {
|
||||
|
||||
ActiveMQServer server;
|
||||
EmbeddedJMS embeddedJMS;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Configuration configuration = createDefaultConfig(false);
|
||||
configuration.setPersistenceEnabled(false);
|
||||
configuration.getAcceptorConfigurations().clear();
|
||||
configuration.addAcceptorConfiguration("legacy", "tcp://localhost:61616?protocols=HORNETQ").
|
||||
addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE");
|
||||
|
||||
configuration.addConnectorConfiguration("legacy", "tcp://localhost:61616");
|
||||
JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
|
||||
|
||||
jmsConfiguration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName("testQueue").setBindings("testQueue"));
|
||||
embeddedJMS = new EmbeddedJMS();
|
||||
embeddedJMS.setConfiguration(configuration);
|
||||
embeddedJMS.setJmsConfiguration(jmsConfiguration);
|
||||
embeddedJMS.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
embeddedJMS.stop();
|
||||
super.tearDown();
|
||||
server = createServer(createDefaultConfig(false)
|
||||
.setPersistenceEnabled(false)
|
||||
.clearAcceptorConfigurations()
|
||||
.addAcceptorConfiguration("legacy", "tcp://localhost:61616?protocols=HORNETQ")
|
||||
.addAcceptorConfiguration("corepr", "tcp://localhost:61617?protocols=CORE")
|
||||
.addQueueConfiguration(new CoreQueueConfiguration()
|
||||
.setName("testQueue")
|
||||
.setAddress("testQueue")
|
||||
.setRoutingType(RoutingType.ANYCAST)));
|
||||
server.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -105,18 +90,10 @@ public class HornetQProtocolManagerTest extends ActiveMQTestBase {
|
|||
/** 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");
|
||||
ActiveMQConnectionFactory connectionFactory = ActiveMQJMSClient.createConnectionFactory("tcp://localhost:61616?protocolManagerFactoryStr=" + HornetQClientProtocolManagerFactory.class.getName(), "legacy");
|
||||
Connection connection = connectionFactory.createConnection();
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
MessageProducer producer = session.createProducer(queue);
|
||||
|
|
|
@ -26,14 +26,11 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
|||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.integration.jms.server.management.NullInitialContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -45,8 +42,6 @@ public class FailureDeadlockTest extends ActiveMQTestBase {
|
|||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl jmsServer;
|
||||
|
||||
private ActiveMQConnectionFactory cf1;
|
||||
|
||||
private ActiveMQConnectionFactory cf2;
|
||||
|
@ -56,9 +51,7 @@ public class FailureDeadlockTest extends ActiveMQTestBase {
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
server = createServer(false, createDefaultInVMConfig());
|
||||
jmsServer = new JMSServerManagerImpl(server);
|
||||
jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
|
||||
jmsServer.start();
|
||||
server.start();
|
||||
|
||||
cf1 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
|
||||
cf2 = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
|
||||
|
|
|
@ -32,12 +32,11 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.ActiveMQXAConnectionFactory;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.transport.amqp.client.AmqpClient;
|
||||
import org.apache.activemq.transport.amqp.client.AmqpConnection;
|
||||
|
@ -57,7 +56,6 @@ public class AMQPToOpenwireTest extends ActiveMQTestBase {
|
|||
public static final int OWPORT = 61616;
|
||||
protected static final String urlString = "tcp://" + OWHOST + ":" + OWPORT + "?wireFormat.cacheEnabled=true";
|
||||
|
||||
JMSServerManager serverManager;
|
||||
private ActiveMQServer server;
|
||||
protected ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlString);
|
||||
protected ActiveMQXAConnectionFactory xaFactory = new ActiveMQXAConnectionFactory(urlString);
|
||||
|
|
|
@ -24,21 +24,12 @@ import javax.jms.Message;
|
|||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -53,10 +44,6 @@ public class FloodServerTest extends ActiveMQTestBase {
|
|||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl serverManager;
|
||||
|
||||
private InVMNamingContext initialContext;
|
||||
|
||||
private final String topicName = "my-topic";
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
@ -81,39 +68,18 @@ public class FloodServerTest extends ActiveMQTestBase {
|
|||
Configuration config = createDefaultNettyConfig();
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, false));
|
||||
server.start();
|
||||
|
||||
serverManager = new JMSServerManagerImpl(server);
|
||||
initialContext = new InVMNamingContext();
|
||||
serverManager.setRegistry(new JndiBindingRegistry(initialContext));
|
||||
serverManager.start();
|
||||
serverManager.activated();
|
||||
|
||||
serverManager.createTopic(false, topicName, topicName);
|
||||
registerConnectionFactory();
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
private void registerConnectionFactory() throws Exception {
|
||||
int retryInterval = 1000;
|
||||
double retryIntervalMultiplier = 1.0;
|
||||
int reconnectAttempts = -1;
|
||||
long callTimeout = 30000;
|
||||
|
||||
List<TransportConfiguration> connectorConfigs = new ArrayList<>();
|
||||
connectorConfigs.add(new TransportConfiguration(NettyConnectorFactory.class.getName()));
|
||||
|
||||
serverManager.createConnectionFactory("ManualReconnectionToSingleServerTest", false, JMSFactoryType.CF, registerConnectors(server, connectorConfigs), null, 1000, ActiveMQClient.DEFAULT_CONNECTION_TTL, callTimeout, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, false, false, false, ActiveMQClient.DEFAULT_AUTO_GROUP, false, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, retryInterval, retryIntervalMultiplier, 1000, reconnectAttempts, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/cf");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFoo() {
|
||||
}
|
||||
|
||||
public void _testFlood() throws Exception {
|
||||
ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/cf");
|
||||
ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616?retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1&callTimeout=30000&clientFailureCheckPeriod=1000&maxRetryInterval=1000&blockOnDurableSend=false&blockOnAcknowledge=false", "cf");
|
||||
|
||||
final int numProducers = 20;
|
||||
|
||||
|
|
|
@ -28,22 +28,18 @@ import javax.jms.MessageProducer;
|
|||
import javax.jms.Queue;
|
||||
import javax.jms.Session;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -64,9 +60,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase {
|
|||
private CountDownLatch reconnectionLatch;
|
||||
private CountDownLatch allMessagesReceived;
|
||||
|
||||
private JMSServerManager serverManager;
|
||||
|
||||
private InVMNamingContext context;
|
||||
private Context context;
|
||||
|
||||
private static final String QUEUE_NAME = ManualReconnectionToSingleServerTest.class.getSimpleName() + ".queue";
|
||||
|
||||
|
@ -90,7 +84,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase {
|
|||
public void testExceptionListener() throws Exception {
|
||||
connect();
|
||||
|
||||
ConnectionFactory cf = (ConnectionFactory) context.lookup("/cf");
|
||||
ConnectionFactory cf = (ConnectionFactory) context.lookup("cf");
|
||||
Destination dest = (Destination) context.lookup(QUEUE_NAME);
|
||||
Connection conn = cf.createConnection();
|
||||
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
@ -103,10 +97,10 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase {
|
|||
|
||||
if (i == NUM / 2) {
|
||||
conn.close();
|
||||
serverManager.stop();
|
||||
server.stop();
|
||||
Thread.sleep(5000);
|
||||
serverManager.start();
|
||||
cf = (ConnectionFactory) context.lookup("/cf");
|
||||
server.start();
|
||||
cf = (ConnectionFactory) context.lookup("cf");
|
||||
dest = (Destination) context.lookup(QUEUE_NAME);
|
||||
conn = cf.createConnection();
|
||||
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
@ -139,21 +133,22 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase {
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
context = new InVMNamingContext();
|
||||
Hashtable<String, String> props = new Hashtable<>();
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory.class.getCanonicalName());
|
||||
props.put("queue." + QUEUE_NAME, QUEUE_NAME);
|
||||
props.put("connectionFactory.cf", "tcp://127.0.0.1:61616?retryInterval=1000&reconnectAttempts=-1");
|
||||
|
||||
context = new InitialContext(props);
|
||||
|
||||
server = createServer(false, createDefaultNettyConfig());
|
||||
|
||||
JMSConfiguration configuration = new JMSConfigurationImpl();
|
||||
serverManager = new JMSServerManagerImpl(server, configuration);
|
||||
serverManager.setRegistry(new JndiBindingRegistry(context));
|
||||
Configuration configuration = new ConfigurationImpl();
|
||||
|
||||
configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME));
|
||||
configuration.getQueueConfigurations().add(new CoreQueueConfiguration().setName(QUEUE_NAME));
|
||||
|
||||
ArrayList<TransportConfiguration> configs = new ArrayList<>();
|
||||
configs.add(new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
|
||||
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(registerConnectors(server, configs)).setBindings("/cf").setRetryInterval(1000).setReconnectAttempts(-1);
|
||||
configuration.getConnectionFactoryConfigurations().add(cfConfig);
|
||||
serverManager.start();
|
||||
server.start();
|
||||
|
||||
listener = new Listener();
|
||||
|
||||
|
@ -198,7 +193,7 @@ public class ManualReconnectionToSingleServerTest extends ActiveMQTestBase {
|
|||
while (true) {
|
||||
try {
|
||||
queue = (Queue) initialContext.lookup(QUEUE_NAME);
|
||||
cf = (ConnectionFactory) initialContext.lookup("/cf");
|
||||
cf = (ConnectionFactory) initialContext.lookup("cf");
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
if (retries++ > retryLimit)
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.stream.Collectors;
|
|||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
|
@ -54,9 +55,9 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
URL url2 = RedeployTest.class.getClassLoader().getResource("reload-test-updated-jms.xml");
|
||||
Files.copy(url1.openStream(), brokerXML);
|
||||
|
||||
EmbeddedJMS embeddedJMS = new EmbeddedJMS();
|
||||
embeddedJMS.setConfigResourcePath(brokerXML.toUri().toString());
|
||||
embeddedJMS.start();
|
||||
EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ();
|
||||
embeddedActiveMQ.setConfigResourcePath(brokerXML.toUri().toString());
|
||||
embeddedActiveMQ.start();
|
||||
|
||||
final ReusableLatch latch = new ReusableLatch(1);
|
||||
|
||||
|
@ -67,23 +68,23 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
}
|
||||
};
|
||||
|
||||
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
|
||||
try {
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
Assert.assertEquals("DLQ", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getDeadLetterAddress().toString());
|
||||
Assert.assertEquals("ExpiryQueue", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getExpiryAddress().toString());
|
||||
Assert.assertEquals("DLQ", embeddedActiveMQ.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getDeadLetterAddress().toString());
|
||||
Assert.assertEquals("ExpiryQueue", embeddedActiveMQ.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getExpiryAddress().toString());
|
||||
Assert.assertFalse(tryConsume());
|
||||
Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING);
|
||||
brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
|
||||
latch.setCount(1);
|
||||
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
|
||||
Assert.assertTrue(tryConsume());
|
||||
|
||||
Assert.assertEquals("NewQueue", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getDeadLetterAddress().toString());
|
||||
Assert.assertEquals("NewQueue", embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getExpiryAddress().toString());
|
||||
Assert.assertEquals("NewQueue", embeddedActiveMQ.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getDeadLetterAddress().toString());
|
||||
Assert.assertEquals("NewQueue", embeddedActiveMQ.getActiveMQServer().getAddressSettingsRepository().getMatch("jms").getExpiryAddress().toString());
|
||||
|
||||
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
|
||||
try (Connection connection = factory.createConnection()) {
|
||||
|
@ -97,7 +98,7 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
} finally {
|
||||
embeddedJMS.stop();
|
||||
embeddedActiveMQ.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,9 +207,9 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
URL url2 = RedeployTest.class.getClassLoader().getResource("reload-address-queues-updated.xml");
|
||||
Files.copy(url1.openStream(), brokerXML);
|
||||
|
||||
EmbeddedJMS embeddedJMS = new EmbeddedJMS();
|
||||
embeddedJMS.setConfigResourcePath(brokerXML.toUri().toString());
|
||||
embeddedJMS.start();
|
||||
EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ();
|
||||
embeddedActiveMQ.setConfigResourcePath(brokerXML.toUri().toString());
|
||||
embeddedActiveMQ.start();
|
||||
|
||||
final ReusableLatch latch = new ReusableLatch(1);
|
||||
|
||||
|
@ -219,49 +220,49 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
}
|
||||
};
|
||||
|
||||
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
|
||||
try {
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_address_removal_no_queue"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal_no_queue"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
|
||||
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "permanent_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "permanent_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "permanent_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "permanent_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
|
||||
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue"));
|
||||
Assert.assertEquals(10, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers());
|
||||
Assert.assertEquals(false, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers());
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_change"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_change").contains("config_test_queue_change_queue"));
|
||||
Assert.assertEquals(10, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").getMaxConsumers());
|
||||
Assert.assertEquals(false, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").isPurgeOnNoConsumers());
|
||||
|
||||
Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING);
|
||||
brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
|
||||
latch.setCount(1);
|
||||
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
|
||||
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal_no_queue"));
|
||||
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
|
||||
Assert.assertFalse(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
|
||||
Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal_no_queue"));
|
||||
Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
|
||||
Assert.assertFalse(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
|
||||
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "permanent_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "permanent_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "permanent_test_address_removal"));
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "permanent_test_queue_removal"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
|
||||
|
||||
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue"));
|
||||
Assert.assertEquals(1, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers());
|
||||
Assert.assertEquals(true, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers());
|
||||
Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_change"));
|
||||
Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_change").contains("config_test_queue_change_queue"));
|
||||
Assert.assertEquals(1, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").getMaxConsumers());
|
||||
Assert.assertEquals(true, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").isPurgeOnNoConsumers());
|
||||
} finally {
|
||||
embeddedJMS.stop();
|
||||
embeddedActiveMQ.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,25 +369,25 @@ public class RedeployTest extends ActiveMQTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
private AddressSettings getAddressSettings(EmbeddedJMS embeddedJMS, String address) {
|
||||
return embeddedJMS.getActiveMQServer().getAddressSettingsRepository().getMatch(address);
|
||||
private AddressSettings getAddressSettings(EmbeddedActiveMQ embeddedActiveMQ, String address) {
|
||||
return embeddedActiveMQ.getActiveMQServer().getAddressSettingsRepository().getMatch(address);
|
||||
}
|
||||
|
||||
private Set<Role> getSecurityRoles(EmbeddedJMS embeddedJMS, String address) {
|
||||
return embeddedJMS.getActiveMQServer().getSecurityRepository().getMatch(address);
|
||||
private Set<Role> getSecurityRoles(EmbeddedActiveMQ embeddedActiveMQ, String address) {
|
||||
return embeddedActiveMQ.getActiveMQServer().getSecurityRepository().getMatch(address);
|
||||
}
|
||||
|
||||
private AddressInfo getAddressInfo(EmbeddedJMS embeddedJMS, String address) {
|
||||
return embeddedJMS.getActiveMQServer().getPostOffice().getAddressInfo(SimpleString.toSimpleString(address));
|
||||
private AddressInfo getAddressInfo(EmbeddedActiveMQ embeddedActiveMQ, String address) {
|
||||
return embeddedActiveMQ.getActiveMQServer().getPostOffice().getAddressInfo(SimpleString.toSimpleString(address));
|
||||
}
|
||||
|
||||
private org.apache.activemq.artemis.core.server.Queue getQueue(EmbeddedJMS embeddedJMS, String queueName) throws Exception {
|
||||
QueueBinding queueBinding = (QueueBinding) embeddedJMS.getActiveMQServer().getPostOffice().getBinding(SimpleString.toSimpleString(queueName));
|
||||
private org.apache.activemq.artemis.core.server.Queue getQueue(EmbeddedActiveMQ embeddedActiveMQ, String queueName) throws Exception {
|
||||
QueueBinding queueBinding = (QueueBinding) embeddedActiveMQ.getActiveMQServer().getPostOffice().getBinding(SimpleString.toSimpleString(queueName));
|
||||
return queueBinding == null ? null : queueBinding.getQueue();
|
||||
}
|
||||
|
||||
private List<String> listQueuesNamesForAddress(EmbeddedJMS embeddedJMS, String address) throws Exception {
|
||||
return embeddedJMS.getActiveMQServer().getPostOffice().listQueuesForAddress(SimpleString.toSimpleString(address)).stream().map(
|
||||
private List<String> listQueuesNamesForAddress(EmbeddedActiveMQ embeddedActiveMQ, String address) throws Exception {
|
||||
return embeddedActiveMQ.getActiveMQServer().getPostOffice().listQueuesForAddress(SimpleString.toSimpleString(address)).stream().map(
|
||||
org.apache.activemq.artemis.core.server.Queue::getName).map(SimpleString::toString).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,18 +21,13 @@ import javax.jms.MessageProducer;
|
|||
import javax.jms.Queue;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerFactory;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -43,25 +38,14 @@ import org.junit.Test;
|
|||
public class RemoteConnectionStressTest extends ActiveMQTestBase {
|
||||
|
||||
ActiveMQServer server;
|
||||
MBeanServer mbeanServer;
|
||||
JMSServerManagerImpl jmsServer;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
mbeanServer = MBeanServerFactory.createMBeanServer();
|
||||
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(createDefaultNettyConfig(), mbeanServer, false));
|
||||
|
||||
InVMNamingContext namingContext = new InVMNamingContext();
|
||||
jmsServer = new JMSServerManagerImpl(server);
|
||||
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
|
||||
|
||||
jmsServer.start();
|
||||
|
||||
jmsServer.createQueue(true, "SomeQueue", null, true, "/jms/SomeQueue");
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(createDefaultNettyConfig(), false));
|
||||
server.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
||||
|
@ -39,20 +40,15 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
|||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.NodeManager;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.integration.jms.server.management.JMSUtil;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.InVMNodeManagerServer;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
|
@ -73,20 +69,12 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase {
|
|||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
protected InVMNamingContext ctx1 = new InVMNamingContext();
|
||||
|
||||
protected InVMNamingContext ctx2 = new InVMNamingContext();
|
||||
|
||||
protected Configuration backupConf;
|
||||
|
||||
protected Configuration liveConf;
|
||||
|
||||
protected JMSServerManager liveJMSServer;
|
||||
|
||||
protected ActiveMQServer liveServer;
|
||||
|
||||
protected JMSServerManager backupJMSServer;
|
||||
|
||||
protected ActiveMQServer backupServer;
|
||||
|
||||
protected Map<String, Object> backupParams = new HashMap<>();
|
||||
|
@ -281,26 +269,18 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase {
|
|||
|
||||
backupServer = addServer(new InVMNodeManagerServer(backupConf, nodeManager));
|
||||
|
||||
backupJMSServer = new JMSServerManagerImpl(backupServer);
|
||||
|
||||
backupJMSServer.setRegistry(new JndiBindingRegistry(ctx2));
|
||||
|
||||
backupJMSServer.getActiveMQServer().setIdentity("JMSBackup");
|
||||
backupServer.setIdentity("JMSBackup");
|
||||
log.info("Starting backup");
|
||||
backupJMSServer.start();
|
||||
backupServer.start();
|
||||
|
||||
liveConf = createBasicConfig().setJournalDirectory(getJournalDir()).setBindingsDirectory(getBindingsDir()).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));
|
||||
|
||||
liveServer = addServer(new InVMNodeManagerServer(liveConf, nodeManager));
|
||||
|
||||
liveJMSServer = new JMSServerManagerImpl(liveServer);
|
||||
|
||||
liveJMSServer.setRegistry(new JndiBindingRegistry(ctx1));
|
||||
|
||||
liveJMSServer.getActiveMQServer().setIdentity("JMSLive");
|
||||
liveServer.setIdentity("JMSLive");
|
||||
log.info("Starting life");
|
||||
|
||||
liveJMSServer.start();
|
||||
liveServer.start();
|
||||
|
||||
JMSUtil.waitForServer(backupServer);
|
||||
}
|
||||
|
|
|
@ -28,14 +28,11 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
|||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.jms.server.management.NullInitialContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -48,22 +45,15 @@ public class ExceptionListenerTest extends ActiveMQTestBase {
|
|||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl jmsServer;
|
||||
|
||||
private ActiveMQConnectionFactory cf;
|
||||
|
||||
private static final String Q_NAME = "ConnectionTestQueue";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(createDefaultInVMConfig(), false));
|
||||
jmsServer = new JMSServerManagerImpl(server);
|
||||
jmsServer.setRegistry(new JndiBindingRegistry(new NullInitialContext()));
|
||||
jmsServer.start();
|
||||
jmsServer.createQueue(false, ExceptionListenerTest.Q_NAME, null, true, ExceptionListenerTest.Q_NAME);
|
||||
server.start();
|
||||
cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
|
||||
cf.setBlockOnDurableSend(true);
|
||||
cf.setPreAcknowledge(true);
|
||||
|
|
|
@ -34,9 +34,6 @@ import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
|
@ -49,7 +46,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
|
||||
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
|
||||
|
||||
private JMSServerManager jmsServer;
|
||||
private ActiveMQServer server;
|
||||
|
||||
private Connection conn;
|
||||
|
||||
|
@ -60,18 +57,13 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
FileConfiguration fc = new FileConfiguration();
|
||||
FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
|
||||
FileDeploymentManager deploymentManager = new FileDeploymentManager("server-start-stop-config1.xml");
|
||||
deploymentManager.addDeployable(fc);
|
||||
deploymentManager.addDeployable(fileConfiguration);
|
||||
deploymentManager.readConfiguration();
|
||||
|
||||
ActiveMQJAASSecurityManager sm = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
|
||||
|
||||
ActiveMQServer server = addServer(new ActiveMQServerImpl(fc, sm));
|
||||
|
||||
jmsServer = new JMSServerManagerImpl(server, fileConfiguration);
|
||||
jmsServer.setRegistry(null);
|
||||
server = addServer(new ActiveMQServerImpl(fc, sm));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -81,7 +73,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
for (int j = 0; j < numMessages; j++) {
|
||||
JMSServerStartStopTest.log.info("Iteration " + j);
|
||||
|
||||
jmsServer.start();
|
||||
server.start();
|
||||
|
||||
ActiveMQConnectionFactory jbcf = createConnectionFactory();
|
||||
|
||||
|
@ -104,11 +96,11 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
|
||||
jbcf.close();
|
||||
|
||||
jmsServer.stop();
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
jmsServer.start();
|
||||
server.start();
|
||||
|
||||
jbcf = createConnectionFactory();
|
||||
|
||||
|
@ -141,7 +133,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
// https://jira.jboss.org/jira/browse/HORNETQ-315
|
||||
@Test
|
||||
public void testCloseConnectionAfterServerIsShutdown() throws Exception {
|
||||
jmsServer.start();
|
||||
server.start();
|
||||
|
||||
jbcf = createConnectionFactory();
|
||||
|
||||
|
@ -151,7 +143,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase {
|
|||
|
||||
conn = jbcf.createConnection();
|
||||
|
||||
jmsServer.stop();
|
||||
server.stop();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,21 +19,15 @@ package org.apache.activemq.artemis.tests.integration.openwire;
|
|||
import javax.jms.ConnectionFactory;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
|
@ -50,7 +44,6 @@ public class OpenWireTestBase extends ActiveMQTestBase {
|
|||
|
||||
protected ActiveMQServer server;
|
||||
|
||||
protected JMSServerManagerImpl jmsServer;
|
||||
protected boolean realStore = false;
|
||||
protected boolean enableSecurity = false;
|
||||
|
||||
|
@ -108,12 +101,9 @@ public class OpenWireTestBase extends ActiveMQTestBase {
|
|||
mbeanServer = MBeanServerFactory.createMBeanServer();
|
||||
server.setMBeanServer(mbeanServer);
|
||||
addServer(server);
|
||||
jmsServer = new JMSServerManagerImpl(server);
|
||||
namingContext = new InVMNamingContext();
|
||||
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
|
||||
jmsServer.start();
|
||||
server.start();
|
||||
|
||||
registerConnectionFactory();
|
||||
coreCf = ActiveMQJMSClient.createConnectionFactory("vm://0?reconnectAttempts=-1","cf");
|
||||
System.out.println("debug: server started");
|
||||
}
|
||||
|
||||
|
@ -121,31 +111,6 @@ public class OpenWireTestBase extends ActiveMQTestBase {
|
|||
protected void extraServerConfig(Configuration serverConfig) {
|
||||
}
|
||||
|
||||
protected void registerConnectionFactory() throws Exception {
|
||||
List<TransportConfiguration> connectorConfigs = new ArrayList<>();
|
||||
connectorConfigs.add(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
|
||||
|
||||
createCF(connectorConfigs, "/cf");
|
||||
|
||||
coreCf = (ConnectionFactory) namingContext.lookup("/cf");
|
||||
}
|
||||
|
||||
protected void createCF(final List<TransportConfiguration> connectorConfigs,
|
||||
final String... jndiBindings) throws Exception {
|
||||
final int retryInterval = 1000;
|
||||
final double retryIntervalMultiplier = 1.0;
|
||||
final int reconnectAttempts = -1;
|
||||
final int callTimeout = 30000;
|
||||
List<String> connectorNames = registerConnectors(server, connectorConfigs);
|
||||
|
||||
String cfName = name.getMethodName();
|
||||
if (cfName == null) {
|
||||
cfName = "cfOpenWire";
|
||||
}
|
||||
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl().setName(cfName).setConnectorNames(connectorNames).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setCallTimeout(callTimeout).setReconnectAttempts(reconnectAttempts);
|
||||
jmsServer.createConnectionFactory(false, configuration, jndiBindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.activemq.artemis.tests.integration.openwire.amq;
|
|||
|
||||
import javax.jms.Connection;
|
||||
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.junit.Test;
|
||||
|
@ -37,7 +36,7 @@ public class ConnectionErrorSocketCloseTest extends BasicOpenWireTest {
|
|||
@Test(timeout = 60000)
|
||||
public void testDuplicateClientIdCloseConnection() throws Exception {
|
||||
connection.start();
|
||||
Wait.waitFor(() -> getActiveMQServer().getRemotingService().getConnections().size() == 1, 10000, 500);
|
||||
Wait.waitFor(() -> server.getRemotingService().getConnections().size() == 1, 10000, 500);
|
||||
|
||||
try (Connection con = factory.createConnection()) {
|
||||
// Try and create second connection the second should fail because of a
|
||||
|
@ -53,13 +52,7 @@ public class ConnectionErrorSocketCloseTest extends BasicOpenWireTest {
|
|||
|
||||
// after 2 seconds the second connection should be terminated by the
|
||||
// broker because of the exception
|
||||
assertTrue(Wait.waitFor(() -> getActiveMQServer().getRemotingService().getConnections().size() == 1, 10000, 500));
|
||||
assertTrue(Wait.waitFor(() -> server.getRemotingService().getConnections().size() == 1, 10000, 500));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ActiveMQServer getActiveMQServer() {
|
||||
return jmsServer.getActiveMQServer();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import javax.jms.MessageConsumer;
|
|||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.Session;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -36,16 +35,11 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
|
||||
import org.junit.After;
|
||||
|
@ -66,7 +60,7 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase {
|
|||
private AtomicLong msgReceived;
|
||||
private AtomicLong msgSent;
|
||||
private final Set<Connection> connections = new HashSet<>();
|
||||
private EmbeddedJMS jmsServer;
|
||||
private ActiveMQServer server;
|
||||
private ConnectionFactory cf;
|
||||
private Queue queue;
|
||||
|
||||
|
@ -76,21 +70,18 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase {
|
|||
super.setUp();
|
||||
executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory());
|
||||
|
||||
AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE).setPageSizeBytes(50000).setMaxSizeBytes(404850);
|
||||
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()))));
|
||||
|
||||
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())));
|
||||
server.start();
|
||||
|
||||
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");
|
||||
cf = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616", "cf");
|
||||
queue = ActiveMQJMSClient.createQueue("simple");
|
||||
|
||||
barrierLatch = new CyclicBarrier(PRODUCERS + 1);
|
||||
runnersLatch = new CountDownLatch(PRODUCERS + 1);
|
||||
|
@ -168,8 +159,8 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase {
|
|||
conn.close();
|
||||
}
|
||||
connections.clear();
|
||||
if (jmsServer != null)
|
||||
jmsServer.stop();
|
||||
if (server != null)
|
||||
server.stop();
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,12 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.jlibaio.LibaioContext;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.qpid.jms.JmsConnectionFactory;
|
||||
import org.junit.Assert;
|
||||
|
@ -79,7 +80,6 @@ public class SyncSendTest extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
ActiveMQServer server;
|
||||
JMSServerManagerImpl jms;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
|
@ -91,15 +91,13 @@ public class SyncSendTest extends ActiveMQTestBase {
|
|||
server = createServer(true, true);
|
||||
}
|
||||
|
||||
jms = new JMSServerManagerImpl(server);
|
||||
|
||||
if (storage.equals("libaio")) {
|
||||
server.getConfiguration().setJournalType(JournalType.ASYNCIO);
|
||||
} else {
|
||||
server.getConfiguration().setJournalType(JournalType.NIO);
|
||||
|
||||
}
|
||||
jms.start();
|
||||
server.start();
|
||||
}
|
||||
|
||||
private long getTimePerSync() throws Exception {
|
||||
|
@ -154,7 +152,7 @@ public class SyncSendTest extends ActiveMQTestBase {
|
|||
|
||||
long recordTime = getTimePerSync();
|
||||
|
||||
jms.createQueue(true, "queue", null, true, null);
|
||||
server.createQueue(SimpleString.toSimpleString("queue"), RoutingType.ANYCAST, SimpleString.toSimpleString("queue"), null, true, false);
|
||||
|
||||
ConnectionFactory factory = newCF();
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ import org.apache.activemq.artemis.api.core.SimpleString;
|
|||
import org.apache.activemq.artemis.core.persistence.OperationContext;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.StompConnection;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
|
@ -118,10 +118,10 @@ public class StompPluginTest extends StompTestBase {
|
|||
private final AtomicBoolean stompBeforeRemoveSession = new AtomicBoolean();
|
||||
|
||||
@Override
|
||||
protected JMSServerManager createServer() throws Exception {
|
||||
JMSServerManager server = super.createServer();
|
||||
server.getActiveMQServer().registerBrokerPlugin(verifier);
|
||||
server.getActiveMQServer().registerBrokerPlugin(new ActiveMQServerPlugin() {
|
||||
protected ActiveMQServer createServer() throws Exception {
|
||||
ActiveMQServer server = super.createServer();
|
||||
server.registerBrokerPlugin(verifier);
|
||||
server.registerBrokerPlugin(new ActiveMQServerPlugin() {
|
||||
|
||||
@Override
|
||||
public void beforeCreateSession(String name, String username, int minLargeMessageSize,
|
||||
|
|
|
@ -18,8 +18,8 @@ package org.apache.activemq.artemis.tests.integration.spring;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
|
@ -67,7 +67,7 @@ public class SpringIntegrationTest extends ActiveMQTestBase {
|
|||
}
|
||||
try {
|
||||
if (context != null) {
|
||||
EmbeddedJMS jms = (EmbeddedJMS) context.getBean("EmbeddedJms");
|
||||
EmbeddedActiveMQ jms = (EmbeddedActiveMQ) context.getBean("EmbeddedActiveMQ");
|
||||
jms.stop();
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class FQQNStompTest extends StompTestBase {
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
QueueQueryResult result = server.getActiveMQServer().queueQuery(new SimpleString(getQueueName()));
|
||||
QueueQueryResult result = server.queueQuery(new SimpleString(getQueueName()));
|
||||
assertTrue(result.isExists());
|
||||
System.out.println("address: " + result.getAddress() + " queue " + result.getName());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.activemq.artemis.tests.integration.stomp;
|
|||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -40,9 +40,9 @@ public class StompConnectionCleanupTest extends StompTest {
|
|||
long start = System.currentTimeMillis();
|
||||
|
||||
while (true) {
|
||||
int connCount = server.getActiveMQServer().getRemotingService().getConnections().size();
|
||||
int connCount = server.getRemotingService().getConnections().size();
|
||||
|
||||
int sessionCount = server.getActiveMQServer().getSessions().size();
|
||||
int sessionCount = server.getSessions().size();
|
||||
|
||||
// All connections and sessions should be timed out including STOMP + JMS connection
|
||||
|
||||
|
@ -77,9 +77,9 @@ public class StompConnectionCleanupTest extends StompTest {
|
|||
long start = System.currentTimeMillis();
|
||||
|
||||
while (true) {
|
||||
int connCount = server.getActiveMQServer().getRemotingService().getConnections().size();
|
||||
int connCount = server.getRemotingService().getConnections().size();
|
||||
|
||||
int sessionCount = server.getActiveMQServer().getSessions().size();
|
||||
int sessionCount = server.getSessions().size();
|
||||
|
||||
// All connections and sessions should be timed out including STOMP + JMS connection
|
||||
|
||||
|
@ -124,10 +124,10 @@ public class StompConnectionCleanupTest extends StompTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected JMSServerManager createServer() throws Exception {
|
||||
JMSServerManager s = super.createServer();
|
||||
protected ActiveMQServer createServer() throws Exception {
|
||||
ActiveMQServer s = super.createServer();
|
||||
|
||||
s.getActiveMQServer().getConfiguration().setConnectionTTLOverride(CONNECTION_TTL);
|
||||
s.getConfiguration().setConnectionTTLOverride(CONNECTION_TTL);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
|||
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
|
@ -108,7 +107,7 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
URI uri = createStompClientUri(scheme, hostname, port);
|
||||
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?connectionTtl=1000").start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?connectionTtl=1000").start();
|
||||
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
conn.connect("brianm", "wombats");
|
||||
|
||||
|
@ -161,9 +160,9 @@ public class StompTest extends StompTestBase {
|
|||
}
|
||||
});
|
||||
|
||||
((ActiveMQServerImpl) server.getActiveMQServer()).getMonitor()
|
||||
.setMaxUsage(0)
|
||||
.tick();
|
||||
((ActiveMQServerImpl) server).getMonitor()
|
||||
.setMaxUsage(0)
|
||||
.tick();
|
||||
|
||||
// Connection should be closed by broker when disk is full and attempt to send
|
||||
Exception e = null;
|
||||
|
@ -303,9 +302,9 @@ public class StompTest extends StompTestBase {
|
|||
Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
|
||||
|
||||
// closing the consumer here should trigger auto-deletion
|
||||
assertNotNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(queue)));
|
||||
assertNotNull(server.getPostOffice().getBinding(new SimpleString(queue)));
|
||||
consumer.close();
|
||||
assertNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(queue)));
|
||||
assertNull(server.getPostOffice().getBinding(new SimpleString(queue)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -316,7 +315,7 @@ public class StompTest extends StompTestBase {
|
|||
@Test
|
||||
public void testSendMessageToNonExistentQueueUsingExplicitDefaultRouting() throws Exception {
|
||||
String nonExistentQueue = RandomUtil.randomString();
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
|
||||
server.getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
|
||||
sendMessageToNonExistentQueue(getQueuePrefix(), nonExistentQueue, null);
|
||||
}
|
||||
|
||||
|
@ -341,12 +340,12 @@ public class StompTest extends StompTestBase {
|
|||
long tmsg = message.getJMSTimestamp();
|
||||
Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
|
||||
|
||||
assertNotNull(server.getActiveMQServer().getAddressInfo(new SimpleString(topic)));
|
||||
assertNotNull(server.getAddressInfo(new SimpleString(topic)));
|
||||
|
||||
// closing the consumer here should trigger auto-deletion of the subscription queue and address
|
||||
consumer.close();
|
||||
Thread.sleep(200);
|
||||
assertNull(server.getActiveMQServer().getAddressInfo(new SimpleString(topic)));
|
||||
assertNull(server.getAddressInfo(new SimpleString(topic)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -357,7 +356,7 @@ public class StompTest extends StompTestBase {
|
|||
@Test
|
||||
public void testSendMessageToNonExistentTopicUsingExplicitDefaultRouting() throws Exception {
|
||||
String nonExistentTopic = RandomUtil.randomString();
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch(nonExistentTopic, new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
|
||||
server.getAddressSettingsRepository().addMatch(nonExistentTopic, new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
|
||||
sendMessageToNonExistentTopic(getTopicPrefix(), nonExistentTopic, null);
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1121,7 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testSubscribeToTopic() throws Exception {
|
||||
final int baselineQueueCount = server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length;
|
||||
final int baselineQueueCount = server.getActiveMQServerControl().getQueueNames().length;
|
||||
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
|
@ -1132,7 +1131,7 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
@Override
|
||||
public boolean isSatisfied() throws Exception {
|
||||
int length = server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length;
|
||||
int length = server.getActiveMQServerControl().getQueueNames().length;
|
||||
if (length - baselineQueueCount == 1) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1157,14 +1156,14 @@ public class StompTest extends StompTestBase {
|
|||
log.info("Received frame: " + frame);
|
||||
Assert.assertNull("No message should have been received since subscription was removed", frame);
|
||||
|
||||
assertEquals("Subscription queue should be deleted", 0, server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length - baselineQueueCount);
|
||||
assertEquals("Subscription queue should be deleted", 0, server.getActiveMQServerControl().getQueueNames().length - baselineQueueCount);
|
||||
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscribeToQueue() throws Exception {
|
||||
final int baselineQueueCount = server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length;
|
||||
final int baselineQueueCount = server.getActiveMQServerControl().getQueueNames().length;
|
||||
|
||||
conn.connect(defUser, defPass);
|
||||
subscribe(conn, null, null, null, true);
|
||||
|
@ -1172,7 +1171,7 @@ public class StompTest extends StompTestBase {
|
|||
assertFalse("Queue should not be created here", Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() throws Exception {
|
||||
if (server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length - baselineQueueCount == 1) {
|
||||
if (server.getActiveMQServerControl().getQueueNames().length - baselineQueueCount == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1195,7 +1194,7 @@ public class StompTest extends StompTestBase {
|
|||
log.info("Received frame: " + frame);
|
||||
Assert.assertNull("No message should have been received since subscription was removed", frame);
|
||||
|
||||
assertEquals("Subscription queue should not be deleted", baselineQueueCount, server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length);
|
||||
assertEquals("Subscription queue should not be deleted", baselineQueueCount, server.getActiveMQServerControl().getQueueNames().length);
|
||||
|
||||
conn.disconnect();
|
||||
}
|
||||
|
@ -1214,9 +1213,9 @@ public class StompTest extends StompTestBase {
|
|||
Assert.assertEquals(getQueuePrefix() + nonExistentQueue, frame.getHeader(Stomp.Headers.Send.DESTINATION));
|
||||
Assert.assertEquals(getName(), frame.getBody());
|
||||
|
||||
assertNotNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
|
||||
assertNotNull(server.getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
|
||||
|
||||
final Queue subscription = ((LocalQueueBinding) server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue))).getQueue();
|
||||
final Queue subscription = ((LocalQueueBinding) server.getPostOffice().getBinding(new SimpleString(nonExistentQueue))).getQueue();
|
||||
|
||||
assertTrue(Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
|
@ -1230,7 +1229,7 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
unsubscribe(conn, null, getQueuePrefix() + nonExistentQueue, true, false);
|
||||
|
||||
assertNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
|
||||
assertNull(server.getPostOffice().getBinding(new SimpleString(nonExistentQueue)));
|
||||
|
||||
sendJmsMessage(getName(), ActiveMQJMSClient.createQueue(nonExistentQueue));
|
||||
|
||||
|
@ -1330,7 +1329,7 @@ public class StompTest extends StompTestBase {
|
|||
conn.disconnect();
|
||||
Thread.sleep(500);
|
||||
|
||||
assertNotNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
assertNotNull(server.locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
|
||||
conn.destroy();
|
||||
conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
|
@ -1340,13 +1339,13 @@ public class StompTest extends StompTestBase {
|
|||
conn.disconnect();
|
||||
Thread.sleep(500);
|
||||
|
||||
assertNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
assertNull(server.locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDurableUnSubscribeWithoutDurableSubName() throws Exception {
|
||||
server.getActiveMQServer().getConfiguration().getWildcardConfiguration().setDelimiter('/');
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("/topic/#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
|
||||
server.getConfiguration().getWildcardConfiguration().setDelimiter('/');
|
||||
server.getAddressSettingsRepository().addMatch("/topic/#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
|
||||
conn.connect(defUser, defPass, "myclientid");
|
||||
String subId = UUID.randomUUID().toString();
|
||||
String durableSubName = UUID.randomUUID().toString();
|
||||
|
@ -1361,7 +1360,7 @@ public class StompTest extends StompTestBase {
|
|||
frame = conn.sendFrame(frame);
|
||||
assertEquals(receipt, frame.getHeader(Stomp.Headers.Response.RECEIPT_ID));
|
||||
|
||||
assertTrue(Wait.waitFor(() -> server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + durableSubName)) != null, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString("myclientid." + durableSubName)) != null, 2000, 100));
|
||||
|
||||
receipt = UUID.randomUUID().toString();
|
||||
frame = conn.createFrame(Stomp.Commands.UNSUBSCRIBE)
|
||||
|
@ -1374,7 +1373,7 @@ public class StompTest extends StompTestBase {
|
|||
conn.disconnect();
|
||||
|
||||
// make sure the durable subscription queue is still there
|
||||
assertTrue(Wait.waitFor(() -> server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + durableSubName)) != null, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString("myclientid." + durableSubName)) != null, 2000, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1384,7 +1383,7 @@ public class StompTest extends StompTestBase {
|
|||
conn.disconnect();
|
||||
Thread.sleep(500);
|
||||
|
||||
assertNotNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
assertNotNull(server.locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
|
||||
conn.destroy();
|
||||
conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
|
@ -1394,7 +1393,7 @@ public class StompTest extends StompTestBase {
|
|||
conn.disconnect();
|
||||
Thread.sleep(500);
|
||||
|
||||
assertNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
assertNull(server.locateQueue(SimpleString.toSimpleString("myclientid." + getName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1578,7 +1577,7 @@ public class StompTest extends StompTestBase {
|
|||
final String PREFIXED_ADDRESS = prefix + ADDRESS;
|
||||
String param = routingType.toString();
|
||||
String urlParam = param.toLowerCase() + "Prefix";
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=" + StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "&" + urlParam + "=" + prefix).start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=" + StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "&" + urlParam + "=" + prefix).start();
|
||||
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
|
@ -1597,7 +1596,7 @@ public class StompTest extends StompTestBase {
|
|||
assertEquals(uuid, frame.getHeader(Stomp.Headers.Response.RECEIPT_ID));
|
||||
}
|
||||
|
||||
AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
assertNotNull("No address was created with the name " + ADDRESS, addressInfo);
|
||||
|
||||
Set<RoutingType> routingTypes = new HashSet<>();
|
||||
|
@ -1619,7 +1618,7 @@ public class StompTest extends StompTestBase {
|
|||
URI uri = createStompClientUri(scheme, hostname, port);
|
||||
|
||||
final String ADDRESS = UUID.randomUUID().toString();
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=STOMP&anycastPrefix=/queue/&multicastPrefix=/topic/").start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=STOMP&anycastPrefix=/queue/&multicastPrefix=/topic/").start();
|
||||
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
|
@ -1631,16 +1630,16 @@ public class StompTest extends StompTestBase {
|
|||
frame = conn.sendFrame(frame);
|
||||
assertEquals(uuid, frame.getHeader(Stomp.Headers.Response.RECEIPT_ID));
|
||||
|
||||
AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
assertNotNull("No address was created with the name " + ADDRESS, addressInfo);
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
assertFalse(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
assertNotNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString(ADDRESS)));
|
||||
assertNotNull(server.locateQueue(SimpleString.toSimpleString(ADDRESS)));
|
||||
|
||||
// sending a MULTICAST message should alter the address to support MULTICAST
|
||||
frame = send(conn, "/topic/" + ADDRESS, null, "Hello World 1", true);
|
||||
assertFalse(frame.getCommand().equals("ERROR"));
|
||||
addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
addressInfo = server.getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
|
||||
|
@ -1699,7 +1698,7 @@ public class StompTest extends StompTestBase {
|
|||
URI uri = createStompClientUri(scheme, hostname, port);
|
||||
|
||||
final String ADDRESS = UUID.randomUUID().toString();
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=STOMP&anycastPrefix=/queue/&multicastPrefix=/topic/").start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=STOMP&anycastPrefix=/queue/&multicastPrefix=/topic/").start();
|
||||
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
|
@ -1711,7 +1710,7 @@ public class StompTest extends StompTestBase {
|
|||
frame = conn.sendFrame(frame);
|
||||
assertEquals(uuid, frame.getHeader(Stomp.Headers.Response.RECEIPT_ID));
|
||||
|
||||
AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
assertNotNull("No address was created with the name " + ADDRESS, addressInfo);
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
assertFalse(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
|
@ -1719,10 +1718,10 @@ public class StompTest extends StompTestBase {
|
|||
// sending an ANYCAST message should alter the address to support ANYCAST and create an ANYCAST queue
|
||||
frame = send(conn, "/queue/" + ADDRESS, null, "Hello World 1", true);
|
||||
assertFalse(frame.getCommand().equals("ERROR"));
|
||||
addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
addressInfo = server.getAddressInfo(SimpleString.toSimpleString(ADDRESS));
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
assertNotNull(server.getActiveMQServer().locateQueue(SimpleString.toSimpleString(ADDRESS)));
|
||||
assertNotNull(server.locateQueue(SimpleString.toSimpleString(ADDRESS)));
|
||||
|
||||
// however, no message should be routed to the MULTICAST queue
|
||||
frame = conn.receiveFrame(1000);
|
||||
|
@ -1792,7 +1791,7 @@ public class StompTest extends StompTestBase {
|
|||
final String ADDRESS = UUID.randomUUID().toString();
|
||||
final String PREFIXED_ADDRESS = prefix + ADDRESS;
|
||||
String urlParam = routingType.toString().toLowerCase() + "Prefix";
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=" + StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "&" + urlParam + "=" + prefix).start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=" + StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "&" + urlParam + "=" + prefix).start();
|
||||
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
|
||||
conn.connect(defUser, defPass);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
@ -1817,13 +1816,13 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testMulticastOperationsOnAnycastAddress() throws Exception {
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
testRoutingSemantics(RoutingType.MULTICAST.toString(), getQueuePrefix() + getQueueName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnycastOperationsOnMulticastAddress() throws Exception {
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
testRoutingSemantics(RoutingType.ANYCAST.toString(), getTopicPrefix() + getTopicName());
|
||||
}
|
||||
|
||||
|
@ -1853,7 +1852,7 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testGetManagementAttributeFromStomp() throws Exception {
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
subscribe(conn, null);
|
||||
|
@ -1916,8 +1915,7 @@ public class StompTest extends StompTestBase {
|
|||
final String queueB = "queueB";
|
||||
final String queueC = "queueC";
|
||||
|
||||
ActiveMQServer activeMQServer = server.getActiveMQServer();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServer().getActiveMQServerControl();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServerControl();
|
||||
serverControl.createAddress(addressA, RoutingType.ANYCAST.toString() + "," + RoutingType.MULTICAST.toString());
|
||||
serverControl.createQueue(addressA, queueA, RoutingType.ANYCAST.toString());
|
||||
serverControl.createQueue(addressA, queueB, RoutingType.ANYCAST.toString());
|
||||
|
@ -1925,8 +1923,8 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
send(conn, addressA, null, "Hello World!", true, RoutingType.ANYCAST);
|
||||
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() + activeMQServer.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 1, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() == 0, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() + server.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 1, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() == 0, 2000, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1938,8 +1936,7 @@ public class StompTest extends StompTestBase {
|
|||
final String queueB = "queueB";
|
||||
final String queueC = "queueC";
|
||||
|
||||
ActiveMQServer activeMQServer = server.getActiveMQServer();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServer().getActiveMQServerControl();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServerControl();
|
||||
serverControl.createAddress(addressA, RoutingType.ANYCAST.toString() + "," + RoutingType.MULTICAST.toString());
|
||||
serverControl.createQueue(addressA, queueA, RoutingType.ANYCAST.toString());
|
||||
serverControl.createQueue(addressA, queueB, RoutingType.MULTICAST.toString());
|
||||
|
@ -1947,8 +1944,8 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
send(conn, addressA, null, "Hello World!", true, RoutingType.MULTICAST);
|
||||
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() == 0, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() + activeMQServer.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 2, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() == 0, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() + server.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 2, 2000, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1961,8 +1958,7 @@ public class StompTest extends StompTestBase {
|
|||
final String queueC = "queueC";
|
||||
final String queueD = "queueD";
|
||||
|
||||
ActiveMQServer activeMQServer = server.getActiveMQServer();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServer().getActiveMQServerControl();
|
||||
ActiveMQServerControl serverControl = server.getActiveMQServerControl();
|
||||
serverControl.createAddress(addressA, RoutingType.ANYCAST.toString() + "," + RoutingType.MULTICAST.toString());
|
||||
serverControl.createQueue(addressA, queueA, RoutingType.ANYCAST.toString());
|
||||
serverControl.createQueue(addressA, queueB, RoutingType.ANYCAST.toString());
|
||||
|
@ -1971,8 +1967,8 @@ public class StompTest extends StompTestBase {
|
|||
|
||||
send(conn, addressA, null, "Hello World!", true);
|
||||
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() + activeMQServer.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 1, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> activeMQServer.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() + activeMQServer.locateQueue(SimpleString.toSimpleString(queueD)).getMessageCount() == 2, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueA)).getMessageCount() + server.locateQueue(SimpleString.toSimpleString(queueB)).getMessageCount() == 1, 2000, 100));
|
||||
assertTrue(Wait.waitFor(() -> server.locateQueue(SimpleString.toSimpleString(queueC)).getMessageCount() + server.locateQueue(SimpleString.toSimpleString(queueD)).getMessageCount() == 2, 2000, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1982,21 +1978,19 @@ public class StompTest extends StompTestBase {
|
|||
String queueName = UUID.randomUUID().toString();
|
||||
SimpleString simpleQueueName = SimpleString.toSimpleString(queueName);
|
||||
|
||||
ActiveMQServer activeMQServer = server.getActiveMQServer();
|
||||
Assert.assertNull(server.getAddressInfo(simpleQueueName));
|
||||
Assert.assertNull(server.locateQueue(simpleQueueName));
|
||||
|
||||
Assert.assertNull(activeMQServer.getAddressInfo(simpleQueueName));
|
||||
Assert.assertNull(activeMQServer.locateQueue(simpleQueueName));
|
||||
|
||||
activeMQServer.getAddressSettingsRepository().addMatch(queueName, new AddressSettings()
|
||||
server.getAddressSettingsRepository().addMatch(queueName, new AddressSettings()
|
||||
.setDefaultAddressRoutingType(RoutingType.ANYCAST)
|
||||
.setDefaultQueueRoutingType(RoutingType.ANYCAST)
|
||||
);
|
||||
|
||||
send(conn, queueName, null, "Hello ANYCAST");
|
||||
|
||||
assertTrue("Address and queue should be created now", Wait.waitFor(() -> (activeMQServer.getAddressInfo(simpleQueueName) != null) && (activeMQServer.locateQueue(simpleQueueName) != null), 2000, 200));
|
||||
assertTrue(activeMQServer.getAddressInfo(simpleQueueName).getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
assertEquals(RoutingType.ANYCAST, activeMQServer.locateQueue(simpleQueueName).getRoutingType());
|
||||
assertTrue("Address and queue should be created now", Wait.waitFor(() -> (server.getAddressInfo(simpleQueueName) != null) && (server.locateQueue(simpleQueueName) != null), 2000, 200));
|
||||
assertTrue(server.getAddressInfo(simpleQueueName).getRoutingTypes().contains(RoutingType.ANYCAST));
|
||||
assertEquals(RoutingType.ANYCAST, server.locateQueue(simpleQueueName).getRoutingType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2006,15 +2000,13 @@ public class StompTest extends StompTestBase {
|
|||
String queueName = UUID.randomUUID().toString();
|
||||
SimpleString simpleQueueName = SimpleString.toSimpleString(queueName);
|
||||
|
||||
ActiveMQServer activeMQServer = server.getActiveMQServer();
|
||||
|
||||
Assert.assertNull(activeMQServer.getAddressInfo(simpleQueueName));
|
||||
Assert.assertNull(activeMQServer.locateQueue(simpleQueueName));
|
||||
Assert.assertNull(server.getAddressInfo(simpleQueueName));
|
||||
Assert.assertNull(server.locateQueue(simpleQueueName));
|
||||
|
||||
send(conn, queueName, null, "Hello MULTICAST");
|
||||
|
||||
assertTrue("Address should be created now", Wait.waitFor(() -> (activeMQServer.getAddressInfo(simpleQueueName) != null), 2000, 200));
|
||||
assertTrue(activeMQServer.getAddressInfo(simpleQueueName).getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
Assert.assertNull(activeMQServer.locateQueue(simpleQueueName));
|
||||
assertTrue("Address should be created now", Wait.waitFor(() -> (server.getAddressInfo(simpleQueueName) != null), 2000, 200));
|
||||
assertTrue(server.getAddressInfo(simpleQueueName).getRoutingTypes().contains(RoutingType.MULTICAST));
|
||||
Assert.assertNull(server.locateQueue(simpleQueueName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,11 @@ import java.util.UUID;
|
|||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolManagerFactory;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
|
||||
import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
|
||||
|
@ -53,17 +54,10 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
|
||||
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -97,7 +91,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
|
|||
|
||||
protected Topic topic;
|
||||
|
||||
protected JMSServerManager server;
|
||||
protected ActiveMQServer server;
|
||||
|
||||
protected String defUser = "brianm";
|
||||
|
||||
|
@ -143,7 +137,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
|
|||
server = createServer();
|
||||
server.start();
|
||||
|
||||
waitForServerToStart(server.getActiveMQServer());
|
||||
waitForServerToStart(server);
|
||||
|
||||
connectionFactory = createConnectionFactory();
|
||||
|
||||
|
@ -174,7 +168,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected JMSServerManager createServer() throws Exception {
|
||||
protected ActiveMQServer createServer() throws Exception {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "," + MQTTProtocolManagerFactory.MQTT_PROTOCOL_NAME);
|
||||
params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
|
||||
|
@ -191,7 +185,9 @@ public abstract class StompTestBase extends ActiveMQTestBase {
|
|||
.setPersistenceEnabled(isPersistenceEnabled())
|
||||
.addAcceptorConfiguration(stompTransport)
|
||||
.addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()))
|
||||
.setConnectionTtlCheckInterval(500);
|
||||
.setConnectionTtlCheckInterval(500)
|
||||
.addQueueConfiguration(new CoreQueueConfiguration().setAddress(getQueueName()).setName(getQueueName()).setRoutingType(RoutingType.ANYCAST))
|
||||
.addAddressConfiguration(new CoreAddressConfiguration().setName(getTopicName()).addRoutingType(RoutingType.MULTICAST));
|
||||
|
||||
if (getIncomingInterceptors() != null) {
|
||||
config.setIncomingInterceptorClassNames(getIncomingInterceptors());
|
||||
|
@ -217,12 +213,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
|
|||
});
|
||||
}
|
||||
|
||||
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
|
||||
jmsConfig.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(getQueueName()).setBindings(getQueueName()));
|
||||
jmsConfig.getTopicConfigurations().add(new TopicConfigurationImpl().setName(getTopicName()).setBindings(getTopicName()));
|
||||
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
|
||||
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
|
||||
return server;
|
||||
return activeMQServer;
|
||||
}
|
||||
|
||||
protected ConnectionFactory createConnectionFactory() {
|
||||
|
|
|
@ -67,8 +67,8 @@ public class StompTestMultiThreaded extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testTwoConcurrentSubscribers() throws Exception {
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoDeleteAddresses(false).setAutoDeleteQueues(false));
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://localhost:61614?protocols=STOMP&anycastPrefix=/queue/").start();
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoDeleteAddresses(false).setAutoDeleteQueues(false));
|
||||
server.getRemotingService().createAcceptor("test", "tcp://localhost:61614?protocols=STOMP&anycastPrefix=/queue/").start();
|
||||
|
||||
int nThreads = 2;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class StompTestMultiThreaded extends StompTestBase {
|
|||
}
|
||||
|
||||
// delete queue here so it can be auto-created again during the next loop iteration
|
||||
server.getActiveMQServer().locateQueue(QUEUE).deleteQueue();
|
||||
server.locateQueue(QUEUE).deleteQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class StompWebSocketMaxFrameTest extends StompTestBase {
|
|||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + wsport + "?stompMaxFramePayloadLength=" + stompWSMaxFrameSize).start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + wsport + "?stompMaxFramePayloadLength=" + stompWSMaxFrameSize).start();
|
||||
wsURI = createStompClientUri(scheme, hostname, wsport);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,17 +28,13 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory
|
|||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StompWebSocketTest extends ActiveMQTestBase {
|
||||
|
||||
private JMSServerManager server;
|
||||
private ActiveMQServer server;
|
||||
|
||||
/**
|
||||
* to test the Stomp over Web Sockets protocol,
|
||||
|
@ -63,7 +59,7 @@ public class StompWebSocketTest extends ActiveMQTestBase {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private JMSServerManager createServer() throws Exception {
|
||||
private ActiveMQServer createServer() throws Exception {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
|
||||
params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT + 1);
|
||||
|
@ -71,11 +67,7 @@ public class StompWebSocketTest extends ActiveMQTestBase {
|
|||
|
||||
Configuration config = createBasicConfig().addAcceptorConfiguration(stompTransport).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())).addQueueConfiguration(new CoreQueueConfiguration().setAddress(getQueueName()).setName(getQueueName()).setDurable(false));
|
||||
|
||||
ActiveMQServer activeMQServer = addServer(ActiveMQServers.newActiveMQServer(config));
|
||||
|
||||
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
|
||||
server = new JMSServerManagerImpl(activeMQServer, jmsConfig);
|
||||
server.setRegistry(null);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config));
|
||||
return server;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,20 +22,14 @@ import java.lang.management.ManagementFactory;
|
|||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
|
||||
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -47,7 +41,7 @@ public class StompWithClientIdValidationTest extends StompTestBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected JMSServerManager createServer() throws Exception {
|
||||
protected ActiveMQServer createServer() throws Exception {
|
||||
Configuration config = createBasicConfig()
|
||||
.setSecurityEnabled(isSecurityEnabled())
|
||||
.setPersistenceEnabled(isPersistenceEnabled())
|
||||
|
@ -79,11 +73,7 @@ public class StompWithClientIdValidationTest extends StompTestBase {
|
|||
|
||||
securityManager.getConfiguration().addUser(defUser, defPass);
|
||||
|
||||
ActiveMQServer activeMqServer = addServer(ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
|
||||
|
||||
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
|
||||
server = new JMSServerManagerImpl(activeMqServer, jmsConfig);
|
||||
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
|
||||
return server;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class StompWithLargeMessagesTest extends StompTestBase {
|
|||
|
||||
try {
|
||||
String address = "testLargeMessageAddress";
|
||||
server.getActiveMQServer().createQueue(SimpleString.toSimpleString(address), RoutingType.ANYCAST, SimpleString.toSimpleString(address), null, true, false);
|
||||
server.createQueue(SimpleString.toSimpleString(address), RoutingType.ANYCAST, SimpleString.toSimpleString(address), null, true, false);
|
||||
|
||||
// STOMP default is UTF-8 == 1 byte per char.
|
||||
int largeMessageStringSize = 10 * 1024 * 1024; // 10MB
|
||||
|
|
|
@ -34,7 +34,7 @@ public class StompWithSecurityTest extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testJMSXUserID() throws Exception {
|
||||
server.getActiveMQServer().getConfiguration().setPopulateValidatedUser(true);
|
||||
server.getConfiguration().setPopulateValidatedUser(true);
|
||||
|
||||
MessageConsumer consumer = session.createConsumer(queue);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class StompV11Test extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testConnection() throws Exception {
|
||||
server.getActiveMQServer().getSecurityStore().setSecurityEnabled(true);
|
||||
server.getSecurityStore().setSecurityEnabled(true);
|
||||
StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
|
||||
|
||||
connection.connect(defUser, defPass);
|
||||
|
@ -708,7 +708,7 @@ public class StompV11Test extends StompTestBase {
|
|||
|
||||
uri = createStompClientUri(scheme, hostname, port);
|
||||
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?connectionTtl=1000&connectionTtlMin=5000&connectionTtlMax=10000").start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?connectionTtl=1000&connectionTtlMin=5000&connectionTtlMax=10000").start();
|
||||
StompClientConnection connection = StompClientConnectionFactory.createClientConnection(uri);
|
||||
|
||||
//no heart beat at all if heat-beat absent
|
||||
|
@ -857,7 +857,7 @@ public class StompV11Test extends StompTestBase {
|
|||
StompClientConnection connection;
|
||||
int port = 61614;
|
||||
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?heartBeatToConnectionTtlModifier=1").start();
|
||||
server.getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?heartBeatToConnectionTtlModifier=1").start();
|
||||
|
||||
connection = StompClientConnectionFactory.createClientConnection(uri);
|
||||
frame = connection.createFrame(Stomp.Commands.CONNECT)
|
||||
|
@ -881,8 +881,8 @@ public class StompV11Test extends StompTestBase {
|
|||
connection.closeTransport();
|
||||
}
|
||||
|
||||
server.getActiveMQServer().getRemotingService().destroyAcceptor("test");
|
||||
server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?heartBeatToConnectionTtlModifier=1.5").start();
|
||||
server.getRemotingService().destroyAcceptor("test");
|
||||
server.getRemotingService().createAcceptor("test", "tcp://127.0.0.1:" + port + "?heartBeatToConnectionTtlModifier=1.5").start();
|
||||
|
||||
connection = StompClientConnectionFactory.createClientConnection(uri);
|
||||
frame = connection.createFrame(Stomp.Commands.CONNECT)
|
||||
|
@ -1518,11 +1518,11 @@ public class StompV11Test extends StompTestBase {
|
|||
|
||||
long start = System.currentTimeMillis();
|
||||
SimpleString queueName = SimpleString.toSimpleString(CLIENT_ID + "." + getName());
|
||||
while (server.getActiveMQServer().locateQueue(queueName) != null && (System.currentTimeMillis() - start) < 5000) {
|
||||
while (server.locateQueue(queueName) != null && (System.currentTimeMillis() - start) < 5000) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
assertNull(server.getActiveMQServer().locateQueue(queueName));
|
||||
assertNull(server.locateQueue(queueName));
|
||||
|
||||
conn.disconnect();
|
||||
}
|
||||
|
@ -2165,8 +2165,8 @@ public class StompV11Test extends StompTestBase {
|
|||
conn.startPinger(100);
|
||||
|
||||
|
||||
Assert.assertEquals(1, server.getActiveMQServer().getRemotingService().getConnections().size());
|
||||
StompConnection stompConnection = (StompConnection)server.getActiveMQServer().getRemotingService().getConnections().iterator().next();
|
||||
Assert.assertEquals(1, server.getRemotingService().getConnections().size());
|
||||
StompConnection stompConnection = (StompConnection)server.getRemotingService().getConnections().iterator().next();
|
||||
StompFrameHandlerV11 stompFrameHandler = (StompFrameHandlerV11)stompConnection.getStompVersionHandler();
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
@ -2177,7 +2177,7 @@ public class StompV11Test extends StompTestBase {
|
|||
conn.stopPinger();
|
||||
//((AbstractStompClientConnection)conn).killReaderThread();
|
||||
Wait.waitFor(() -> {
|
||||
return server.getActiveMQServer().getRemotingService().getConnections().size() == 0;
|
||||
return server.getRemotingService().getConnections().size() == 0;
|
||||
});
|
||||
|
||||
Assert.assertFalse(stompFrameHandler.getHeartBeater().isStarted());
|
||||
|
@ -2202,7 +2202,7 @@ public class StompV11Test extends StompTestBase {
|
|||
// Obtain a reference to the server StompConnection object
|
||||
RemotingConnection remotingConnection = null;
|
||||
StompConnection stompConnection = null;
|
||||
Iterator<RemotingConnection> iterator = server.getActiveMQServer().getRemotingService().getConnections().iterator();
|
||||
Iterator<RemotingConnection> iterator = server.getRemotingService().getConnections().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
remotingConnection = iterator.next();
|
||||
if (remotingConnection instanceof StompConnection) {
|
||||
|
@ -2236,7 +2236,7 @@ public class StompV11Test extends StompTestBase {
|
|||
Thread.sleep(2000);
|
||||
|
||||
Wait.waitFor(() -> {
|
||||
return server.getActiveMQServer().getRemotingService().getConnections().size() == 0;
|
||||
return server.getRemotingService().getConnections().size() == 0;
|
||||
});
|
||||
|
||||
Assert.assertFalse("HeartBeater is still running!!", stompFrameHandler.getHeartBeater().isStarted());
|
||||
|
|
|
@ -97,7 +97,7 @@ public class StompV12Test extends StompTestBase {
|
|||
|
||||
@Test
|
||||
public void testConnection() throws Exception {
|
||||
server.getActiveMQServer().getSecurityStore().setSecurityEnabled(true);
|
||||
server.getSecurityStore().setSecurityEnabled(true);
|
||||
StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
|
||||
|
||||
connection.connect(defUser, defPass);
|
||||
|
@ -375,7 +375,7 @@ public class StompV12Test extends StompTestBase {
|
|||
AddressSettings addressSettings = new AddressSettings();
|
||||
addressSettings.setAutoCreateQueues(false);
|
||||
addressSettings.setAutoCreateAddresses(false);
|
||||
server.getActiveMQServer().getAddressSettingsRepository().addMatch("#", addressSettings);
|
||||
server.getAddressSettingsRepository().addMatch("#", addressSettings);
|
||||
|
||||
conn.connect(defUser, defPass);
|
||||
|
||||
|
@ -1502,11 +1502,11 @@ public class StompV12Test extends StompTestBase {
|
|||
|
||||
long start = System.currentTimeMillis();
|
||||
SimpleString queueName = SimpleString.toSimpleString(CLIENT_ID + "." + getName());
|
||||
while (server.getActiveMQServer().locateQueue(queueName) != null && (System.currentTimeMillis() - start) < 5000) {
|
||||
while (server.locateQueue(queueName) != null && (System.currentTimeMillis() - start) < 5000) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
assertNull(server.getActiveMQServer().locateQueue(queueName));
|
||||
assertNull(server.locateQueue(queueName));
|
||||
|
||||
conn.disconnect();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean id="EmbeddedJms" class="org.apache.activemq.artemis.integration.spring.SpringJmsBootstrap" init-method="start">
|
||||
<bean id="EmbeddedActiveMQ" class="org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ" init-method="start" destroy-method="stop">
|
||||
<property name="configResourcePath" value="spring-activemq-config.xml"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -33,9 +33,7 @@ import javax.jms.TopicSession;
|
|||
import javax.jms.TopicSubscriber;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -1309,13 +1307,8 @@ public class AcknowledgementTest extends JMSTestCase {
|
|||
*/
|
||||
@Test
|
||||
public void testNonBlockingAckPerf() throws Exception {
|
||||
getJmsServerManager().createConnectionFactory("testsuitecf1", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf1");
|
||||
getJmsServerManager().createConnectionFactory("testsuitecf2", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf2");
|
||||
|
||||
ActiveMQJMSConnectionFactory cf1 = (ActiveMQJMSConnectionFactory) getInitialContext().lookup("/testsuitecf1");
|
||||
cf1.setBlockOnAcknowledge(false);
|
||||
ActiveMQJMSConnectionFactory cf2 = (ActiveMQJMSConnectionFactory) getInitialContext().lookup("/testsuitecf2");
|
||||
cf2.setBlockOnAcknowledge(true);
|
||||
ConnectionFactory cf1 = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616?blockOnNonDurableSend=true&blockOnAcknowledge=false", "testsuitecf1");
|
||||
ConnectionFactory cf2 = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616?blockOnNonDurableSend=true&blockOnAcknowledge=true", "testsuitecf2");
|
||||
|
||||
int messageCount = 100;
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
|||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.tests.tools.ServerManagement;
|
||||
import org.apache.activemq.artemis.jms.tests.tools.container.Server;
|
||||
import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport;
|
||||
|
@ -248,10 +247,6 @@ public abstract class ActiveMQServerTestCase {
|
|||
return ActiveMQServerTestCase.servers.get(0).getActiveMQServer();
|
||||
}
|
||||
|
||||
protected JMSServerManager getJmsServerManager() throws Exception {
|
||||
return ActiveMQServerTestCase.servers.get(0).getJMSServerManager();
|
||||
}
|
||||
|
||||
protected void checkNoSubscriptions(final Topic topic) throws Exception {
|
||||
|
||||
}
|
||||
|
|
|
@ -20,11 +20,8 @@ import javax.jms.Connection;
|
|||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -41,21 +38,13 @@ public class CTSMiscellaneousTest extends JMSTest {
|
|||
// Attributes ----------------------------------------------------
|
||||
protected static ActiveMQConnectionFactory cf;
|
||||
|
||||
private static final String ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY = "StrictTCKConnectionFactory";
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
try {
|
||||
super.setUp();
|
||||
// Deploy a connection factory with load balancing but no failover on node0
|
||||
List<String> bindings = new ArrayList<>();
|
||||
bindings.add("StrictTCKConnectionFactory");
|
||||
|
||||
getJmsServerManager().createConnectionFactory("StrictTCKConnectionFactory", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/StrictTCKConnectionFactory");
|
||||
|
||||
CTSMiscellaneousTest.cf = (ActiveMQConnectionFactory) getInitialContext().lookup("/StrictTCKConnectionFactory");
|
||||
CTSMiscellaneousTest.cf = ActiveMQJMSClient.createConnectionFactory("tcp://127.0.0.1:61616?blockOnAcknowledge=true&blockOnDurableSend=true&blockOnNonDurableSend=true", "StrictTCKConnectionFactory");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -101,7 +90,6 @@ public class CTSMiscellaneousTest extends JMSTest {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
ActiveMQServerTestCase.undeployConnectionFactory(CTSMiscellaneousTest.ORG_JBOSS_MESSAGING_SERVICE_LBCONNECTION_FACTORY);
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
|
|
@ -26,8 +26,6 @@ import javax.jms.XAConnection;
|
|||
import javax.naming.InitialContext;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueueConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopicConnectionFactory;
|
||||
|
@ -68,16 +66,9 @@ public class JMSTestCase extends ActiveMQServerTestCase {
|
|||
|
||||
// All jms tests should use a specific cg which has blockOnAcknowledge = true and
|
||||
// both np and p messages are sent synchronously
|
||||
|
||||
getJmsServerManager().createConnectionFactory("testsuitecf", false, JMSFactoryType.CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf");
|
||||
|
||||
getJmsServerManager().createConnectionFactory("testsuitecf_queue", false, JMSFactoryType.QUEUE_CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf_queue");
|
||||
|
||||
getJmsServerManager().createConnectionFactory("testsuitecf_topic", false, JMSFactoryType.TOPIC_CF, NETTY_CONNECTOR, null, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, ActiveMQClient.DEFAULT_CONNECTION_TTL, ActiveMQClient.DEFAULT_CALL_TIMEOUT, ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, ActiveMQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, ActiveMQClient.DEFAULT_COMPRESS_LARGE_MESSAGES, ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE, ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_WINDOW_SIZE, ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE, true, true, true, ActiveMQClient.DEFAULT_AUTO_GROUP, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE, ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS, ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE, ActiveMQClient.DEFAULT_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, ActiveMQClient.DEFAULT_MAX_RETRY_INTERVAL, ActiveMQClient.DEFAULT_RECONNECT_ATTEMPTS, ActiveMQClient.DEFAULT_FAILOVER_ON_INITIAL_CONNECTION, null, "/testsuitecf_topic");
|
||||
|
||||
cf = (ActiveMQJMSConnectionFactory) getInitialContext().lookup("/testsuitecf");
|
||||
queueCf = (ActiveMQQueueConnectionFactory) getInitialContext().lookup("/testsuitecf_queue");
|
||||
topicCf = (ActiveMQTopicConnectionFactory) getInitialContext().lookup("/testsuitecf_topic");
|
||||
cf = new ActiveMQJMSConnectionFactory("tcp://127.0.0.1:61616?blockOnAcknowledge=true&blockOnDurableSend=true&blockOnNonDurableSend=true");
|
||||
queueCf = new ActiveMQQueueConnectionFactory("tcp://127.0.0.1:61616?blockOnAcknowledge=true&blockOnDurableSend=true&blockOnNonDurableSend=true");
|
||||
topicCf = new ActiveMQTopicConnectionFactory("tcp://127.0.0.1:61616?blockOnAcknowledge=true&blockOnDurableSend=true&blockOnNonDurableSend=true");
|
||||
|
||||
assertRemainingMessages(0);
|
||||
}
|
||||
|
@ -119,7 +110,6 @@ public class JMSTestCase extends ActiveMQServerTestCase {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
getJmsServerManager().destroyConnectionFactory("testsuitecf");
|
||||
if (cf != null) {
|
||||
cf.close();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public class SecurityTest extends JMSTestCase {
|
|||
} else {
|
||||
System.setProperty(DefaultConnectionProperties.BROKER_BIND_URL, originalBrokerBindUrl);
|
||||
}
|
||||
DefaultConnectionProperties.initialize();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,14 +26,11 @@ import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.utils.FileUtil;
|
||||
|
||||
public class SpawnedJMSServer {
|
||||
|
||||
public static ActiveMQServer server;
|
||||
public static JMSServerManager serverManager;
|
||||
|
||||
// Using files may be useful for debugging (through print-data for instance)
|
||||
private static final boolean useFiles = false;
|
||||
|
@ -92,18 +89,16 @@ public class SpawnedJMSServer {
|
|||
// set DLA and expiry to avoid spamming the log with warnings
|
||||
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLA")).setExpiryAddress(SimpleString.toSimpleString("Expiry")));
|
||||
|
||||
serverManager = new JMSServerManagerImpl(server);
|
||||
serverManager.start();
|
||||
server.start();
|
||||
}
|
||||
return server;
|
||||
}
|
||||
|
||||
public static void stopServer() throws Exception {
|
||||
if (server != null) {
|
||||
serverManager.stop();
|
||||
server.stop();
|
||||
}
|
||||
server = null;
|
||||
serverManager = null;
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
|
|
@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
|
@ -51,20 +52,16 @@ import org.apache.activemq.artemis.api.core.management.QueueControl;
|
|||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
||||
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
|
||||
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
|
||||
import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
|
@ -84,7 +81,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase {
|
|||
|
||||
private static final String TARGET = RandomUtil.randomString();
|
||||
|
||||
private JMSServerManager jmsServer;
|
||||
private ActiveMQServer server;
|
||||
|
||||
private static final AtomicBoolean tcclClassFound = new AtomicBoolean(false);
|
||||
|
||||
|
@ -701,14 +698,11 @@ public class JMSBridgeImplTest extends ActiveMQTestBase {
|
|||
super.setUp();
|
||||
|
||||
Configuration config = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
|
||||
InVMNamingContext context = new InVMNamingContext();
|
||||
jmsServer = new JMSServerManagerImpl(addServer(ActiveMQServers.newActiveMQServer(config, false)));
|
||||
jmsServer.setRegistry(new JndiBindingRegistry(context));
|
||||
jmsServer.start();
|
||||
|
||||
jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);
|
||||
jmsServer.createQueue(false, JMSBridgeImplTest.TARGET, null, true, "/queue/" + JMSBridgeImplTest.TARGET);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, false));
|
||||
server.start();
|
||||
|
||||
server.createQueue(SimpleString.toSimpleString(JMSBridgeImplTest.SOURCE), RoutingType.ANYCAST, SimpleString.toSimpleString(JMSBridgeImplTest.SOURCE), null, true, false);
|
||||
server.createQueue(SimpleString.toSimpleString(JMSBridgeImplTest.TARGET), RoutingType.ANYCAST, SimpleString.toSimpleString(JMSBridgeImplTest.TARGET), null, true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue