This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 833db66c45e CAMEL-18779: Refactor sjms2 (#9024)
833db66c45e is described below
commit 833db66c45ec1eb6365e88af3b07952bcdc847bc
Author: Federico Mariani <[email protected]>
AuthorDate: Tue Jan 10 09:19:27 2023 +0100
CAMEL-18779: Refactor sjms2 (#9024)
---
components/camel-sjms/pom.xml | 2 +-
components/camel-sjms2/pom.xml | 43 ++-------------
.../component/sjms2/SimpleJms2ComponentTest.java | 10 +++-
.../component/sjms2/Sjms2ComponentRestartTest.java | 10 +++-
.../sjms2/Sjms2EndpointNameOverrideTest.java | 10 +++-
.../camel/component/sjms2/Sjms2EndpointTest.java | 16 ++++--
.../component/sjms2/support/Jms2TestSupport.java | 61 ++++------------------
parent/pom.xml | 1 +
.../services/AbstractArtemisEmbeddedService.java | 7 +++
.../infra/artemis/services/ArtemisService.java | 3 ++
.../artemis/services/ArtemisServiceFactory.java | 10 ++++
...ice.java => ArtemisTCPAllProtocolsService.java} | 31 ++++++-----
12 files changed, 91 insertions(+), 113 deletions(-)
diff --git a/components/camel-sjms/pom.xml b/components/camel-sjms/pom.xml
index d9b15347b71..718c93cb81f 100644
--- a/components/camel-sjms/pom.xml
+++ b/components/camel-sjms/pom.xml
@@ -68,7 +68,7 @@
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
- <version>2.0.5</version>
+ <version>${pooled-jms-version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-sjms2/pom.xml b/components/camel-sjms2/pom.xml
index 4b46e879c50..0fbe6206f1e 100644
--- a/components/camel-sjms2/pom.xml
+++ b/components/camel-sjms2/pom.xml
@@ -67,25 +67,17 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-kahadb-store</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-pool</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-artemis</artifactId>
+ <version>${project.version}</version>
<scope>test</scope>
+ <type>test-jar</type>
</dependency>
<!-- artemis connection pool -->
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
- <version>1.2.1</version>
+ <version>${pooled-jms-version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -94,31 +86,6 @@
<version>${commons-io-version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-server</artifactId>
- <version>${activemq-artemis-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-server</artifactId>
- <version>${activemq-artemis-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${activemq-artemis-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-amqp-protocol</artifactId>
- <version>${activemq-artemis-version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
index 7d9722849db..e373c0f7040 100644
---
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
+++
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
@@ -16,15 +16,21 @@
*/
package org.apache.camel.component.sjms2;
-import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class SimpleJms2ComponentTest extends CamelTestSupport {
+ @RegisterExtension
+ public ArtemisService service = ArtemisServiceFactory.createVMService();
+
@Test
public void testHelloWorld() {
Sjms2Component component = context.getComponent("sjms2",
Sjms2Component.class);
@@ -36,7 +42,7 @@ public class SimpleJms2ComponentTest extends CamelTestSupport
{
return new RouteBuilder() {
public void configure() {
ActiveMQConnectionFactory connectionFactory
- = new
ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ = new
ActiveMQConnectionFactory(service.serviceAddress());
Sjms2Component component = new Sjms2Component();
component.setConnectionFactory(connectionFactory);
getContext().addComponent("sjms2", component);
diff --git
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
index b7e27969bc4..654f6f797c1 100644
---
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
+++
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
@@ -16,18 +16,24 @@
*/
package org.apache.camel.component.sjms2;
-import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class Sjms2ComponentRestartTest extends CamelTestSupport {
+ @RegisterExtension
+ public ArtemisService service = ArtemisServiceFactory.createVMService();
+
@BindToRegistry("activemqCF")
private ActiveMQConnectionFactory connectionFactory
- = new
ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ = new ActiveMQConnectionFactory(service.serviceAddress());
@Override
public boolean isUseRouteBuilder() {
diff --git
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
index c009e61500a..9d2bacdd56e 100644
---
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
+++
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
@@ -16,12 +16,15 @@
*/
package org.apache.camel.component.sjms2;
-import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.ExchangePattern;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -31,6 +34,9 @@ public class Sjms2EndpointNameOverrideTest extends
CamelTestSupport {
private static final String BEAN_NAME = "not-sjms";
+ @RegisterExtension
+ public ArtemisService service = ArtemisServiceFactory.createVMService();
+
@Override
protected boolean useJmx() {
return true;
@@ -67,7 +73,7 @@ public class Sjms2EndpointNameOverrideTest extends
CamelTestSupport {
CamelContext camelContext = super.createCamelContext();
ActiveMQConnectionFactory connectionFactory
- = new
ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ = new ActiveMQConnectionFactory(service.serviceAddress());
Sjms2Component component = new Sjms2Component();
component.setConnectionFactory(connectionFactory);
camelContext.addComponent(BEAN_NAME, component);
diff --git
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
index 8f030137e22..ac3ac678785 100644
---
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
+++
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
@@ -16,17 +16,27 @@
*/
package org.apache.camel.component.sjms2;
-import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.ExchangePattern;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class Sjms2EndpointTest extends CamelTestSupport {
+ @RegisterExtension
+ public ArtemisService service = ArtemisServiceFactory.createVMService();
+
@Override
protected boolean useJmx() {
return true;
@@ -146,7 +156,7 @@ public class Sjms2EndpointTest extends CamelTestSupport {
CamelContext camelContext = super.createCamelContext();
ActiveMQConnectionFactory connectionFactory
- = new
ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ = new ActiveMQConnectionFactory(service.serviceAddress());
Sjms2Component component = new Sjms2Component();
component.setConnectionFactory(connectionFactory);
camelContext.addComponent("sjms2", component);
diff --git
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
index c932dc8d6ad..50fdabd5308 100644
---
a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
+++
b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
@@ -21,15 +21,8 @@ import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Session;
-import org.apache.activemq.ActiveMQConnectionFactory;
-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.config.impl.ConfigurationImpl;
-import
org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
-import org.apache.activemq.artemis.core.server.QueueQueryResult;
-import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
@@ -38,25 +31,25 @@ import
org.apache.camel.component.sjms.jms.DestinationCreationStrategy;
import org.apache.camel.component.sjms2.Sjms2Component;
import org.apache.camel.component.sjms2.jms.Jms2ObjectFactory;
import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
-
/**
* A support class that builds up and tears down an ActiveMQ Artemis instance
to be used for unit testing.
*/
public class Jms2TestSupport extends CamelTestSupport {
+ @RegisterExtension
+ public ArtemisService service =
ArtemisServiceFactory.createTCPAllProtocolsService();
+
protected final Logger log = LoggerFactory.getLogger(getClass());
@Produce
protected ProducerTemplate template;
- protected String brokerUri;
- protected int port;
- private EmbeddedActiveMQ broker;
private Connection connection;
private Session session;
private DestinationCreationStrategy destinationCreationStrategy = new
DefaultDestinationCreationStrategy();
@@ -66,33 +59,6 @@ public class Jms2TestSupport extends CamelTestSupport {
return false;
}
- @Override
- protected void doPreSetup() throws Exception {
- broker = new EmbeddedActiveMQ();
- deleteDirectory("target/data");
- port = AvailablePortFinder.getNextAvailable();
- brokerUri = "tcp://localhost:" + port;
- configureBroker(this.broker);
- startBroker();
- }
-
- protected void configureBroker(EmbeddedActiveMQ broker) throws Exception {
- Configuration configuration = new ConfigurationImpl()
- .setPersistenceEnabled(false)
- .setJournalDirectory("target/data/journal")
- .setSecurityEnabled(false)
- .addAcceptorConfiguration("connector", brokerUri +
"?protocols=CORE,AMQP,HORNETQ,OPENWIRE")
- .addAcceptorConfiguration("vm", "vm://broker")
- .addConnectorConfiguration("connector", new
TransportConfiguration(NettyConnectorFactory.class.getName()));
-
- broker.setConfiguration(configuration);
- }
-
- private void startBroker() throws Exception {
- broker.start();
- log.info("Started Embedded JMS Server");
- }
-
@Override
public void tearDown() throws Exception {
super.tearDown();
@@ -110,11 +76,6 @@ public class Jms2TestSupport extends CamelTestSupport {
connection.stop();
connection = null;
}
- log.info("Stopping the ActiveMQ Broker");
- if (broker != null) {
- broker.stop();
- broker = null;
- }
}
/*
@@ -143,16 +104,12 @@ public class Jms2TestSupport extends CamelTestSupport {
//of artemis we may be able test against them in an agnostic way.
switch (protocol) {
case "OPENWIRE":
- return new ActiveMQConnectionFactory(brokerUri);
+ return new ActiveMQConnectionFactory(service.serviceAddress());
default:
- return ActiveMQJMSClient.createConnectionFactory(brokerUri,
"test");
+ return
ActiveMQJMSClient.createConnectionFactory(service.serviceAddress(), "test");
}
}
- public QueueQueryResult getQueueQueryResult(String queueQuery) throws
Exception {
- return broker.getActiveMQServer().queueQuery(new
SimpleString(queueQuery));
- }
-
public void setSession(Session session) {
this.session = session;
}
diff --git a/parent/pom.xml b/parent/pom.xml
index 9a792af9f58..63d5035c5c0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -440,6 +440,7 @@
<pgjdbc-ng-driver-version>0.8.9</pgjdbc-ng-driver-version>
<picocli-version>4.7.0</picocli-version>
<plc4x-version>0.10.0</plc4x-version>
+ <pooled-jms-version>1.2.4</pooled-jms-version>
<powermock-version>2.0.7</powermock-version>
<properties-maven-plugin-version>1.0-alpha-2</properties-maven-plugin-version>
<protobuf-version>3.19.6</protobuf-version>
diff --git
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
index 96467571853..0d977d6e804 100644
---
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
+++
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/AbstractArtemisEmbeddedService.java
@@ -23,10 +23,12 @@ import java.util.function.Consumer;
import javax.jms.ConnectionFactory;
+import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.infra.artemis.common.ConnectionFactoryHelper;
@@ -121,4 +123,9 @@ public abstract class AbstractArtemisEmbeddedService
implements ArtemisService,
public ConnectionFactory createConnectionFactory(Integer
maximumRedeliveries) {
return ConnectionFactoryHelper.createConnectionFactory(this,
maximumRedeliveries);
}
+
+ @Override
+ public QueueQueryResult getQueueQueryResult(String queueQuery) throws
Exception {
+ return embeddedBrokerService.getActiveMQServer().queueQuery(new
SimpleString(queueQuery));
+ }
}
diff --git
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisService.java
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisService.java
index 39d82b84690..732b3ad8d5b 100644
---
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisService.java
+++
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisService.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.test.infra.artemis.services;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.camel.test.infra.artemis.common.ArtemisProperties;
import org.apache.camel.test.infra.common.services.TestService;
import org.junit.jupiter.api.extension.AfterAllCallback;
@@ -66,4 +67,6 @@ public interface ArtemisService
void restart();
long countMessages(String queue) throws Exception;
+
+ QueueQueryResult getQueueQueryResult(String queueQuery) throws Exception;
}
diff --git
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisServiceFactory.java
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisServiceFactory.java
index 26599721ce4..59756053b5f 100644
---
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisServiceFactory.java
+++
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisServiceFactory.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.test.infra.artemis.services;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
import org.apache.camel.test.infra.common.services.SingletonService;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -66,6 +67,11 @@ public final class ArtemisServiceFactory {
return getService().countMessages(queue);
}
+ @Override
+ public QueueQueryResult getQueueQueryResult(String queueQuery) throws
Exception {
+ return getService().getQueueQueryResult(queueQuery);
+ }
+
@Override
public ArtemisService getService() {
return super.getService();
@@ -152,4 +158,8 @@ public final class ArtemisServiceFactory {
return amqpService;
}
+
+ public static ArtemisService createTCPAllProtocolsService() {
+ return new ArtemisTCPAllProtocolsService();
+ }
}
diff --git
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPService.java
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPAllProtocolsService.java
similarity index 63%
rename from
test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPService.java
rename to
test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPAllProtocolsService.java
index f3f3f4822f9..76d6d14dafa 100644
---
a/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPService.java
+++
b/test-infra/camel-test-infra-artemis/src/test/java/org/apache/camel/test/infra/artemis/services/ArtemisTCPAllProtocolsService.java
@@ -17,30 +17,35 @@
package org.apache.camel.test.infra.artemis.services;
import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
+import
org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.camel.test.AvailablePortFinder;
import static org.junit.jupiter.api.Assertions.fail;
-public class ArtemisTCPService extends AbstractArtemisEmbeddedService {
+public class ArtemisTCPAllProtocolsService extends
AbstractArtemisEmbeddedService {
- private String brokerUrl;
- private int tcpPort;
-
- public ArtemisTCPService() {
- }
+ private String brokerURL;
+ private int port;
@Override
protected Configuration getConfiguration(Configuration configuration, int
port) {
- this.tcpPort = port;
- brokerUrl = "tcp://0.0.0.0:" + port
- +
"?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE";
+ final int brokerId = super.BROKER_COUNT.intValue();
+ port = AvailablePortFinder.getNextAvailable();
+ brokerURL = "tcp://0.0.0.0:" + port;
+
configuration.setPersistenceEnabled(false);
try {
- configuration.addAcceptorConfiguration("artemis", brokerUrl);
+ configuration.addAcceptorConfiguration("in-vm", "vm://" +
brokerId);
+ configuration.addAcceptorConfiguration("connector", brokerURL +
"?protocols=CORE,AMQP,HORNETQ,OPENWIRE");
+ configuration.addConnectorConfiguration("connector",
+ new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ configuration.setJournalDirectory("target/data/journal");
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
- fail("Artemis/TCP acceptor cannot be configured");
+ fail("vm acceptor cannot be configured");
}
configuration.addAddressSetting("#",
new AddressSettings()
@@ -52,11 +57,11 @@ public class ArtemisTCPService extends
AbstractArtemisEmbeddedService {
@Override
public String serviceAddress() {
- return brokerUrl;
+ return brokerURL;
}
@Override
public int brokerPort() {
- return tcpPort;
+ return port;
}
}