ARTEMIS-1320 allow URL for REST/broker connection
This commit is contained in:
parent
01b37de761
commit
b6e48eb14c
|
@ -46,6 +46,10 @@
|
||||||
<groupId>org.jboss.logging</groupId>
|
<groupId>org.jboss.logging</groupId>
|
||||||
<artifactId>jboss-logging</artifactId>
|
<artifactId>jboss-logging</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logmanager</groupId>
|
||||||
|
<artifactId>jboss-logmanager</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>resteasy-jaxrs</artifactId>
|
<artifactId>resteasy-jaxrs</artifactId>
|
||||||
|
@ -111,9 +115,7 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>${activemq-surefire-argline}</argLine>
|
||||||
-Djava.util.logging.config.file=${project.build.directory}/../../../distribution/activemq/src/main/resources/config/stand-alone/non-clustered/logging.properties
|
|
||||||
</argLine>
|
|
||||||
<skipTests>${skipRestTests}</skipTests>
|
<skipTests>${skipRestTests}</skipTests>
|
||||||
<!--includes>
|
<!--includes>
|
||||||
<include>**/PushQueueConsumerTest.java</include>
|
<include>**/PushQueueConsumerTest.java</include>
|
||||||
|
|
|
@ -72,6 +72,10 @@ public interface ActiveMQRestLogger extends BasicLogger {
|
||||||
@Message(id = 182003, value = "Failed to build Message from object", format = Message.Format.MESSAGE_FORMAT)
|
@Message(id = 182003, value = "Failed to build Message from object", format = Message.Format.MESSAGE_FORMAT)
|
||||||
void failedToBuildMessageFromObject(@Cause Exception e);
|
void failedToBuildMessageFromObject(@Cause Exception e);
|
||||||
|
|
||||||
|
@LogMessage(level = Logger.Level.WARN)
|
||||||
|
@Message(id = 182004, value = "REST configuration parameter ''{0}'' is deprecated. Use ''{1}'' instead.", format = Message.Format.MESSAGE_FORMAT)
|
||||||
|
void deprecatedConfiguration(String oldConfigParameter, String newConfigParameter);
|
||||||
|
|
||||||
@LogMessage(level = Logger.Level.ERROR)
|
@LogMessage(level = Logger.Level.ERROR)
|
||||||
@Message(id = 184000, value = "Failed to load push store {0}, it is probably corrupted", format = Message.Format.MESSAGE_FORMAT)
|
@Message(id = 184000, value = "Failed to load push store {0}, it is probably corrupted", format = Message.Format.MESSAGE_FORMAT)
|
||||||
void errorLoadingStore(@Cause Exception e, String name);
|
void errorLoadingStore(@Cause Exception e, String name);
|
||||||
|
|
|
@ -26,12 +26,15 @@ public class MessageServiceConfiguration {
|
||||||
private long producerTimeToLive = -1;
|
private long producerTimeToLive = -1;
|
||||||
private int timeoutTaskInterval = 1;
|
private int timeoutTaskInterval = 1;
|
||||||
private int consumerSessionTimeoutSeconds = 300;
|
private int consumerSessionTimeoutSeconds = 300;
|
||||||
|
@Deprecated
|
||||||
private int consumerWindowSize = -1;
|
private int consumerWindowSize = -1;
|
||||||
private boolean defaultDurableSend = false;
|
private boolean defaultDurableSend = false;
|
||||||
private boolean dupsOk = true;
|
private boolean dupsOk = true;
|
||||||
private String topicPushStoreDirectory = "topic-push-store";
|
private String topicPushStoreDirectory = "topic-push-store";
|
||||||
private String queuePushStoreDirectory = "queue-push-store";
|
private String queuePushStoreDirectory = "queue-push-store";
|
||||||
|
@Deprecated
|
||||||
private String inVmId = "0";
|
private String inVmId = "0";
|
||||||
|
private String url = "vm://0";
|
||||||
private boolean useLinkHeaders = false;
|
private boolean useLinkHeaders = false;
|
||||||
|
|
||||||
private String deserializationWhiteList;
|
private String deserializationWhiteList;
|
||||||
|
@ -43,6 +46,7 @@ public class MessageServiceConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInVmId(String inVmId) {
|
public void setInVmId(String inVmId) {
|
||||||
|
ActiveMQRestLogger.LOGGER.deprecatedConfiguration("server-in-vm-id", "url");
|
||||||
this.inVmId = inVmId;
|
this.inVmId = inVmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +137,19 @@ public class MessageServiceConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConsumerWindowSize(int consumerWindowSize) {
|
public void setConsumerWindowSize(int consumerWindowSize) {
|
||||||
|
ActiveMQRestLogger.LOGGER.deprecatedConfiguration("consumer-window-size", "url");
|
||||||
this.consumerWindowSize = consumerWindowSize;
|
this.consumerWindowSize = consumerWindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "url")
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDeserializationWhiteList() {
|
public String getDeserializationWhiteList() {
|
||||||
return deserializationWhiteList;
|
return deserializationWhiteList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,13 @@ import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
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.ClientSessionFactory;
|
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||||
import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
|
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
|
|
||||||
import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions;
|
import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions;
|
||||||
import org.apache.activemq.artemis.rest.queue.DestinationSettings;
|
import org.apache.activemq.artemis.rest.queue.DestinationSettings;
|
||||||
import org.apache.activemq.artemis.rest.queue.QueueServiceManager;
|
import org.apache.activemq.artemis.rest.queue.QueueServiceManager;
|
||||||
|
@ -143,20 +139,18 @@ public class MessageServiceManager {
|
||||||
defaultSettings.setDuplicatesAllowed(configuration.isDupsOk());
|
defaultSettings.setDuplicatesAllowed(configuration.isDupsOk());
|
||||||
defaultSettings.setDurableSend(configuration.isDefaultDurableSend());
|
defaultSettings.setDurableSend(configuration.isDefaultDurableSend());
|
||||||
|
|
||||||
HashMap<String, Object> transportConfig = new HashMap<>();
|
ServerLocator consumerLocator = ActiveMQClient.createServerLocator(configuration.getUrl());
|
||||||
transportConfig.put(TransportConstants.SERVER_ID_PROP_NAME, configuration.getInVmId());
|
|
||||||
|
|
||||||
ServerLocator consumerLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
|
|
||||||
ActiveMQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator);
|
|
||||||
|
|
||||||
if (configuration.getConsumerWindowSize() != -1) {
|
if (configuration.getConsumerWindowSize() != -1) {
|
||||||
consumerLocator.setConsumerWindowSize(configuration.getConsumerWindowSize());
|
consumerLocator.setConsumerWindowSize(configuration.getConsumerWindowSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActiveMQRestLogger.LOGGER.debug("Created ServerLocator: " + consumerLocator);
|
||||||
|
|
||||||
consumerSessionFactory = consumerLocator.createSessionFactory();
|
consumerSessionFactory = consumerLocator.createSessionFactory();
|
||||||
ActiveMQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory);
|
ActiveMQRestLogger.LOGGER.debug("Created ClientSessionFactory: " + consumerSessionFactory);
|
||||||
|
|
||||||
ServerLocator defaultLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
|
ServerLocator defaultLocator = ActiveMQClient.createServerLocator(configuration.getUrl());
|
||||||
|
|
||||||
ClientSessionFactory sessionFactory = defaultLocator.createSessionFactory();
|
ClientSessionFactory sessionFactory = defaultLocator.createSessionFactory();
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ file. Below is the format of the XML configuration file and the default
|
||||||
values for each.
|
values for each.
|
||||||
|
|
||||||
<rest-messaging>
|
<rest-messaging>
|
||||||
<server-in-vm-id>0</server-in-vm-id>
|
<server-in-vm-id>0</server-in-vm-id> <!-- deprecated, use "url" -->
|
||||||
<use-link-headers>false</use-link-headers>
|
<use-link-headers>false</use-link-headers>
|
||||||
<default-durable-send>false</default-durable-send>
|
<default-durable-send>false</default-durable-send>
|
||||||
<dups-ok>true</dups-ok>
|
<dups-ok>true</dups-ok>
|
||||||
|
@ -218,14 +218,17 @@ values for each.
|
||||||
<producer-session-pool-size>10</producer-session-pool-size>
|
<producer-session-pool-size>10</producer-session-pool-size>
|
||||||
<session-timeout-task-interval>1</session-timeout-task-interval>
|
<session-timeout-task-interval>1</session-timeout-task-interval>
|
||||||
<consumer-session-timeout-seconds>300</consumer-session-timeout-seconds>
|
<consumer-session-timeout-seconds>300</consumer-session-timeout-seconds>
|
||||||
<consumer-window-size>-1</consumer-window-size>
|
<consumer-window-size>-1</consumer-window-size> <!-- deprecated, use "url" -->
|
||||||
|
<url>vm://0</url>
|
||||||
</rest-messaging>
|
</rest-messaging>
|
||||||
|
|
||||||
Let's give an explanation of each config option.
|
Let's give an explanation of each config option.
|
||||||
|
|
||||||
- `server-in-vm-id`. The Apache ActiveMQ Artemis REST impl uses the IN-VM transport
|
- `server-in-vm-id`. The Apache ActiveMQ Artemis REST implementation was formerly hard-coded
|
||||||
to communicate with Apache ActiveMQ Artemis. It uses the default server id, which
|
to use the in-vm transport to communicate with the embedded Apache ActiveMQ Artemis instance.
|
||||||
is "0".
|
This is the id of the embedded instance. It is "0" by default. Note: this is deprecated in
|
||||||
|
favor of `url` which can be used to connect to an arbitrary instance of Apache ActiveMQ
|
||||||
|
Artemis (including one over the network).
|
||||||
|
|
||||||
- `use-link-headers`. By default, all links (URLs) are published using
|
- `use-link-headers`. By default, all links (URLs) are published using
|
||||||
custom headers. You can instead have the Apache ActiveMQ Artemis REST
|
custom headers. You can instead have the Apache ActiveMQ Artemis REST
|
||||||
|
@ -265,6 +268,11 @@ Let's give an explanation of each config option.
|
||||||
- `consumer-window-size`. For consumers, this config option is the
|
- `consumer-window-size`. For consumers, this config option is the
|
||||||
same as the Apache ActiveMQ Artemis one of the same name. It will be used by
|
same as the Apache ActiveMQ Artemis one of the same name. It will be used by
|
||||||
sessions created by the Apache ActiveMQ Artemis REST implementation.
|
sessions created by the Apache ActiveMQ Artemis REST implementation.
|
||||||
|
This is deprecated in favor of `url` as it can be specified as a URL
|
||||||
|
parameter.
|
||||||
|
|
||||||
|
- `url`. The URL the Apache ActiveMQ Artemis REST implementation should use
|
||||||
|
to connect to the Apache ActiveMQ Artemis instance. Default to "vm://0".
|
||||||
|
|
||||||
## Apache ActiveMQ Artemis REST Interface Basics
|
## Apache ActiveMQ Artemis REST Interface Basics
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue