ARTEMIS-876 Remove JMS JMX Objects and add new Address JMX objects
This commit is contained in:
parent
0006627d12
commit
0189f156ec
|
@ -328,7 +328,7 @@ public final class XmlDataImporter extends ActionAbstract {
|
|||
// address may need the message
|
||||
try (ClientRequestor requestor = new ClientRequestor(managementSession, "activemq.management")) {
|
||||
ClientMessage managementMessage = managementSession.createMessage(false);
|
||||
ManagementHelper.putAttribute(managementMessage, "core.queue." + queue, "ID");
|
||||
ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queue, "ID");
|
||||
managementSession.start();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Requesting ID for: " + queue);
|
||||
|
@ -825,20 +825,7 @@ public final class XmlDataImporter extends ActionAbstract {
|
|||
reader.next();
|
||||
}
|
||||
|
||||
try (ClientRequestor requestor = new ClientRequestor(managementSession, "activemq.management")) {
|
||||
ClientMessage managementMessage = managementSession.createMessage(false);
|
||||
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createConnectionFactory", name, Boolean.parseBoolean(ha), discoveryGroupName.length() > 0, Integer.parseInt(type), connectors, entries, clientId, Long.parseLong(clientFailureCheckPeriod), Long.parseLong(connectionTtl), Long.parseLong(callTimeout), Long.parseLong(callFailoverTimeout), Integer.parseInt(minLargeMessageSize), Boolean.parseBoolean(compressLargeMessages), Integer.parseInt(consumerWindowSize), Integer.parseInt(consumerMaxRate), Integer.parseInt(confirmationWindowSize), Integer.parseInt(producerWindowSize), Integer.parseInt(producerMaxRate), Boolean.parseBoolean(blockOnAcknowledge), Boolean.parseBoolean(blockOnDurableSend), Boolean.parseBoolean(blockOnNonDurableSend), Boolean.parseBoolean(autoGroup), Boolean.parseBoolean(preacknowledge), loadBalancingPolicyClassName, Integer.parseInt(transactionBatchSize), Integer.parseInt(dupsOkBatchSize), Boolean.parseBoolean(useGlobalPools), Integer.parseInt(scheduledThreadMaxPoolSize), Integer.parseInt(threadMaxPoolSize), Long.parseLong(retryInterval), Double.parseDouble(retryIntervalMultiplier), Long.parseLong(maxRetryInterval), Integer.parseInt(reconnectAttempts), Boolean.parseBoolean(failoverOnInitialConnection), groupId);
|
||||
//Boolean.parseBoolean(cacheLargeMessagesClient));
|
||||
managementSession.start();
|
||||
ClientMessage reply = requestor.request(managementMessage);
|
||||
if (ManagementHelper.hasOperationSucceeded(reply)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Created connection factory " + name);
|
||||
}
|
||||
} else {
|
||||
ActiveMQServerLogger.LOGGER.error("Problem creating " + name);
|
||||
}
|
||||
}
|
||||
ActiveMQServerLogger.LOGGER.error("Ignoring Connection Factory " + name);
|
||||
}
|
||||
|
||||
private void createJmsDestination() throws Exception {
|
||||
|
@ -886,9 +873,9 @@ public final class XmlDataImporter extends ActionAbstract {
|
|||
try (ClientRequestor requestor = new ClientRequestor(managementSession, "activemq.management")) {
|
||||
ClientMessage managementMessage = managementSession.createMessage(false);
|
||||
if ("Queue".equals(type)) {
|
||||
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createQueue", name, entries, selector);
|
||||
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.BROKER, "createQueue", name, entries, selector);
|
||||
} else if ("Topic".equals(type)) {
|
||||
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createTopic", name, entries);
|
||||
ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.BROKER, "createAddress", name, entries);
|
||||
}
|
||||
managementSession.start();
|
||||
ClientMessage reply = requestor.request(managementMessage);
|
||||
|
|
|
@ -296,6 +296,14 @@ public interface ActiveMQServerControl {
|
|||
@Attribute(desc = "management address of this server")
|
||||
String getManagementAddress();
|
||||
|
||||
/**
|
||||
* Returns the node ID of this server.
|
||||
* <br>
|
||||
* Clients can send management messages to this address to manage this server.
|
||||
*/
|
||||
@Attribute(desc = "Node ID of this server")
|
||||
String getNodeID();
|
||||
|
||||
/**
|
||||
* Returns the management notification address of this server.
|
||||
* <br>
|
||||
|
@ -424,6 +432,15 @@ public interface ActiveMQServerControl {
|
|||
|
||||
// Operations ----------------------------------------------------
|
||||
|
||||
@Operation(desc = "create an address", impact = MBeanOperationInfo.ACTION)
|
||||
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
||||
@Parameter(name = "routingType", desc = "the routing type of the address either 0 for multicast or 1 for anycast") int routingType,
|
||||
@Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
|
||||
@Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception;
|
||||
|
||||
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
|
||||
void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Create a durable queue.
|
||||
* <br>
|
||||
|
@ -881,5 +898,8 @@ public interface ActiveMQServerControl {
|
|||
|
||||
@Operation(desc = "force the server to stop and to scale down to another server", impact = MBeanOperationInfo.UNKNOWN)
|
||||
void scaleDown(@Parameter(name = "name", desc = "The connector to use to scale down, if not provided the first appropriate connector will be used") String connector) throws Exception;
|
||||
|
||||
@Operation(desc = "List the Network Topology", impact = MBeanOperationInfo.INFO)
|
||||
String listNetworkTopology() throws Exception;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.api.core.management;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An AddressControl is used to manage an address.
|
||||
*/
|
||||
|
@ -27,6 +30,12 @@ public interface AddressControl {
|
|||
@Attribute(desc = "managed address")
|
||||
String getAddress();
|
||||
|
||||
/*
|
||||
* The routing type of this address, either multicast (topic subscriptions) or anycast (queue semantics).
|
||||
* */
|
||||
@Attribute(desc = "The routing type of this address")
|
||||
String getRoutingType();
|
||||
|
||||
/**
|
||||
* Returns the roles (name and permissions) associated with this address.
|
||||
*/
|
||||
|
@ -85,4 +94,25 @@ public interface AddressControl {
|
|||
*/
|
||||
@Attribute(desc = "names of all bindings (both queues and diverts) bound to this address")
|
||||
String[] getBindingNames() throws Exception;
|
||||
|
||||
@Attribute(desc = "number of messages added to all the queues for this address")
|
||||
long getMessageCount();
|
||||
|
||||
|
||||
/**
|
||||
* @param headers the message headers and properties to set. Can only
|
||||
* container Strings maped to primitive types.
|
||||
* @param body the text to send
|
||||
* @param durable
|
||||
* @param user
|
||||
* @param password @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected address.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendMessage(@Parameter(name = "headers", desc = "The headers to add to the message") Map<String, String> headers,
|
||||
@Parameter(name = "headers", desc = "A type for the message") final int type,
|
||||
@Parameter(name = "body", desc = "The body (byte[]) of the message encoded as a string using Base64") String body,
|
||||
@Parameter(name = "durable", desc = "Whether the message is durable") boolean durable,
|
||||
@Parameter(name = "user", desc = "The user to authenticate with") String user,
|
||||
@Parameter(name = "password", desc = "The users password to authenticate with") String password) throws Exception;
|
||||
}
|
||||
|
|
|
@ -33,10 +33,6 @@ public final class ObjectNameBuilder {
|
|||
*/
|
||||
public static final ObjectNameBuilder DEFAULT = new ObjectNameBuilder(ActiveMQDefaultConfiguration.getDefaultJmxDomain(), "localhost", true);
|
||||
|
||||
static final String JMS_MODULE = "JMS";
|
||||
|
||||
static final String CORE_MODULE = "Core";
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final String domain;
|
||||
|
@ -85,7 +81,7 @@ public final class ObjectNameBuilder {
|
|||
* Returns the ObjectName used by the single {@link ActiveMQServerControl}.
|
||||
*/
|
||||
public ObjectName getActiveMQServerObjectName() throws Exception {
|
||||
return ObjectName.getInstance(domain + ":" + getBrokerProperties() + "module=Core," + getObjectType() + "=Server");
|
||||
return ObjectName.getInstance(domain + ":" + getBrokerProperties() + getObjectType() + "=Broker");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +90,7 @@ public final class ObjectNameBuilder {
|
|||
* @see AddressControl
|
||||
*/
|
||||
public ObjectName getAddressObjectName(final SimpleString address) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "Address", address.toString());
|
||||
return createObjectName("Address", address.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +99,7 @@ public final class ObjectNameBuilder {
|
|||
* @see QueueControl
|
||||
*/
|
||||
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name) throws Exception {
|
||||
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "module=%s," + getObjectType() + "=%s,address=%s,name=%s", domain, ObjectNameBuilder.CORE_MODULE, "Queue", ObjectName.quote(address.toString()), ObjectName.quote(name.toString())));
|
||||
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", ObjectName.quote(name.toString())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,8 +107,8 @@ public final class ObjectNameBuilder {
|
|||
*
|
||||
* @see DivertControl
|
||||
*/
|
||||
public ObjectName getDivertObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "Divert", name);
|
||||
public ObjectName getDivertObjectName(final String name, String address) throws Exception {
|
||||
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Divert", ObjectName.quote(name.toString())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +117,7 @@ public final class ObjectNameBuilder {
|
|||
* @see AcceptorControl
|
||||
*/
|
||||
public ObjectName getAcceptorObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "Acceptor", name);
|
||||
return createObjectName("Acceptor", name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,7 +126,7 @@ public final class ObjectNameBuilder {
|
|||
* @see BroadcastGroupControl
|
||||
*/
|
||||
public ObjectName getBroadcastGroupObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "BroadcastGroup", name);
|
||||
return createObjectName("BroadcastGroup", name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +135,7 @@ public final class ObjectNameBuilder {
|
|||
* @see BridgeControl
|
||||
*/
|
||||
public ObjectName getBridgeObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "Bridge", name);
|
||||
return createObjectName("Bridge", name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,14 +144,14 @@ public final class ObjectNameBuilder {
|
|||
* @see ClusterConnectionControl
|
||||
*/
|
||||
public ObjectName getClusterConnectionObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "ClusterConnection", name);
|
||||
return createObjectName("ClusterConnection", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ObjectName used by DiscoveryGroupControl.
|
||||
*/
|
||||
public ObjectName getDiscoveryGroupObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.CORE_MODULE, "DiscoveryGroup", name);
|
||||
return createObjectName("DiscoveryGroup", name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,25 +165,25 @@ public final class ObjectNameBuilder {
|
|||
* Returns the ObjectName used by JMSQueueControl.
|
||||
*/
|
||||
public ObjectName getJMSQueueObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.JMS_MODULE, "Queue", name);
|
||||
return createObjectName("Queue", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ObjectName used by TopicControl.
|
||||
*/
|
||||
public ObjectName getJMSTopicObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.JMS_MODULE, "Topic", name);
|
||||
return createObjectName("Topic", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ObjectName used by ConnectionFactoryControl.
|
||||
*/
|
||||
public ObjectName getConnectionFactoryObjectName(final String name) throws Exception {
|
||||
return createObjectName(ObjectNameBuilder.JMS_MODULE, "ConnectionFactory", name);
|
||||
return createObjectName("ConnectionFactory", name);
|
||||
}
|
||||
|
||||
private ObjectName createObjectName(final String module, final String type, final String name) throws Exception {
|
||||
String format = String.format("%s:" + getBrokerProperties() + "module=%s," + getObjectType() + "=%s,name=%s", domain, module, type, ObjectName.quote(name));
|
||||
private ObjectName createObjectName(final String type, final String name) throws Exception {
|
||||
String format = String.format("%s:" + getBrokerProperties() + getObjectType() + "=%s,name=%s", domain, type, ObjectName.quote(name));
|
||||
return ObjectName.getInstance(format);
|
||||
}
|
||||
|
||||
|
|
|
@ -338,7 +338,6 @@ public interface QueueControl {
|
|||
* @param headers the message headers and properties to set. Can only
|
||||
* container Strings maped to primitive types.
|
||||
* @param body the text to send
|
||||
* @param userID
|
||||
* @param durable
|
||||
* @param user
|
||||
* @param password @return
|
||||
|
@ -348,7 +347,6 @@ public interface QueueControl {
|
|||
String sendMessage(@Parameter(name = "headers", desc = "The headers to add to the message") Map<String, String> headers,
|
||||
@Parameter(name = "headers", desc = "A type for the message") final int type,
|
||||
@Parameter(name = "body", desc = "The body (byte[]) of the message encoded as a string using Base64") String body,
|
||||
@Parameter(name = "body", desc = "The user ID to set on the message") String userID,
|
||||
@Parameter(name = "durable", desc = "Whether the message is durable") boolean durable,
|
||||
@Parameter(name = "user", desc = "The user to authenticate with") String user,
|
||||
@Parameter(name = "password", desc = "The users password to authenticate with") String password) throws Exception;
|
||||
|
@ -431,6 +429,9 @@ public interface QueueControl {
|
|||
@Attribute(desc = "whether the queue is paused")
|
||||
boolean isPaused() throws Exception;
|
||||
|
||||
@Operation(desc = "Browse Messages", impact = MBeanOperationInfo.ACTION)
|
||||
CompositeData[] browse() throws Exception;
|
||||
|
||||
/**
|
||||
* Resets the MessagesAdded property
|
||||
*/
|
||||
|
|
|
@ -20,35 +20,26 @@ package org.apache.activemq.artemis.api.core.management;
|
|||
* Helper class used to build resource names used by management messages.
|
||||
* <br>
|
||||
* Resource's name is build by appending its <em>name</em> to its corresponding type.
|
||||
* For example, the resource name of the "foo" queue is {@code CORE_QUEUE + "foo"}.
|
||||
* For example, the resource name of the "foo" queue is {@code QUEUE + "foo"}.
|
||||
*/
|
||||
public final class ResourceNames {
|
||||
public static final String BROKER = "broker";
|
||||
|
||||
public static final String CORE_SERVER = "core.server";
|
||||
public static final String QUEUE = "queue.";
|
||||
|
||||
public static final String CORE_QUEUE = "core.queue.";
|
||||
public static final String ADDRESS = "address.";
|
||||
|
||||
public static final String CORE_ADDRESS = "core.address.";
|
||||
public static final String BRIDGE = "bridge.";
|
||||
|
||||
public static final String CORE_BRIDGE = "core.bridge.";
|
||||
public static final String ACCEPTOR = "acceptor.";
|
||||
|
||||
public static final String CORE_ACCEPTOR = "core.acceptor.";
|
||||
public static final String DIVERT = "divert.";
|
||||
|
||||
public static final String CORE_DIVERT = "core.divert.";
|
||||
public static final String CORE_CLUSTER_CONNECTION = "clusterconnection.";
|
||||
|
||||
public static final String CORE_CLUSTER_CONNECTION = "core.clusterconnection.";
|
||||
public static final String BROADCAST_GROUP = "broadcastgroup.";
|
||||
|
||||
public static final String CORE_BROADCAST_GROUP = "core.broadcastgroup.";
|
||||
|
||||
public static final String CORE_DISCOVERY_GROUP = "core.discovery.";
|
||||
|
||||
public static final String JMS_SERVER = "jms.server";
|
||||
|
||||
// public static final String JMS_QUEUE = "jms.queue.";
|
||||
|
||||
// public static final String JMS_TOPIC = "jms.topic.";
|
||||
|
||||
public static final String JMS_CONNECTION_FACTORY = "jms.connectionfactory.";
|
||||
public static final String DISCOVERY_GROUP = "discovery.";
|
||||
|
||||
private ResourceNames() {
|
||||
}
|
||||
|
|
|
@ -1,399 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
|
||||
/**
|
||||
* A ConnectionFactoryControl is used to manage a JMS ConnectionFactory. <br>
|
||||
* ActiveMQ Artemis JMS ConnectionFactory uses an underlying ClientSessionFactory to connect to ActiveMQ
|
||||
* servers. Please refer to the ClientSessionFactory for a detailed description.
|
||||
*
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator
|
||||
* @see org.apache.activemq.artemis.api.core.client.ClientSessionFactory
|
||||
*/
|
||||
public interface ConnectionFactoryControl {
|
||||
|
||||
/**
|
||||
* Returns the configuration name of this connection factory.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the Registry bindings associated to this connection factory.
|
||||
*/
|
||||
String[] getRegistryBindings();
|
||||
|
||||
/**
|
||||
* does ths cf support HA
|
||||
*
|
||||
* @return true if it supports HA
|
||||
*/
|
||||
boolean isHA();
|
||||
|
||||
/**
|
||||
* return the type of factory
|
||||
*
|
||||
* @return 0 = jms cf, 1 = queue cf, 2 = topic cf, 3 = xa cf, 4 = xa queue cf, 5 = xa topic cf
|
||||
*/
|
||||
int getFactoryType();
|
||||
|
||||
/**
|
||||
* Returns the Client ID of this connection factory (or {@code null} if it is not set.
|
||||
*/
|
||||
String getClientID();
|
||||
|
||||
/**
|
||||
* Sets the Client ID for this connection factory.
|
||||
*/
|
||||
void setClientID(String clientID);
|
||||
|
||||
/**
|
||||
* @return whether large messages are compressed
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isCompressLargeMessage()
|
||||
*/
|
||||
boolean isCompressLargeMessages();
|
||||
|
||||
void setCompressLargeMessages(boolean compress);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getClientFailureCheckPeriod()
|
||||
*/
|
||||
long getClientFailureCheckPeriod();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setClientFailureCheckPeriod
|
||||
*/
|
||||
void setClientFailureCheckPeriod(long clientFailureCheckPeriod);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getCallTimeout()
|
||||
*/
|
||||
long getCallTimeout();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setCallTimeout(long)
|
||||
*/
|
||||
void setCallTimeout(long callTimeout);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getCallFailoverTimeout()
|
||||
*/
|
||||
long getCallFailoverTimeout();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setCallFailoverTimeout(long)
|
||||
*/
|
||||
|
||||
void setCallFailoverTimeout(long callTimeout);
|
||||
|
||||
/**
|
||||
* Returns the batch size (in bytes) between acknowledgements when using DUPS_OK_ACKNOWLEDGE
|
||||
* mode.
|
||||
*
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getAckBatchSize()
|
||||
* @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE
|
||||
*/
|
||||
int getDupsOKBatchSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setAckBatchSize(int)
|
||||
*/
|
||||
void setDupsOKBatchSize(int dupsOKBatchSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getConsumerMaxRate()
|
||||
*/
|
||||
int getConsumerMaxRate();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setConsumerMaxRate(int)
|
||||
*/
|
||||
void setConsumerMaxRate(int consumerMaxRate);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getConsumerWindowSize()
|
||||
*/
|
||||
int getConsumerWindowSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setConfirmationWindowSize(int)
|
||||
*/
|
||||
void setConsumerWindowSize(int consumerWindowSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getProducerMaxRate()
|
||||
*/
|
||||
int getProducerMaxRate();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setProducerMaxRate(int)
|
||||
*/
|
||||
void setProducerMaxRate(int producerMaxRate);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getConfirmationWindowSize()
|
||||
*/
|
||||
int getConfirmationWindowSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setConfirmationWindowSize(int)
|
||||
*/
|
||||
void setConfirmationWindowSize(int confirmationWindowSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isBlockOnAcknowledge()
|
||||
*/
|
||||
boolean isBlockOnAcknowledge();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setBlockOnAcknowledge(boolean)
|
||||
*/
|
||||
void setBlockOnAcknowledge(boolean blockOnAcknowledge);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isBlockOnDurableSend()
|
||||
*/
|
||||
boolean isBlockOnDurableSend();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setBlockOnDurableSend(boolean)
|
||||
*/
|
||||
void setBlockOnDurableSend(boolean blockOnDurableSend);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isBlockOnNonDurableSend()
|
||||
*/
|
||||
boolean isBlockOnNonDurableSend();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setBlockOnNonDurableSend(boolean)
|
||||
*/
|
||||
void setBlockOnNonDurableSend(boolean blockOnNonDurableSend);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isPreAcknowledge()
|
||||
*/
|
||||
boolean isPreAcknowledge();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setPreAcknowledge(boolean)
|
||||
*/
|
||||
void setPreAcknowledge(boolean preAcknowledge);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getConnectionTTL()
|
||||
*/
|
||||
long getConnectionTTL();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setConnectionTTL(long)
|
||||
*/
|
||||
void setConnectionTTL(long connectionTTL);
|
||||
|
||||
/**
|
||||
* Returns the batch size (in bytes) between acknowledgements when using a transacted session.
|
||||
*
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getAckBatchSize()
|
||||
*/
|
||||
int getTransactionBatchSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setAckBatchSize(int)
|
||||
*/
|
||||
void setTransactionBatchSize(int transactionBatchSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getMinLargeMessageSize()
|
||||
*/
|
||||
int getMinLargeMessageSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setMinLargeMessageSize(int)
|
||||
*/
|
||||
void setMinLargeMessageSize(int minLargeMessageSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isAutoGroup()
|
||||
*/
|
||||
boolean isAutoGroup();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setAutoGroup(boolean)
|
||||
*/
|
||||
void setAutoGroup(boolean autoGroup);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getRetryInterval()
|
||||
*/
|
||||
long getRetryInterval();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setRetryInterval(long)
|
||||
*/
|
||||
void setRetryInterval(long retryInterval);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getRetryIntervalMultiplier()
|
||||
*/
|
||||
double getRetryIntervalMultiplier();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setRetryIntervalMultiplier(double)
|
||||
*/
|
||||
void setRetryIntervalMultiplier(double retryIntervalMultiplier);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getReconnectAttempts()
|
||||
*/
|
||||
int getReconnectAttempts();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setReconnectAttempts(int)
|
||||
*/
|
||||
void setReconnectAttempts(int reconnectAttempts);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isFailoverOnInitialConnection()
|
||||
*/
|
||||
boolean isFailoverOnInitialConnection();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setFailoverOnInitialConnection(boolean)
|
||||
*/
|
||||
void setFailoverOnInitialConnection(boolean failoverOnInitialConnection);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getProducerWindowSize()
|
||||
*/
|
||||
int getProducerWindowSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setProducerWindowSize(int)
|
||||
*/
|
||||
void setProducerWindowSize(int producerWindowSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isCacheLargeMessagesClient()
|
||||
*/
|
||||
boolean isCacheLargeMessagesClient();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setCacheLargeMessagesClient(boolean)
|
||||
*/
|
||||
void setCacheLargeMessagesClient(boolean cacheLargeMessagesClient);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getMaxRetryInterval()
|
||||
*/
|
||||
long getMaxRetryInterval();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setMaxRetryInterval(long)
|
||||
*/
|
||||
void setMaxRetryInterval(long retryInterval);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getScheduledThreadPoolMaxSize()
|
||||
*/
|
||||
int getScheduledThreadPoolMaxSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setScheduledThreadPoolMaxSize(int)
|
||||
*/
|
||||
void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getThreadPoolMaxSize()
|
||||
*/
|
||||
int getThreadPoolMaxSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setThreadPoolMaxSize(int)
|
||||
*/
|
||||
void setThreadPoolMaxSize(int threadPoolMaxSize);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getGroupID()
|
||||
*/
|
||||
String getGroupID();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setGroupID(String)
|
||||
*/
|
||||
void setGroupID(String groupID);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getInitialMessagePacketSize()
|
||||
*/
|
||||
int getInitialMessagePacketSize();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#isUseGlobalPools()
|
||||
*/
|
||||
boolean isUseGlobalPools();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setUseGlobalPools(boolean)
|
||||
*/
|
||||
void setUseGlobalPools(boolean useGlobalPools);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getConnectionLoadBalancingPolicyClassName()
|
||||
*/
|
||||
String getConnectionLoadBalancingPolicyClassName();
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#setConnectionLoadBalancingPolicyClassName(String)
|
||||
*/
|
||||
void setConnectionLoadBalancingPolicyClassName(String connectionLoadBalancingPolicyClassName);
|
||||
|
||||
/**
|
||||
* @see org.apache.activemq.artemis.api.core.client.ServerLocator#getStaticTransportConfigurations()
|
||||
*/
|
||||
TransportConfiguration[] getStaticConnectors();
|
||||
|
||||
/**
|
||||
* get the discovery group configuration
|
||||
*/
|
||||
DiscoveryGroupConfiguration getDiscoveryGroupConfiguration();
|
||||
|
||||
/**
|
||||
* get the protocol manager factory name
|
||||
*/
|
||||
String getProtocolManagerFactoryStr();
|
||||
|
||||
/**
|
||||
* set the protocol manager factory name
|
||||
*/
|
||||
void setProtocolManagerFactoryStr(String protocolManagerFactoryStr);
|
||||
|
||||
/**
|
||||
* Add the Registry binding to this destination
|
||||
*/
|
||||
@Operation(desc = "Adds the factory to another Registry binding")
|
||||
void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception;
|
||||
|
||||
/**
|
||||
* Remove a Registry binding
|
||||
*/
|
||||
@Operation(desc = "Remove an existing Registry binding")
|
||||
void removeBinding(@Parameter(name = "binding", desc = "the name of the binding for Registry") String binding) throws Exception;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.Attribute;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
|
||||
/**
|
||||
* A DestinationControl is used to manage a JMS Destination.
|
||||
*/
|
||||
public interface DestinationControl {
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the name of this destination.
|
||||
*/
|
||||
@Attribute(desc = "the name of this destination")
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the address corresponding to this destination.
|
||||
*/
|
||||
@Attribute(desc = "the address corresponding to this destination")
|
||||
String getAddress();
|
||||
|
||||
/**
|
||||
* Returns whether this destination is temporary.
|
||||
*/
|
||||
@Attribute(desc = "whether this destination is temporary")
|
||||
boolean isTemporary();
|
||||
|
||||
/**
|
||||
* Returns the number of messages currently in this destination.
|
||||
*/
|
||||
@Attribute(desc = "the number of messages currently in this destination")
|
||||
long getMessageCount() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the number of messages that this queue is currently delivering to its consumers.
|
||||
*/
|
||||
@Attribute(desc = "the number of messages that this queue is currently delivering to its consumers")
|
||||
int getDeliveringCount();
|
||||
|
||||
/**
|
||||
* Returns the number of messages added to this queue since it was created.
|
||||
*/
|
||||
@Attribute(desc = "the number of messages added to this queue since it was created")
|
||||
long getMessagesAdded();
|
||||
|
||||
// Operations ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Removed all the messages which matches the specified JMS filter from this destination.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will remove <em>all</em> messages from this destination.
|
||||
*
|
||||
* @return the number of removed messages
|
||||
*/
|
||||
@Operation(desc = "Remove messages matching the given filter from the destination", impact = MBeanOperationInfo.ACTION)
|
||||
int removeMessages(@Parameter(name = "filter", desc = "A JMS message filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
|
||||
public class JMSConnectionInfo {
|
||||
|
||||
private final String connectionID;
|
||||
|
||||
private final String clientAddress;
|
||||
|
||||
private final long creationTime;
|
||||
|
||||
private final String clientID;
|
||||
|
||||
private final String username;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
public static JMSConnectionInfo[] from(final String jsonString) throws Exception {
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonObject obj = array.getJsonObject(i);
|
||||
String cid = obj.containsKey("clientID") ? obj.getString("clientID") : null;
|
||||
String uname = obj.containsKey("principal") ? obj.getString("principal") : null;
|
||||
|
||||
JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"), obj.getJsonNumber("creationTime").longValue(), cid, uname);
|
||||
infos[i] = info;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
private JMSConnectionInfo(final String connectionID,
|
||||
final String clientAddress,
|
||||
final long creationTime,
|
||||
final String clientID,
|
||||
final String username) {
|
||||
this.connectionID = connectionID;
|
||||
this.clientAddress = clientAddress;
|
||||
this.creationTime = creationTime;
|
||||
this.clientID = clientID;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
public String getConnectionID() {
|
||||
return connectionID;
|
||||
}
|
||||
|
||||
public String getClientAddress() {
|
||||
return clientAddress;
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
|
||||
/**
|
||||
* Helper class to create Java Objects from the
|
||||
* JSON serialization returned by {@link JMSServerControl#listConsumersAsJSON(String)} and related methods.
|
||||
*/
|
||||
public class JMSConsumerInfo {
|
||||
|
||||
private final String consumerID;
|
||||
|
||||
private final String connectionID;
|
||||
|
||||
private final String destinationName;
|
||||
|
||||
private final String destinationType;
|
||||
|
||||
private final boolean browseOnly;
|
||||
|
||||
private final long creationTime;
|
||||
|
||||
private final boolean durable;
|
||||
|
||||
private final String filter;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an array of SubscriptionInfo corresponding to the JSON serialization returned
|
||||
* by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods.
|
||||
*/
|
||||
public static JMSConsumerInfo[] from(final String jsonString) throws Exception {
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonObject sub = array.getJsonObject(i);
|
||||
JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(), sub.getString("connectionID"), sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"), sub.getJsonNumber("creationTime").longValue(), sub.getBoolean("durable"), sub.getString("filter", null));
|
||||
infos[i] = info;
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
private JMSConsumerInfo(final String consumerID,
|
||||
final String connectionID,
|
||||
final String destinationName,
|
||||
final String destinationType,
|
||||
final boolean browseOnly,
|
||||
final long creationTime,
|
||||
final boolean durable,
|
||||
final String filter) {
|
||||
this.consumerID = consumerID;
|
||||
this.connectionID = connectionID;
|
||||
this.destinationName = destinationName;
|
||||
this.destinationType = destinationType;
|
||||
this.browseOnly = browseOnly;
|
||||
this.creationTime = creationTime;
|
||||
this.durable = durable;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
public String getConsumerID() {
|
||||
return consumerID;
|
||||
}
|
||||
|
||||
public String getConnectionID() {
|
||||
return connectionID;
|
||||
}
|
||||
|
||||
public String getDestinationName() {
|
||||
return destinationName;
|
||||
}
|
||||
|
||||
public String getDestinationType() {
|
||||
return destinationType;
|
||||
}
|
||||
|
||||
public boolean isBrowseOnly() {
|
||||
return browseOnly;
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the durable
|
||||
*/
|
||||
public boolean isDurable() {
|
||||
return durable;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
|
@ -1,443 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.Attribute;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
|
||||
/**
|
||||
* A JMSQueueControl is used to manage a JMS queue.
|
||||
*/
|
||||
public interface JMSQueueControl extends DestinationControl {
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the expiry address associated with this queue.
|
||||
*/
|
||||
@Attribute(desc = "expiry address associated with this queue")
|
||||
String getExpiryAddress();
|
||||
|
||||
/**
|
||||
* Returns the dead-letter address associated with this queue.
|
||||
*/
|
||||
@Attribute(desc = "dead-letter address associated with this queue")
|
||||
String getDeadLetterAddress();
|
||||
|
||||
/**
|
||||
* Returns the number of scheduled messages in this queue.
|
||||
*/
|
||||
@Attribute(desc = "number of scheduled messages in this queue")
|
||||
long getScheduledCount();
|
||||
|
||||
/**
|
||||
* Returns the number of consumers consuming messages from this queue.
|
||||
*/
|
||||
@Attribute(desc = "number of consumers consuming messages from this queue")
|
||||
int getConsumerCount();
|
||||
|
||||
/**
|
||||
* Returns the number of messages expired from this queue since it was created.
|
||||
*/
|
||||
@Attribute(desc = "the number of messages expired from this queue since it was created")
|
||||
long getMessagesExpired();
|
||||
|
||||
/**
|
||||
* Returns the number of messages removed from this queue since it was created due to exceeding the max delivery attempts.
|
||||
*/
|
||||
@Attribute(desc = "number of messages removed from this queue since it was created due to exceeding the max delivery attempts")
|
||||
long getMessagesKilled();
|
||||
|
||||
/**
|
||||
* returns the selector for the queue
|
||||
*/
|
||||
@Attribute(desc = "selector for the queue")
|
||||
String getSelector();
|
||||
|
||||
/**
|
||||
* Returns the first message on the queue as JSON
|
||||
*/
|
||||
@Attribute(desc = "first message on the queue as JSON")
|
||||
String getFirstMessageAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the first message in milliseconds.
|
||||
*/
|
||||
@Attribute(desc = "timestamp of the first message in milliseconds")
|
||||
Long getFirstMessageTimestamp() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the age of the first message in milliseconds.
|
||||
*/
|
||||
@Attribute(desc = "age of the first message in milliseconds")
|
||||
Long getFirstMessageAge() throws Exception;
|
||||
|
||||
// Operations ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the Registry bindings associated with this queue.
|
||||
*/
|
||||
@Attribute(desc = "Returns the list of Registry bindings associated with this queue")
|
||||
String[] getRegistryBindings();
|
||||
|
||||
/**
|
||||
* Add the JNDI binding to this destination
|
||||
*/
|
||||
@Operation(desc = "Adds the queue to another Registry binding")
|
||||
void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the registry") String binding) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the JMS messages in this queue matching the specified filter.
|
||||
* <br>
|
||||
* 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will list <em>all</em> messages from this queue.
|
||||
*/
|
||||
@Operation(desc = "List all messages in the queue which matches the filter", impact = MBeanOperationInfo.INFO)
|
||||
Map<String, Object>[] listMessages(@Parameter(name = "filter", desc = "A JMS Message filter") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the JMS messages in this queue matching the specified filter using JSON serialization.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will list <em>all</em> messages from this queue.
|
||||
*/
|
||||
@Operation(desc = "List all messages in the queue which matches the filter and return them using JSON", impact = MBeanOperationInfo.INFO)
|
||||
String listMessagesAsJSON(@Parameter(name = "filter", desc = "A JMS Message filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Counts the number of messages in this queue matching the specified filter.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will count <em>all</em> messages from this queue.
|
||||
*/
|
||||
@Operation(desc = "Returns the number of the messages in the queue matching the given filter", impact = MBeanOperationInfo.INFO)
|
||||
long countMessages(@Parameter(name = "filter", desc = "A JMS message filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Removes the message corresponding to the specified message ID.
|
||||
*
|
||||
* @return {@code true} if the message was removed, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Remove the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION)
|
||||
boolean removeMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception;
|
||||
|
||||
/**
|
||||
* Removes all the message corresponding to the specified filter.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will remove <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of removed messages
|
||||
*/
|
||||
@Override
|
||||
@Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of removed messages)", impact = MBeanOperationInfo.ACTION)
|
||||
int removeMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Expires all the message corresponding to the specified filter.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will expire <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of expired messages
|
||||
*/
|
||||
@Operation(desc = "Expire the messages corresponding to the given filter (and returns the number of expired messages)", impact = MBeanOperationInfo.ACTION)
|
||||
int expireMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Expires the message corresponding to the specified message ID.
|
||||
*
|
||||
* @return {@code true} if the message was expired, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Expire the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION)
|
||||
boolean expireMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends the message corresponding to the specified message ID to this queue's dead letter address.
|
||||
*
|
||||
* @return {@code true} if the message was sent to the dead letter address, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Send the message corresponding to the given messageID to this queue's Dead Letter Address", impact = MBeanOperationInfo.ACTION)
|
||||
boolean sendMessageToDeadLetterAddress(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends all the message corresponding to the specified filter to this queue's dead letter address.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will send <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of sent messages
|
||||
*/
|
||||
@Operation(desc = "Send the messages corresponding to the given filter to this queue's Dead Letter Address", impact = MBeanOperationInfo.ACTION)
|
||||
int sendMessagesToDeadLetterAddress(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filterStr) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends a TextMesage to the destination.
|
||||
*
|
||||
* @param body the text to send
|
||||
* @return the message id of the message sent.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendTextMessage(@Parameter(name = "body") String body) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends a TextMessage to the destination.
|
||||
*
|
||||
* @param properties the message properties to set as a comma sep name=value list. Can only
|
||||
* contain Strings maped to primitive types or JMS properties. eg: body=hi,JMSReplyTo=Queue2
|
||||
* @return the message id of the message sent.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendTextMessageWithProperties(String properties) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends a TextMesage to the destination.
|
||||
*
|
||||
* @param headers the message headers and properties to set. Can only
|
||||
* container Strings maped to primitive types.
|
||||
* @param body the text to send
|
||||
* @return the message id of the message sent.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendTextMessage(@Parameter(name = "headers") Map<String, String> headers,
|
||||
@Parameter(name = "body") String body) throws Exception;
|
||||
|
||||
/**
|
||||
* Sends a TextMesage to the destination.
|
||||
*
|
||||
* @param body the text to send
|
||||
* @param user
|
||||
* @param password
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendTextMessage(@Parameter(name = "body") String body,
|
||||
@Parameter(name = "user") String user,
|
||||
@Parameter(name = "password") String password) throws Exception;
|
||||
|
||||
/**
|
||||
* @param headers the message headers and properties to set. Can only
|
||||
* container Strings maped to primitive types.
|
||||
* @param body the text to send
|
||||
* @param user
|
||||
* @param password
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Sends a TextMessage to a password-protected destination.", impact = MBeanOperationInfo.ACTION)
|
||||
String sendTextMessage(@Parameter(name = "headers") Map<String, String> headers,
|
||||
@Parameter(name = "body") String body,
|
||||
@Parameter(name = "user") String user,
|
||||
@Parameter(name = "password") String password) throws Exception;
|
||||
|
||||
/**
|
||||
* Changes the message's priority corresponding to the specified message ID to the specified priority.
|
||||
*
|
||||
* @param newPriority between 0 and 9 inclusive.
|
||||
* @return {@code true} if the message priority was changed
|
||||
*/
|
||||
@Operation(desc = "Change the priority of the message corresponding to the given messageID", impact = MBeanOperationInfo.ACTION)
|
||||
boolean changeMessagePriority(@Parameter(name = "messageID", desc = "A message ID") String messageID,
|
||||
@Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority) throws Exception;
|
||||
|
||||
/**
|
||||
* Changes the priority for all the message corresponding to the specified filter to the specified priority.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will change <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of changed messages
|
||||
*/
|
||||
@Operation(desc = "Change the priority of the messages corresponding to the given filter", impact = MBeanOperationInfo.ACTION)
|
||||
int changeMessagesPriority(@Parameter(name = "filter", desc = "A message filter") String filter,
|
||||
@Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority) throws Exception;
|
||||
|
||||
/**
|
||||
* Moves the message corresponding to the specified message ID to the specified other queue.
|
||||
*
|
||||
* @return {@code true} if the message was moved, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Move the message corresponding to the given messageID to another queue, ignoring duplicates (rejectDuplicates=false on this case)", impact = MBeanOperationInfo.ACTION)
|
||||
boolean moveMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID,
|
||||
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName) throws Exception;
|
||||
|
||||
/**
|
||||
* Moves the message corresponding to the specified message ID to the specified other queue.
|
||||
*
|
||||
* @return {@code true} if the message was moved, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Move the message corresponding to the given messageID to another queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean moveMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID,
|
||||
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName,
|
||||
@Parameter(name = "rejectDuplicates", desc = "Reject messages identified as duplicate by the duplicate message") boolean rejectDuplicates) throws Exception;
|
||||
|
||||
/**
|
||||
* Moves all the message corresponding to the specified filter to the specified other queue.
|
||||
* RejectDuplicates=false on this case
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will move <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of moved messages
|
||||
*/
|
||||
@Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages). rejectDuplicates=false on this case", impact = MBeanOperationInfo.ACTION)
|
||||
int moveMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter,
|
||||
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName) throws Exception;
|
||||
|
||||
/**
|
||||
* Moves all the message corresponding to the specified filter to the specified other queue.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will move <em>all</em> messages from this queue.
|
||||
*
|
||||
* @return the number of moved messages
|
||||
*/
|
||||
@Operation(desc = "Move the messages corresponding to the given filter (and returns the number of moved messages)", impact = MBeanOperationInfo.ACTION)
|
||||
int moveMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter,
|
||||
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName,
|
||||
@Parameter(name = "rejectDuplicates", desc = "Reject messages identified as duplicate by the duplicate message") boolean rejectDuplicates) throws Exception;
|
||||
|
||||
/**
|
||||
* Retries the message corresponding to the given messageID to the original queue.
|
||||
* This is appropriate on dead messages on Dead letter queues only.
|
||||
*
|
||||
* @param messageID
|
||||
* @return {@code true} if the message was retried, {@code false} else
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Retry the message corresponding to the given messageID to the original queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean retryMessage(@Parameter(name = "messageID", desc = "A message ID") String messageID) throws Exception;
|
||||
|
||||
/**
|
||||
* Retries all messages on a DLQ to their respective original queues.
|
||||
* This is appropriate on dead messages on Dead letter queues only.
|
||||
*
|
||||
* @return the number of retried messages.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "Retry all messages on a DLQ to their respective original queues", impact = MBeanOperationInfo.ACTION)
|
||||
int retryMessages() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the message counter for this queue.
|
||||
*/
|
||||
@Operation(desc = "List the message counters", impact = MBeanOperationInfo.INFO)
|
||||
String listMessageCounter() throws Exception;
|
||||
|
||||
/**
|
||||
* Resets the message counter for this queue.
|
||||
*/
|
||||
@Operation(desc = "Reset the message counters", impact = MBeanOperationInfo.INFO)
|
||||
void resetMessageCounter() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the message counter for this queue as a HTML table.
|
||||
*/
|
||||
@Operation(desc = "List the message counters as HTML", impact = MBeanOperationInfo.INFO)
|
||||
String listMessageCounterAsHTML() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the message counter history for this queue.
|
||||
*/
|
||||
@Operation(desc = "List the message counters history", impact = MBeanOperationInfo.INFO)
|
||||
String listMessageCounterHistory() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the message counter history for this queue as a HTML table.
|
||||
*/
|
||||
@Operation(desc = "List the message counters history as HTML", impact = MBeanOperationInfo.INFO)
|
||||
String listMessageCounterHistoryAsHTML() throws Exception;
|
||||
|
||||
/**
|
||||
* Pauses the queue. Messages are no longer delivered to its consumers.
|
||||
*/
|
||||
@Operation(desc = "Pause the queue.", impact = MBeanOperationInfo.ACTION)
|
||||
void pause() throws Exception;
|
||||
|
||||
/**
|
||||
* Pauses the queue. Messages are no longer delivered to its consumers.
|
||||
*/
|
||||
@Operation(desc = "Pauses the Queue", impact = MBeanOperationInfo.ACTION)
|
||||
void pause(@Parameter(name = "persist", desc = "if true, the pause state will be persisted.") boolean persist) throws Exception;
|
||||
|
||||
/**
|
||||
* Returns whether the queue is paused.
|
||||
*/
|
||||
@Attribute(desc = "Returns true if the queue is paused.")
|
||||
boolean isPaused() throws Exception;
|
||||
|
||||
/**
|
||||
* Resumes the queue. Messages are again delivered to its consumers.
|
||||
*/
|
||||
@Operation(desc = "Resume the queue.", impact = MBeanOperationInfo.ACTION)
|
||||
void resume() throws Exception;
|
||||
|
||||
/**
|
||||
* Resumes the queue. Messages are again delivered to its consumers.
|
||||
*/
|
||||
@Operation(desc = "Browse the queue.", impact = MBeanOperationInfo.ACTION)
|
||||
CompositeData[] browse() throws Exception;
|
||||
|
||||
/**
|
||||
* Resumes the queue. Messages are again delivered to its consumers.
|
||||
*/
|
||||
@Operation(desc = "Browse the queue.", impact = MBeanOperationInfo.ACTION)
|
||||
CompositeData[] browse(String filter) throws Exception;
|
||||
|
||||
@Operation(desc = "List all the existent consumers on the Queue")
|
||||
String listConsumersAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* it will flush one cycle on internal executors, so you would be sure that any pending tasks are done before you call
|
||||
* any other measure.
|
||||
* It is useful if you need the exact number of counts on a message
|
||||
*/
|
||||
void flushExecutor();
|
||||
|
||||
/**
|
||||
* Lists all the messages scheduled for delivery for this queue.
|
||||
* <br>
|
||||
* 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values.
|
||||
*/
|
||||
@Operation(desc = "List the messages scheduled for delivery", impact = MBeanOperationInfo.INFO)
|
||||
Map<String, Object>[] listScheduledMessages() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the messages scheduled for delivery for this queue using JSON serialization.
|
||||
*/
|
||||
@Operation(desc = "List the messages scheduled for delivery and returns them using JSON", impact = MBeanOperationInfo.INFO)
|
||||
String listScheduledMessagesAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the messages being deliver per consumer.
|
||||
* <br>
|
||||
* The Map's key is a toString representation for the consumer. Each consumer will then return a {@code Map<String,Object>[]} same way is returned by {@link #listScheduledMessages()}
|
||||
*/
|
||||
@Operation(desc = "List all messages being delivered per consumer")
|
||||
Map<String, Map<String, Object>[]> listDeliveringMessages() throws Exception;
|
||||
|
||||
/**
|
||||
* Executes a conversion of {@link #listDeliveringMessages()} to JSON
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(desc = "list all messages being delivered per consumer using JSON form")
|
||||
String listDeliveringMessagesAsJSON() throws Exception;
|
||||
|
||||
}
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.Attribute;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
|
||||
/**
|
||||
* A JMSSserverControl is used to manage ActiveMQ Artemis JMS server.
|
||||
*/
|
||||
public interface JMSServerControl {
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns whether this server is started.
|
||||
*/
|
||||
@Attribute(desc = "whether this server is started")
|
||||
boolean isStarted();
|
||||
|
||||
/**
|
||||
* Returns this server's version
|
||||
*/
|
||||
@Attribute(desc = "server's version")
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the names of the JMS topics available on this server.
|
||||
*/
|
||||
@Attribute(desc = "names of the JMS topics available on this server")
|
||||
String[] getTopicNames();
|
||||
|
||||
/**
|
||||
* Returns the names of the JMS queues available on this server.
|
||||
*/
|
||||
@Attribute(desc = "names of the JMS queues available on this server")
|
||||
String[] getQueueNames();
|
||||
|
||||
/**
|
||||
* Returns the names of the JMS connection factories available on this server.
|
||||
*/
|
||||
@Attribute(desc = "names of the JMS connection factories available on this server")
|
||||
String[] getConnectionFactoryNames();
|
||||
|
||||
/**
|
||||
* Returns the server's nodeId
|
||||
*/
|
||||
@Attribute(desc = "server's nodeId")
|
||||
String getNodeID();
|
||||
|
||||
// Operations ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a durable JMS Queue.
|
||||
*
|
||||
* @return {@code true} if the queue was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Creates a durable JMS Queue with the specified name and JNDI binding.
|
||||
*
|
||||
* @return {@code true} if the queue was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
|
||||
|
||||
/**
|
||||
* Creates a durable JMS Queue with the specified name, JNDI binding and selector.
|
||||
*
|
||||
* @return {@code true} if the queue was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings,
|
||||
@Parameter(name = "selector", desc = "the jms selector") String selector) throws Exception;
|
||||
|
||||
/**
|
||||
* Creates a JMS Queue with the specified name, durability, selector and JNDI binding.
|
||||
*
|
||||
* @return {@code true} if the queue was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings,
|
||||
@Parameter(name = "selector", desc = "the jms selector") String selector,
|
||||
@Parameter(name = "durable", desc = "durability of the queue") boolean durable) throws Exception;
|
||||
|
||||
/**
|
||||
* Destroys a JMS Queue with the specified name.
|
||||
*
|
||||
* @return {@code true} if the queue was destroyed, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Destroy a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Destroys a JMS Queue with the specified name.
|
||||
*
|
||||
* @return {@code true} if the queue was destroyed, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Destroy a JMS Queue", impact = MBeanOperationInfo.ACTION)
|
||||
boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name,
|
||||
@Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
|
||||
|
||||
/**
|
||||
* Creates a JMS Topic.
|
||||
*
|
||||
* @return {@code true} if the topic was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Creates a JMS Topic with the specified name and JNDI binding.
|
||||
*
|
||||
* @return {@code true} if the topic was created, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
|
||||
boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
|
||||
|
||||
/**
|
||||
* Destroys a JMS Topic with the specified name.
|
||||
*
|
||||
* @return {@code true} if the topic was destroyed, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Destroy a JMS Topic", impact = MBeanOperationInfo.ACTION)
|
||||
boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name,
|
||||
@Parameter(name = "removeConsumers", desc = "disconnect any consumers connected to this queue") boolean removeConsumers) throws Exception;
|
||||
|
||||
/**
|
||||
* Destroys a JMS Topic with the specified name.
|
||||
*
|
||||
* @return {@code true} if the topic was destroyed, {@code false} else
|
||||
*/
|
||||
@Operation(desc = "Destroy a JMS Topic", impact = MBeanOperationInfo.ACTION)
|
||||
boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Create a JMS ConnectionFactory with the specified name connected to a static list of live-backup servers.
|
||||
* <br>
|
||||
* The ConnectionFactory is bound to JNDI for all the specified bindings Strings.
|
||||
* <br>
|
||||
* {@code liveConnectorsTransportClassNames} are the class names
|
||||
* of the {@link org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory} to connect to the live servers
|
||||
* and {@code liveConnectorTransportParams} are Map<String, Object> for the corresponding {@link org.apache.activemq.artemis.api.core.TransportConfiguration}'s parameters.
|
||||
*/
|
||||
void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
@Parameter(name = "cfType", desc = "RegularCF=0, QueueCF=1, TopicCF=2, XACF=3, QueueXACF=4, TopicXACF=5") int cfType,
|
||||
String[] connectorNames,
|
||||
Object[] bindings) throws Exception;
|
||||
|
||||
/**
|
||||
* Create a JMS ConnectionFactory with the specified name connected to a single live-backup pair of servers.
|
||||
* <br>
|
||||
* The ConnectionFactory is bound to JNDI for all the specified bindings Strings.
|
||||
*/
|
||||
@Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
|
||||
void createConnectionFactory(@Parameter(name = "name") String name,
|
||||
@Parameter(name = "ha") boolean ha,
|
||||
@Parameter(name = "useDiscovery", desc = "should we use discovery or a connector configuration") boolean useDiscovery,
|
||||
@Parameter(name = "cfType", desc = "RegularCF=0, QueueCF=1, TopicCF=2, XACF=3, QueueXACF=4, TopicXACF=5") int cfType,
|
||||
@Parameter(name = "connectorNames", desc = "comma-separated list of connectorNames or the discovery group name") String connectors,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
|
||||
|
||||
@Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
|
||||
void createConnectionFactory(@Parameter(name = "name") String name,
|
||||
@Parameter(name = "ha") boolean ha,
|
||||
@Parameter(name = "useDiscovery", desc = "should we use discovery or a connector configuration") boolean useDiscovery,
|
||||
@Parameter(name = "cfType", desc = "RegularCF=0, QueueCF=1, TopicCF=2, XACF=3, QueueXACF=4, TopicXACF=5") int cfType,
|
||||
@Parameter(name = "connectorNames", desc = "An array of connector or the binding address") String[] connectors,
|
||||
@Parameter(name = "jndiBindings", desc = "array JNDI bindings (use ',' if u need to use commas in your jndi name)") String[] jndiBindings,
|
||||
@Parameter(name = "clientID", desc = "The clientID configured for the connectionFactory") String clientID,
|
||||
@Parameter(name = "clientFailureCheckPeriod", desc = "clientFailureCheckPeriod") long clientFailureCheckPeriod,
|
||||
@Parameter(name = "connectionTTL", desc = "connectionTTL") long connectionTTL,
|
||||
@Parameter(name = "callTimeout", desc = "callTimeout") long callTimeout,
|
||||
@Parameter(name = "callFailoverTimeout", desc = "callFailoverTimeout") long callFailoverTimeout,
|
||||
@Parameter(name = "minLargeMessageSize", desc = "minLargeMessageSize") int minLargeMessageSize,
|
||||
@Parameter(name = "compressLargeMessages", desc = "compressLargeMessages") boolean compressLargeMessages,
|
||||
@Parameter(name = "consumerWindowSize", desc = "consumerWindowSize") int consumerWindowSize,
|
||||
@Parameter(name = "consumerMaxRate", desc = "consumerMaxRate") int consumerMaxRate,
|
||||
@Parameter(name = "confirmationWindowSize", desc = "confirmationWindowSize") int confirmationWindowSize,
|
||||
@Parameter(name = "producerWindowSize", desc = "producerWindowSize") int producerWindowSize,
|
||||
@Parameter(name = "producerMaxRate", desc = "producerMaxRate") int producerMaxRate,
|
||||
@Parameter(name = "blockOnAcknowledge", desc = "blockOnAcknowledge") boolean blockOnAcknowledge,
|
||||
@Parameter(name = "blockOnDurableSend", desc = "blockOnDurableSend") boolean blockOnDurableSend,
|
||||
@Parameter(name = "blockOnNonDurableSend", desc = "blockOnNonDurableSend") boolean blockOnNonDurableSend,
|
||||
@Parameter(name = "autoGroup", desc = "autoGroup") boolean autoGroup,
|
||||
@Parameter(name = "preAcknowledge", desc = "preAcknowledge") boolean preAcknowledge,
|
||||
@Parameter(name = "loadBalancingPolicyClassName", desc = "loadBalancingPolicyClassName (null or blank mean use the default value)") String loadBalancingPolicyClassName,
|
||||
@Parameter(name = "transactionBatchSize", desc = "transactionBatchSize") int transactionBatchSize,
|
||||
@Parameter(name = "dupsOKBatchSize", desc = "dupsOKBatchSize") int dupsOKBatchSize,
|
||||
@Parameter(name = "useGlobalPools", desc = "useGlobalPools") boolean useGlobalPools,
|
||||
@Parameter(name = "scheduledThreadPoolMaxSize", desc = "scheduledThreadPoolMaxSize") int scheduledThreadPoolMaxSize,
|
||||
@Parameter(name = "threadPoolMaxSize", desc = "threadPoolMaxSize") int threadPoolMaxSize,
|
||||
@Parameter(name = "retryInterval", desc = "retryInterval") long retryInterval,
|
||||
@Parameter(name = "retryIntervalMultiplier", desc = "retryIntervalMultiplier") double retryIntervalMultiplier,
|
||||
@Parameter(name = "maxRetryInterval", desc = "maxRetryInterval") long maxRetryInterval,
|
||||
@Parameter(name = "reconnectAttempts", desc = "reconnectAttempts") int reconnectAttempts,
|
||||
@Parameter(name = "failoverOnInitialConnection", desc = "failoverOnInitialConnection") boolean failoverOnInitialConnection,
|
||||
@Parameter(name = "groupId", desc = "groupId") String groupId) throws Exception;
|
||||
|
||||
@Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
|
||||
void createConnectionFactory(@Parameter(name = "name") String name,
|
||||
@Parameter(name = "ha") boolean ha,
|
||||
@Parameter(name = "useDiscovery", desc = "should we use discovery or a connector configuration") boolean useDiscovery,
|
||||
@Parameter(name = "cfType", desc = "RegularCF=0, QueueCF=1, TopicCF=2, XACF=3, QueueXACF=4, TopicXACF=5") int cfType,
|
||||
@Parameter(name = "connectorNames", desc = "comma-separated list of connectorNames or the discovery group name") String connectors,
|
||||
@Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings,
|
||||
@Parameter(name = "clientID", desc = "The clientID configured for the connectionFactory") String clientID,
|
||||
@Parameter(name = "clientFailureCheckPeriod", desc = "clientFailureCheckPeriod") long clientFailureCheckPeriod,
|
||||
@Parameter(name = "connectionTTL", desc = "connectionTTL") long connectionTTL,
|
||||
@Parameter(name = "callTimeout", desc = "callTimeout") long callTimeout,
|
||||
@Parameter(name = "callFailoverTimeout", desc = "callFailoverTimeout") long callFailoverTimeout,
|
||||
@Parameter(name = "minLargeMessageSize", desc = "minLargeMessageSize") int minLargeMessageSize,
|
||||
@Parameter(name = "compressLargeMessages", desc = "compressLargeMessages") boolean compressLargeMessages,
|
||||
@Parameter(name = "consumerWindowSize", desc = "consumerWindowSize") int consumerWindowSize,
|
||||
@Parameter(name = "consumerMaxRate", desc = "consumerMaxRate") int consumerMaxRate,
|
||||
@Parameter(name = "confirmationWindowSize", desc = "confirmationWindowSize") int confirmationWindowSize,
|
||||
@Parameter(name = "producerWindowSize", desc = "producerWindowSize") int producerWindowSize,
|
||||
@Parameter(name = "producerMaxRate", desc = "producerMaxRate") int producerMaxRate,
|
||||
@Parameter(name = "blockOnAcknowledge", desc = "blockOnAcknowledge") boolean blockOnAcknowledge,
|
||||
@Parameter(name = "blockOnDurableSend", desc = "blockOnDurableSend") boolean blockOnDurableSend,
|
||||
@Parameter(name = "blockOnNonDurableSend", desc = "blockOnNonDurableSend") boolean blockOnNonDurableSend,
|
||||
@Parameter(name = "autoGroup", desc = "autoGroup") boolean autoGroup,
|
||||
@Parameter(name = "preAcknowledge", desc = "preAcknowledge") boolean preAcknowledge,
|
||||
@Parameter(name = "loadBalancingPolicyClassName", desc = "loadBalancingPolicyClassName (null or blank mean use the default value)") String loadBalancingPolicyClassName,
|
||||
@Parameter(name = "transactionBatchSize", desc = "transactionBatchSize") int transactionBatchSize,
|
||||
@Parameter(name = "dupsOKBatchSize", desc = "dupsOKBatchSize") int dupsOKBatchSize,
|
||||
@Parameter(name = "useGlobalPools", desc = "useGlobalPools") boolean useGlobalPools,
|
||||
@Parameter(name = "scheduledThreadPoolMaxSize", desc = "scheduledThreadPoolMaxSize") int scheduledThreadPoolMaxSize,
|
||||
@Parameter(name = "threadPoolMaxSize", desc = "threadPoolMaxSize") int threadPoolMaxSize,
|
||||
@Parameter(name = "retryInterval", desc = "retryInterval") long retryInterval,
|
||||
@Parameter(name = "retryIntervalMultiplier", desc = "retryIntervalMultiplier") double retryIntervalMultiplier,
|
||||
@Parameter(name = "maxRetryInterval", desc = "maxRetryInterval") long maxRetryInterval,
|
||||
@Parameter(name = "reconnectAttempts", desc = "reconnectAttempts") int reconnectAttempts,
|
||||
@Parameter(name = "failoverOnInitialConnection", desc = "failoverOnInitialConnection") boolean failoverOnInitialConnection,
|
||||
@Parameter(name = "groupId", desc = "groupId") String groupId) throws Exception;
|
||||
|
||||
@Operation(desc = "Destroy a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
|
||||
void destroyConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to destroy") String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the addresses of all the clients connected to this address.
|
||||
*/
|
||||
@Operation(desc = "List the client addresses", impact = MBeanOperationInfo.INFO)
|
||||
String[] listRemoteAddresses() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists the addresses of the clients connected to this address which matches the specified IP address.
|
||||
*/
|
||||
@Operation(desc = "List the client addresses which match the given IP Address", impact = MBeanOperationInfo.INFO)
|
||||
String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
|
||||
|
||||
/**
|
||||
* Closes all the connections of clients connected to this server which matches the specified IP address.
|
||||
*/
|
||||
@Operation(desc = "Closes all the connections for the given IP Address", impact = MBeanOperationInfo.INFO)
|
||||
boolean closeConnectionsForAddress(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
|
||||
|
||||
/**
|
||||
* Closes all the connections on this server for consumers which are consuming from a queue associated with a particular address.
|
||||
*/
|
||||
@Operation(desc = "Closes all the consumer connections for the given messaging address", impact = MBeanOperationInfo.INFO)
|
||||
boolean closeConsumerConnectionsForAddress(@Parameter(desc = "a messaging address", name = "address") String address) throws Exception;
|
||||
|
||||
/**
|
||||
* Closes all the connections on this server for sessions using a particular user name.
|
||||
*/
|
||||
@Operation(desc = "Closes all the connections for session using a particular user name", impact = MBeanOperationInfo.INFO)
|
||||
boolean closeConnectionsForUser(@Parameter(desc = "a user name", name = "userName") String address) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the IDs of the connections connected to this server.
|
||||
*/
|
||||
@Operation(desc = "List all the connection IDs", impact = MBeanOperationInfo.INFO)
|
||||
String[] listConnectionIDs() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the connections connected to this server.
|
||||
* The returned String is a JSON string containing an array of JMSConnectionInfo objects.
|
||||
*
|
||||
* @see JMSConnectionInfo#from(String)
|
||||
*/
|
||||
@Operation(desc = "List all JMS connections")
|
||||
String listConnectionsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the sessions IDs for the specified connection ID.
|
||||
*/
|
||||
@Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
|
||||
String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the consumers which belongs to the JMS Connection specified by the connectionID.
|
||||
* The returned String is a JSON string containing an array of JMSConsumerInfo objects.
|
||||
*
|
||||
* @see JMSConsumerInfo#from(String)
|
||||
*/
|
||||
@Operation(desc = "List all JMS consumers associated with a JMS Connection")
|
||||
String listConsumersAsJSON(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the consumers
|
||||
* The returned String is a JSON string containing an array of JMSConsumerInfo objects.
|
||||
*
|
||||
* @see JMSConsumerInfo#from(String)
|
||||
*/
|
||||
@Operation(desc = "List all JMS consumers associated with a JMS Connection")
|
||||
String listAllConsumersAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all addresses to which the designated server session has sent messages.
|
||||
*/
|
||||
@Operation(desc = "Lists all addresses to which the designated session has sent messages", impact = MBeanOperationInfo.INFO)
|
||||
String[] listTargetDestinations(@Parameter(desc = "a session ID", name = "sessionID") String sessionID) throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the last sent message's ID from the given session to an address.
|
||||
*/
|
||||
@Operation(desc = "Returns the last sent message's ID from the given session to an address", impact = MBeanOperationInfo.INFO)
|
||||
String getLastSentMessageID(@Parameter(desc = "session name", name = "sessionID") String sessionID,
|
||||
@Parameter(desc = "address", name = "address") String address) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the session's creation time.
|
||||
*/
|
||||
@Operation(desc = "Gets the sessions creation time", impact = MBeanOperationInfo.INFO)
|
||||
String getSessionCreationTime(@Parameter(desc = "session name", name = "sessionID") String sessionID) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the sessions IDs for the specified connection ID.
|
||||
*/
|
||||
@Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
|
||||
String listSessionsAsJSON(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
|
||||
|
||||
@Operation(desc = "List the Network Topology", impact = MBeanOperationInfo.INFO)
|
||||
String listNetworkTopology() throws Exception;
|
||||
|
||||
/**
|
||||
* List all the prepared transaction, sorted by date,
|
||||
* oldest first, with details, in text format
|
||||
*/
|
||||
@Operation(desc = "List all the prepared transaction, sorted by date, oldest first, with details, in JSON format", impact = MBeanOperationInfo.INFO)
|
||||
String listPreparedTransactionDetailsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* List all the prepared transaction, sorted by date,
|
||||
* oldest first, with details, in HTML format
|
||||
*/
|
||||
@Operation(desc = "List all the prepared transaction, sorted by date, oldest first, with details, in HTML format", impact = MBeanOperationInfo.INFO)
|
||||
String listPreparedTransactionDetailsAsHTML() throws Exception;
|
||||
|
||||
/**
|
||||
* List all the prepared transaction, sorted by date,
|
||||
* oldest first, with details, in HTML format
|
||||
*/
|
||||
@Operation(desc = "Will close any connection with the given connectionID", impact = MBeanOperationInfo.INFO)
|
||||
String closeConnectionWithClientID(@Parameter(desc = "the clientID used to connect", name = "clientID") String clientID) throws Exception;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
|
||||
public class JMSSessionInfo {
|
||||
|
||||
private final String sessionID;
|
||||
|
||||
private final long creationTime;
|
||||
|
||||
public JMSSessionInfo(String sessionID, long creationTime) {
|
||||
this.sessionID = sessionID;
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public static JMSSessionInfo[] from(final String jsonString) {
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
JMSSessionInfo[] infos = new JMSSessionInfo[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonObject obj = array.getJsonObject(i);
|
||||
|
||||
JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), obj.getJsonNumber("creationTime").longValue());
|
||||
infos[i] = info;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
public String getSessionID() {
|
||||
return sessionID;
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
|
||||
/**
|
||||
* Helper class to create Java Objects from the
|
||||
* JSON serialization returned by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods.
|
||||
*/
|
||||
public class SubscriptionInfo {
|
||||
|
||||
private final String queueName;
|
||||
|
||||
private final String clientID;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final boolean durable;
|
||||
|
||||
private final String selector;
|
||||
|
||||
private final int messageCount;
|
||||
|
||||
private final int deliveringCount;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an array of SubscriptionInfo corresponding to the JSON serialization returned
|
||||
* by {@link TopicControl#listAllSubscriptionsAsJSON()} and related methods.
|
||||
*/
|
||||
public static SubscriptionInfo[] from(final String jsonString) throws Exception {
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
SubscriptionInfo[] infos = new SubscriptionInfo[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonObject sub = array.getJsonObject(i);
|
||||
SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"), sub.getString("clientID", null), sub.getString("name", null), sub.getBoolean("durable"), sub.getString("selector", null), sub.getInt("messageCount"), sub.getInt("deliveringCount"));
|
||||
infos[i] = info;
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
private SubscriptionInfo(final String queueName,
|
||||
final String clientID,
|
||||
final String name,
|
||||
final boolean durable,
|
||||
final String selector,
|
||||
final int messageCount,
|
||||
final int deliveringCount) {
|
||||
this.queueName = queueName;
|
||||
this.clientID = clientID;
|
||||
this.name = name;
|
||||
this.durable = durable;
|
||||
this.selector = selector;
|
||||
this.messageCount = messageCount;
|
||||
this.deliveringCount = deliveringCount;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the name of the ActiveMQ Artemis core queue corresponding to this subscription.
|
||||
*/
|
||||
public String getQueueName() {
|
||||
return queueName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the client ID of this subscription or {@code null}.
|
||||
*/
|
||||
public String getClientID() {
|
||||
return clientID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this subscription.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this subscription is durable.
|
||||
*/
|
||||
public boolean isDurable() {
|
||||
return durable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JMS message selector associated to this subscription.
|
||||
*/
|
||||
public String getSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of messages currently held by this subscription.
|
||||
*/
|
||||
public int getMessageCount() {
|
||||
return messageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of messages currently delivered to this subscription.
|
||||
*/
|
||||
public int getDeliveringCount() {
|
||||
return deliveringCount;
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.api.jms.management;
|
||||
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.Attribute;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
|
||||
/**
|
||||
* A TopicControl is used to manage a JMS Topic.
|
||||
*/
|
||||
public interface TopicControl extends DestinationControl {
|
||||
|
||||
/**
|
||||
* Returns the number of (durable and non-durable) subscribers for this topic.
|
||||
*/
|
||||
@Attribute(desc = "number of (durable and non-durable) subscribers for this topic")
|
||||
int getSubscriptionCount();
|
||||
|
||||
/**
|
||||
* Returns the number of <em>durable</em> subscribers for this topic.
|
||||
*/
|
||||
@Attribute(desc = "number of durable subscribers for this topic")
|
||||
int getDurableSubscriptionCount();
|
||||
|
||||
/**
|
||||
* Returns the number of <em>non-durable</em> subscribers for this topic.
|
||||
*/
|
||||
@Attribute(desc = "number of non-durable subscribers for this topic")
|
||||
int getNonDurableSubscriptionCount();
|
||||
|
||||
/**
|
||||
* Returns the number of messages for all <em>durable</em> subscribers for this topic.
|
||||
*/
|
||||
@Attribute(desc = "number of messages for all durable subscribers for this topic")
|
||||
int getDurableMessageCount();
|
||||
|
||||
/**
|
||||
* Returns the number of messages for all <em>non-durable</em> subscribers for this topic.
|
||||
*/
|
||||
@Attribute(desc = "number of messages for all non-durable subscribers for this topic")
|
||||
int getNonDurableMessageCount();
|
||||
|
||||
/**
|
||||
* Returns the Registry bindings associated with this topic.
|
||||
*/
|
||||
@Attribute(desc = "the list of Registry bindings associated with this topic")
|
||||
String[] getRegistryBindings();
|
||||
|
||||
/**
|
||||
* Add the Registry binding to this destination
|
||||
*/
|
||||
@Operation(desc = "Adds the queue to another Registry binding")
|
||||
void addBinding(@Parameter(name = "binding", desc = "the name of the binding for Registry") String binding) throws Exception;
|
||||
|
||||
// Operations ----------------------------------------------------
|
||||
|
||||
/**
|
||||
* Lists all the subscriptions for this topic (both durable and non-durable).
|
||||
*/
|
||||
@Operation(desc = "List all subscriptions")
|
||||
Object[] listAllSubscriptions() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the subscriptions for this topic (both durable and non-durable) using JSON serialization.
|
||||
* <br>
|
||||
* Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
|
||||
*/
|
||||
@Operation(desc = "List all subscriptions")
|
||||
String listAllSubscriptionsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the <em>durable</em> subscriptions for this topic.
|
||||
*/
|
||||
@Operation(desc = "List only the durable subscriptions")
|
||||
Object[] listDurableSubscriptions() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the <em>durable</em> subscriptions using JSON serialization.
|
||||
* <br>
|
||||
* Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
|
||||
*/
|
||||
@Operation(desc = "List only the durable subscriptions")
|
||||
String listDurableSubscriptionsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the <em>non-durable</em> subscriptions for this topic.
|
||||
*/
|
||||
@Operation(desc = "List only the non durable subscriptions")
|
||||
Object[] listNonDurableSubscriptions() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the <em>non-durable</em> subscriptions using JSON serialization.
|
||||
* <br>
|
||||
* Java objects can be recreated from JSON serialization using {@link SubscriptionInfo#from(String)}.
|
||||
*/
|
||||
@Operation(desc = "List only the non durable subscriptions")
|
||||
String listNonDurableSubscriptionsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the messages in this queue matching the specified queue representing the subscription.
|
||||
* <br>
|
||||
* 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values.
|
||||
*/
|
||||
@Operation(desc = "List all the message for the given subscription")
|
||||
Map<String, Object>[] listMessagesForSubscription(@Parameter(name = "queueName", desc = "the name of the queue representing a subscription") String queueName) throws Exception;
|
||||
|
||||
/**
|
||||
* Lists all the messages in this queue matching the specified queue representing the subscription using JSON serialization.
|
||||
*/
|
||||
@Operation(desc = "List all the message for the given subscription")
|
||||
String listMessagesForSubscriptionAsJSON(@Parameter(name = "queueName", desc = "the name of the queue representing a subscription") String queueName) throws Exception;
|
||||
|
||||
/**
|
||||
* Counts the number of messages in the subscription specified by the specified client ID and subscription name. Only messages matching the filter will be counted.
|
||||
* <br>
|
||||
* Using {@code null} or an empty filter will count <em>all</em> messages from this queue.
|
||||
*/
|
||||
@Operation(desc = "Count the number of messages matching the filter for the given subscription")
|
||||
int countMessagesForSubscription(@Parameter(name = "clientID", desc = "the client ID") String clientID,
|
||||
@Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName,
|
||||
@Parameter(name = "filter", desc = "a JMS filter (can be empty)") String filter) throws Exception;
|
||||
|
||||
/**
|
||||
* Drops the subscription specified by the specified client ID and subscription name.
|
||||
*/
|
||||
@Operation(desc = "Drop a durable subscription", impact = MBeanOperationInfo.ACTION)
|
||||
void dropDurableSubscription(@Parameter(name = "clientID", desc = "the client ID") String clientID,
|
||||
@Parameter(name = "subscriptionName", desc = "the name of the durable subscription") String subscriptionName) throws Exception;
|
||||
|
||||
/**
|
||||
* Drops all subscriptions.
|
||||
*/
|
||||
@Operation(desc = "Drop all subscriptions from this topic", impact = MBeanOperationInfo.ACTION)
|
||||
void dropAllSubscriptions() throws Exception;
|
||||
}
|
|
@ -1,471 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl;
|
||||
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.management.StandardMBean;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl;
|
||||
import org.apache.activemq.artemis.core.management.impl.MBeanInfoHelper;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
|
||||
public class JMSConnectionFactoryControlImpl extends StandardMBean implements ConnectionFactoryControl {
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final ConnectionFactoryConfiguration cfConfig;
|
||||
|
||||
private ActiveMQConnectionFactory cf;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final JMSServerManager jmsManager;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public JMSConnectionFactoryControlImpl(final ConnectionFactoryConfiguration cfConfig,
|
||||
final ActiveMQConnectionFactory cf,
|
||||
final JMSServerManager jmsManager,
|
||||
final String name) throws NotCompliantMBeanException {
|
||||
super(ConnectionFactoryControl.class);
|
||||
this.cfConfig = cfConfig;
|
||||
this.cf = cf;
|
||||
this.name = name;
|
||||
this.jmsManager = jmsManager;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// ManagedConnectionFactoryMBean implementation ------------------
|
||||
|
||||
@Override
|
||||
public String[] getRegistryBindings() {
|
||||
return jmsManager.getBindingsOnConnectionFactory(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompressLargeMessages() {
|
||||
return cf.isCompressLargeMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompressLargeMessages(final boolean compress) {
|
||||
cfConfig.setCompressLargeMessages(compress);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHA() {
|
||||
return cfConfig.isHA();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFactoryType() {
|
||||
return cfConfig.getFactoryType().intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientID() {
|
||||
return cfConfig.getClientID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getClientFailureCheckPeriod() {
|
||||
return cfConfig.getClientFailureCheckPeriod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientID(String clientID) {
|
||||
cfConfig.setClientID(clientID);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDupsOKBatchSize(int dupsOKBatchSize) {
|
||||
cfConfig.setDupsOKBatchSize(dupsOKBatchSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransactionBatchSize(int transactionBatchSize) {
|
||||
cfConfig.setTransactionBatchSize(transactionBatchSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFailureCheckPeriod(long clientFailureCheckPeriod) {
|
||||
cfConfig.setClientFailureCheckPeriod(clientFailureCheckPeriod);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionTTL(long connectionTTL) {
|
||||
cfConfig.setConnectionTTL(connectionTTL);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCallTimeout(long callTimeout) {
|
||||
cfConfig.setCallTimeout(callTimeout);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCallFailoverTimeout(long callTimeout) {
|
||||
cfConfig.setCallFailoverTimeout(callTimeout);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsumerWindowSize(int consumerWindowSize) {
|
||||
cfConfig.setConsumerWindowSize(consumerWindowSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsumerMaxRate(int consumerMaxRate) {
|
||||
cfConfig.setConsumerMaxRate(consumerMaxRate);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfirmationWindowSize(int confirmationWindowSize) {
|
||||
cfConfig.setConfirmationWindowSize(confirmationWindowSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProducerMaxRate(int producerMaxRate) {
|
||||
cfConfig.setProducerMaxRate(producerMaxRate);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProducerWindowSize() {
|
||||
return cfConfig.getProducerWindowSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProducerWindowSize(int producerWindowSize) {
|
||||
cfConfig.setProducerWindowSize(producerWindowSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheLargeMessagesClient(boolean cacheLargeMessagesClient) {
|
||||
cfConfig.setCacheLargeMessagesClient(cacheLargeMessagesClient);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCacheLargeMessagesClient() {
|
||||
return cfConfig.isCacheLargeMessagesClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinLargeMessageSize(int minLargeMessageSize) {
|
||||
cfConfig.setMinLargeMessageSize(minLargeMessageSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockOnNonDurableSend(boolean blockOnNonDurableSend) {
|
||||
cfConfig.setBlockOnNonDurableSend(blockOnNonDurableSend);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockOnAcknowledge(boolean blockOnAcknowledge) {
|
||||
cfConfig.setBlockOnAcknowledge(blockOnAcknowledge);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockOnDurableSend(boolean blockOnDurableSend) {
|
||||
cfConfig.setBlockOnDurableSend(blockOnDurableSend);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoGroup(boolean autoGroup) {
|
||||
cfConfig.setAutoGroup(autoGroup);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPreAcknowledge(boolean preAcknowledge) {
|
||||
cfConfig.setPreAcknowledge(preAcknowledge);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxRetryInterval(long retryInterval) {
|
||||
cfConfig.setMaxRetryInterval(retryInterval);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRetryIntervalMultiplier(double retryIntervalMultiplier) {
|
||||
cfConfig.setRetryIntervalMultiplier(retryIntervalMultiplier);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReconnectAttempts(int reconnectAttempts) {
|
||||
cfConfig.setReconnectAttempts(reconnectAttempts);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFailoverOnInitialConnection(boolean failover) {
|
||||
cfConfig.setFailoverOnInitialConnection(failover);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseGlobalPools() {
|
||||
return cfConfig.isUseGlobalPools();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize) {
|
||||
cfConfig.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThreadPoolMaxSize() {
|
||||
return cfConfig.getThreadPoolMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThreadPoolMaxSize(int threadPoolMaxSize) {
|
||||
cfConfig.setThreadPoolMaxSize(threadPoolMaxSize);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialMessagePacketSize() {
|
||||
return cf.getInitialMessagePacketSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupID(String groupID) {
|
||||
cfConfig.setGroupID(groupID);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupID() {
|
||||
return cfConfig.getGroupID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseGlobalPools(boolean useGlobalPools) {
|
||||
cfConfig.setUseGlobalPools(useGlobalPools);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScheduledThreadPoolMaxSize() {
|
||||
return cfConfig.getScheduledThreadPoolMaxSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRetryInterval(long retryInterval) {
|
||||
cfConfig.setRetryInterval(retryInterval);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxRetryInterval() {
|
||||
return cfConfig.getMaxRetryInterval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConnectionLoadBalancingPolicyClassName() {
|
||||
return cfConfig.getLoadBalancingPolicyClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionLoadBalancingPolicyClassName(String name) {
|
||||
cfConfig.setLoadBalancingPolicyClassName(name);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportConfiguration[] getStaticConnectors() {
|
||||
return cf.getStaticConnectors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscoveryGroupConfiguration getDiscoveryGroupConfiguration() {
|
||||
return cf.getDiscoveryGroupConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception {
|
||||
jmsManager.addConnectionFactoryToBindingRegistry(name, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBinding(@Parameter(name = "binding", desc = "the name of the binding for the Registry") String binding) throws Exception {
|
||||
jmsManager.removeConnectionFactoryFromBindingRegistry(name, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCallTimeout() {
|
||||
return cfConfig.getCallTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCallFailoverTimeout() {
|
||||
return cfConfig.getCallFailoverTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConsumerMaxRate() {
|
||||
return cfConfig.getConsumerMaxRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConsumerWindowSize() {
|
||||
return cfConfig.getConsumerWindowSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProducerMaxRate() {
|
||||
return cfConfig.getProducerMaxRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConfirmationWindowSize() {
|
||||
return cfConfig.getConfirmationWindowSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDupsOKBatchSize() {
|
||||
return cfConfig.getDupsOKBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockOnAcknowledge() {
|
||||
return cfConfig.isBlockOnAcknowledge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockOnNonDurableSend() {
|
||||
return cfConfig.isBlockOnNonDurableSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockOnDurableSend() {
|
||||
return cfConfig.isBlockOnDurableSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreAcknowledge() {
|
||||
return cfConfig.isPreAcknowledge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConnectionTTL() {
|
||||
return cfConfig.getConnectionTTL();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReconnectAttempts() {
|
||||
return cfConfig.getReconnectAttempts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFailoverOnInitialConnection() {
|
||||
return cfConfig.isFailoverOnInitialConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinLargeMessageSize() {
|
||||
return cfConfig.getMinLargeMessageSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRetryInterval() {
|
||||
return cfConfig.getRetryInterval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRetryIntervalMultiplier() {
|
||||
return cfConfig.getRetryIntervalMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransactionBatchSize() {
|
||||
return cfConfig.getTransactionBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProtocolManagerFactoryStr(String protocolManagerFactoryStr) {
|
||||
cfConfig.setProtocolManagerFactoryStr(protocolManagerFactoryStr);
|
||||
recreateCF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocolManagerFactoryStr() {
|
||||
return cfConfig.getProtocolManagerFactoryStr();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoGroup() {
|
||||
return cfConfig.isAutoGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
MBeanInfo info = super.getMBeanInfo();
|
||||
return new MBeanInfo(info.getClassName(), info.getDescription(), info.getAttributes(), info.getConstructors(), MBeanInfoHelper.getMBeanOperationsInfo(ConnectionFactoryControl.class), info.getNotifications());
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
private void recreateCF() {
|
||||
try {
|
||||
this.cf = jmsManager.recreateCF(this.name, this.cfConfig);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
}
|
|
@ -1,532 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl;
|
||||
|
||||
import javax.jms.InvalidSelectorException;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.StandardMBean;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQInvalidFilterExpressionException;
|
||||
import org.apache.activemq.artemis.api.core.FilterConstants;
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
import org.apache.activemq.artemis.api.core.Message;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.MessageCounterInfo;
|
||||
import org.apache.activemq.artemis.api.core.management.Operation;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.core.management.impl.MBeanInfoHelper;
|
||||
import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
|
||||
import org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterHelper;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
|
||||
import org.apache.activemq.artemis.jms.management.impl.openmbean.JMSOpenTypeSupport;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.utils.Base64;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
import org.apache.activemq.artemis.utils.SelectorTranslator;
|
||||
import org.apache.activemq.artemis.utils.UUIDGenerator;
|
||||
|
||||
public class JMSQueueControlImpl extends StandardMBean implements JMSQueueControl {
|
||||
|
||||
private final ActiveMQDestination managedQueue;
|
||||
|
||||
private final JMSServerManager jmsServerManager;
|
||||
|
||||
private final QueueControl coreQueueControl;
|
||||
|
||||
private final MessageCounter counter;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns null if the string is null or empty
|
||||
*/
|
||||
public static String createFilterFromJMSSelector(final String selectorStr) throws ActiveMQException {
|
||||
return selectorStr == null || selectorStr.trim().length() == 0 ? null : SelectorTranslator.convertToActiveMQFilterString(selectorStr);
|
||||
}
|
||||
|
||||
private static String createFilterForJMSMessageID(final String jmsMessageID) throws Exception {
|
||||
return FilterConstants.ACTIVEMQ_USERID + " = '" + jmsMessageID + "'";
|
||||
}
|
||||
|
||||
static String toJSON(final Map<String, Object>[] messages) {
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
for (Map<String, Object> message : messages) {
|
||||
array.add(JsonUtil.toJsonObject(message));
|
||||
}
|
||||
return array.build().toString();
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public JMSQueueControlImpl(final ActiveMQDestination managedQueue,
|
||||
final QueueControl coreQueueControl,
|
||||
final JMSServerManager jmsServerManager,
|
||||
final MessageCounter counter) throws Exception {
|
||||
super(JMSQueueControl.class);
|
||||
this.managedQueue = managedQueue;
|
||||
this.jmsServerManager = jmsServerManager;
|
||||
this.coreQueueControl = coreQueueControl;
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// ManagedJMSQueueMBean implementation ---------------------------
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return managedQueue.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return managedQueue.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return managedQueue.isTemporary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
return coreQueueControl.getMessageCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesAdded() {
|
||||
return coreQueueControl.getMessagesAdded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesExpired() {
|
||||
return coreQueueControl.getMessagesExpired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesKilled() {
|
||||
return coreQueueControl.getMessagesKilled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConsumerCount() {
|
||||
return coreQueueControl.getConsumerCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeliveringCount() {
|
||||
return coreQueueControl.getDeliveringCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getScheduledCount() {
|
||||
return coreQueueControl.getScheduledCount();
|
||||
}
|
||||
|
||||
public boolean isDurable() {
|
||||
return coreQueueControl.isDurable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeadLetterAddress() {
|
||||
return coreQueueControl.getDeadLetterAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpiryAddress() {
|
||||
return coreQueueControl.getExpiryAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFirstMessageAsJSON() throws Exception {
|
||||
return coreQueueControl.getFirstMessageAsJSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFirstMessageTimestamp() throws Exception {
|
||||
return coreQueueControl.getFirstMessageTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFirstMessageAge() throws Exception {
|
||||
return coreQueueControl.getFirstMessageAge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(String binding) throws Exception {
|
||||
jmsServerManager.addQueueToBindingRegistry(managedQueue.getName(), binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegistryBindings() {
|
||||
return jmsServerManager.getBindingsOnQueue(managedQueue.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeMessage(final String messageID) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
|
||||
int removed = coreQueueControl.removeMessages(filter);
|
||||
if (removed != 1) {
|
||||
throw new IllegalArgumentException("No message found for JMSMessageID: " + messageID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeMessages(final String filterStr) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.removeMessages(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object>[] listMessages(final String filterStr) throws Exception {
|
||||
try {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
Map<String, Object>[] coreMessages = coreQueueControl.listMessages(filter);
|
||||
|
||||
return toJMSMap(coreMessages);
|
||||
} catch (ActiveMQException e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object>[] toJMSMap(Map<String, Object>[] coreMessages) {
|
||||
Map<String, Object>[] jmsMessages = new Map[coreMessages.length];
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (Map<String, Object> coreMessage : coreMessages) {
|
||||
Map<String, Object> jmsMessage = ActiveMQMessage.coreMaptoJMSMap(coreMessage);
|
||||
jmsMessages[i++] = jmsMessage;
|
||||
}
|
||||
return jmsMessages;
|
||||
}
|
||||
|
||||
private CompositeData toJMSCompositeType(CompositeDataSupport data) throws Exception {
|
||||
return JMSOpenTypeSupport.convert(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object>[] listScheduledMessages() throws Exception {
|
||||
Map<String, Object>[] coreMessages = coreQueueControl.listScheduledMessages();
|
||||
|
||||
return toJMSMap(coreMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listScheduledMessagesAsJSON() throws Exception {
|
||||
return coreQueueControl.listScheduledMessagesAsJSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, Object>[]> listDeliveringMessages() throws Exception {
|
||||
try {
|
||||
Map<String, Map<String, Object>[]> returnMap = new HashMap<>();
|
||||
|
||||
// the workingMap from the queue-control
|
||||
Map<String, Map<String, Object>[]> workingMap = coreQueueControl.listDeliveringMessages();
|
||||
|
||||
for (Map.Entry<String, Map<String, Object>[]> entry : workingMap.entrySet()) {
|
||||
returnMap.put(entry.getKey(), toJMSMap(entry.getValue()));
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
} catch (ActiveMQException e) {
|
||||
throw new IllegalStateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listDeliveringMessagesAsJSON() throws Exception {
|
||||
return coreQueueControl.listDeliveringMessagesAsJSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessagesAsJSON(final String filter) throws Exception {
|
||||
return JMSQueueControlImpl.toJSON(listMessages(filter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMessages(final String filterStr) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.countMessages(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean expireMessage(final String messageID) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
|
||||
int expired = coreQueueControl.expireMessages(filter);
|
||||
if (expired != 1) {
|
||||
throw new IllegalArgumentException("No message found for JMSMessageID: " + messageID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expireMessages(final String filterStr) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.expireMessages(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendMessageToDeadLetterAddress(final String messageID) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
|
||||
int dead = coreQueueControl.sendMessagesToDeadLetterAddress(filter);
|
||||
if (dead != 1) {
|
||||
throw new IllegalArgumentException("No message found for JMSMessageID: " + messageID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.sendMessagesToDeadLetterAddress(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessageWithProperties(String properties) throws Exception {
|
||||
String[] kvs = properties.split(",");
|
||||
Map<String, String> props = new HashMap<>();
|
||||
for (String kv : kvs) {
|
||||
String[] it = kv.split("=");
|
||||
if (it.length == 2) {
|
||||
props.put(it[0], it[1]);
|
||||
}
|
||||
}
|
||||
return sendTextMessage(props, props.remove("body"), props.remove("username"), props.remove("password"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(String body) throws Exception {
|
||||
return sendTextMessage(Collections.EMPTY_MAP, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(Map<String, String> headers, String body) throws Exception {
|
||||
return sendTextMessage(headers, body, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(String body, String user, String password) throws Exception {
|
||||
return sendTextMessage(Collections.EMPTY_MAP, body, user, password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(Map<String, String> headers,
|
||||
String body,
|
||||
String user,
|
||||
String password) throws Exception {
|
||||
boolean durable = false;
|
||||
if (headers.containsKey("JMSDeliveryMode")) {
|
||||
String jmsDeliveryMode = headers.remove("JMSDeliveryMode");
|
||||
if (jmsDeliveryMode != null && (jmsDeliveryMode.equals("2") || jmsDeliveryMode.equalsIgnoreCase("PERSISTENT"))) {
|
||||
durable = true;
|
||||
}
|
||||
}
|
||||
String userID = UUIDGenerator.getInstance().generateStringUUID();
|
||||
ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(56);
|
||||
buffer.writeNullableSimpleString(new SimpleString(body));
|
||||
byte[] bytes = new byte[buffer.readableBytes()];
|
||||
buffer.readBytes(bytes);
|
||||
coreQueueControl.sendMessage(headers, Message.TEXT_TYPE, Base64.encodeBytes(bytes), userID, durable, user, password);
|
||||
return userID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeMessagePriority(final String messageID, final int newPriority) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
|
||||
int changed = coreQueueControl.changeMessagesPriority(filter, newPriority);
|
||||
if (changed != 1) {
|
||||
throw new IllegalArgumentException("No message found for JMSMessageID: " + messageID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.changeMessagesPriority(filter, newPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retryMessage(final String jmsMessageID) throws Exception {
|
||||
|
||||
// Figure out messageID from JMSMessageID.
|
||||
final String filter = createFilterForJMSMessageID(jmsMessageID);
|
||||
Map<String, Object>[] messages = coreQueueControl.listMessages(filter);
|
||||
if (messages.length != 1) { // if no messages. There should not be more than one, JMSMessageID should be unique.
|
||||
return false;
|
||||
}
|
||||
|
||||
final Map<String, Object> messageToRedeliver = messages[0];
|
||||
Long messageID = (Long) messageToRedeliver.get("messageID");
|
||||
return messageID != null && coreQueueControl.retryMessage(messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int retryMessages() throws Exception {
|
||||
return coreQueueControl.retryMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveMessage(final String messageID, final String otherQueueName) throws Exception {
|
||||
return moveMessage(messageID, otherQueueName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveMessage(final String messageID,
|
||||
final String otherQueueName,
|
||||
final boolean rejectDuplicates) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
|
||||
ActiveMQDestination otherQueue = ActiveMQDestination.createQueue(otherQueueName);
|
||||
int moved = coreQueueControl.moveMessages(filter, otherQueue.getAddress(), rejectDuplicates);
|
||||
if (moved != 1) {
|
||||
throw new IllegalArgumentException("No message found for JMSMessageID: " + messageID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int moveMessages(final String filterStr,
|
||||
final String otherQueueName,
|
||||
final boolean rejectDuplicates) throws Exception {
|
||||
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
ActiveMQDestination otherQueue = ActiveMQDestination.createQueue(otherQueueName);
|
||||
return coreQueueControl.moveMessages(filter, otherQueue.getAddress(), rejectDuplicates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int moveMessages(final String filterStr, final String otherQueueName) throws Exception {
|
||||
return moveMessages(filterStr, otherQueueName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Operation(desc = "List all the existent consumers on the Queue")
|
||||
public String listConsumersAsJSON() throws Exception {
|
||||
return coreQueueControl.listConsumersAsJSON();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounter() {
|
||||
try {
|
||||
return MessageCounterInfo.toJSon(counter);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMessageCounter() throws Exception {
|
||||
coreQueueControl.resetMessageCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterAsHTML() {
|
||||
return MessageCounterHelper.listMessageCounterAsHTML(new MessageCounter[]{counter});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterHistory() throws Exception {
|
||||
return MessageCounterHelper.listMessageCounterHistory(counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterHistoryAsHTML() {
|
||||
return MessageCounterHelper.listMessageCounterHistoryAsHTML(new MessageCounter[]{counter});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() throws Exception {
|
||||
return coreQueueControl.isPaused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() throws Exception {
|
||||
coreQueueControl.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(boolean persist) throws Exception {
|
||||
coreQueueControl.pause(persist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() throws Exception {
|
||||
coreQueueControl.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse() throws Exception {
|
||||
return browse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse(String filter) throws Exception {
|
||||
try {
|
||||
CompositeData[] messages = coreQueueControl.browse(filter);
|
||||
|
||||
ArrayList<CompositeData> c = new ArrayList<>();
|
||||
|
||||
for (CompositeData message : messages) {
|
||||
c.add(toJMSCompositeType((CompositeDataSupport) message));
|
||||
}
|
||||
CompositeData[] rc = new CompositeData[c.size()];
|
||||
c.toArray(rc);
|
||||
return rc;
|
||||
} catch (ActiveMQInvalidFilterExpressionException e) {
|
||||
throw new InvalidSelectorException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelector() {
|
||||
return coreQueueControl.getFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushExecutor() {
|
||||
coreQueueControl.flushExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
MBeanInfo info = super.getMBeanInfo();
|
||||
return new MBeanInfo(info.getClassName(), info.getDescription(), MBeanInfoHelper.getMBeanAttributesInfo(JMSQueueControl.class), info.getConstructors(), MBeanInfoHelper.getMBeanOperationsInfo(JMSQueueControl.class), info.getNotifications());
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
}
|
|
@ -1,876 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
import javax.management.ListenerNotFoundException;
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import javax.management.Notification;
|
||||
import javax.management.NotificationBroadcasterSupport;
|
||||
import javax.management.NotificationEmitter;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.NotificationListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
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;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.DestinationControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.core.client.impl.Topology;
|
||||
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
|
||||
import org.apache.activemq.artemis.core.filter.Filter;
|
||||
import org.apache.activemq.artemis.core.management.impl.AbstractControl;
|
||||
import org.apache.activemq.artemis.core.management.impl.MBeanInfoHelper;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.ServerConsumer;
|
||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.jms.server.ActiveMQJMSServerLogger;
|
||||
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.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
import org.apache.activemq.artemis.utils.TypedProperties;
|
||||
|
||||
public class JMSServerControlImpl extends AbstractControl implements JMSServerControl, NotificationEmitter, org.apache.activemq.artemis.core.server.management.NotificationListener {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final JMSServerManager server;
|
||||
|
||||
private final NotificationBroadcasterSupport broadcaster;
|
||||
|
||||
private final AtomicLong notifSeq = new AtomicLong(0);
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
private static String[] convert(final Object[] bindings) {
|
||||
String[] theBindings = new String[bindings.length];
|
||||
for (int i = 0, bindingsLength = bindings.length; i < bindingsLength; i++) {
|
||||
theBindings[i] = bindings[i].toString().trim();
|
||||
}
|
||||
return theBindings;
|
||||
}
|
||||
|
||||
private static String[] toArray(final String commaSeparatedString) {
|
||||
if (commaSeparatedString == null || commaSeparatedString.trim().length() == 0) {
|
||||
return new String[0];
|
||||
}
|
||||
String[] values = commaSeparatedString.split(",");
|
||||
String[] trimmed = new String[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
trimmed[i] = values[i].trim();
|
||||
trimmed[i] = trimmed[i].replace(",", ",");
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
public static MBeanNotificationInfo[] getNotificationInfos() {
|
||||
JMSNotificationType[] values = JMSNotificationType.values();
|
||||
String[] names = new String[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
names[i] = values[i].toString();
|
||||
}
|
||||
return new MBeanNotificationInfo[]{new MBeanNotificationInfo(names, JMSServerControl.class.getName(), "Notifications emitted by a JMS Server")};
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public JMSServerControlImpl(final JMSServerManager server) throws Exception {
|
||||
super(JMSServerControl.class, server.getActiveMQServer().getStorageManager());
|
||||
this.server = server;
|
||||
broadcaster = new NotificationBroadcasterSupport();
|
||||
server.getActiveMQServer().getManagementService().addNotificationListener(this);
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// JMSServerControlMBean implementation --------------------------
|
||||
|
||||
/**
|
||||
* See the interface definition for the javadoc.
|
||||
*/
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String[] connectorNames,
|
||||
Object[] bindings) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
if (useDiscovery) {
|
||||
if (connectorNames == null || connectorNames.length == 0) {
|
||||
throw new IllegalArgumentException("no discovery group name supplied");
|
||||
}
|
||||
server.createConnectionFactory(name, ha, JMSFactoryType.valueOf(cfType), connectorNames[0], JMSServerControlImpl.convert(bindings));
|
||||
} else {
|
||||
List<String> connectorList = new ArrayList<>(connectorNames.length);
|
||||
|
||||
for (String str : connectorNames) {
|
||||
connectorList.add(str);
|
||||
}
|
||||
|
||||
server.createConnectionFactory(name, ha, JMSFactoryType.valueOf(cfType), connectorList, JMSServerControlImpl.convert(bindings));
|
||||
}
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String connectors,
|
||||
String bindings,
|
||||
String clientID,
|
||||
long clientFailureCheckPeriod,
|
||||
long connectionTTL,
|
||||
long callTimeout,
|
||||
long callFailoverTimeout,
|
||||
int minLargeMessageSize,
|
||||
boolean compressLargeMessages,
|
||||
int consumerWindowSize,
|
||||
int consumerMaxRate,
|
||||
int confirmationWindowSize,
|
||||
int producerWindowSize,
|
||||
int producerMaxRate,
|
||||
boolean blockOnAcknowledge,
|
||||
boolean blockOnDurableSend,
|
||||
boolean blockOnNonDurableSend,
|
||||
boolean autoGroup,
|
||||
boolean preAcknowledge,
|
||||
String loadBalancingPolicyClassName,
|
||||
int transactionBatchSize,
|
||||
int dupsOKBatchSize,
|
||||
boolean useGlobalPools,
|
||||
int scheduledThreadPoolMaxSize,
|
||||
int threadPoolMaxSize,
|
||||
long retryInterval,
|
||||
double retryIntervalMultiplier,
|
||||
long maxRetryInterval,
|
||||
int reconnectAttempts,
|
||||
boolean failoverOnInitialConnection,
|
||||
String groupId) throws Exception {
|
||||
createConnectionFactory(name, ha, useDiscovery, cfType, toArray(connectors), toArray(bindings), clientID, clientFailureCheckPeriod, connectionTTL, callTimeout, callFailoverTimeout, minLargeMessageSize, compressLargeMessages, consumerWindowSize, consumerMaxRate, confirmationWindowSize, producerWindowSize, producerMaxRate, blockOnAcknowledge, blockOnDurableSend, blockOnNonDurableSend, autoGroup, preAcknowledge, loadBalancingPolicyClassName, transactionBatchSize, dupsOKBatchSize, useGlobalPools, scheduledThreadPoolMaxSize, threadPoolMaxSize, retryInterval, retryIntervalMultiplier, maxRetryInterval, reconnectAttempts, failoverOnInitialConnection, groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String[] connectorNames,
|
||||
String[] bindings,
|
||||
String clientID,
|
||||
long clientFailureCheckPeriod,
|
||||
long connectionTTL,
|
||||
long callTimeout,
|
||||
long callFailoverTimeout,
|
||||
int minLargeMessageSize,
|
||||
boolean compressLargeMessages,
|
||||
int consumerWindowSize,
|
||||
int consumerMaxRate,
|
||||
int confirmationWindowSize,
|
||||
int producerWindowSize,
|
||||
int producerMaxRate,
|
||||
boolean blockOnAcknowledge,
|
||||
boolean blockOnDurableSend,
|
||||
boolean blockOnNonDurableSend,
|
||||
boolean autoGroup,
|
||||
boolean preAcknowledge,
|
||||
String loadBalancingPolicyClassName,
|
||||
int transactionBatchSize,
|
||||
int dupsOKBatchSize,
|
||||
boolean useGlobalPools,
|
||||
int scheduledThreadPoolMaxSize,
|
||||
int threadPoolMaxSize,
|
||||
long retryInterval,
|
||||
double retryIntervalMultiplier,
|
||||
long maxRetryInterval,
|
||||
int reconnectAttempts,
|
||||
boolean failoverOnInitialConnection,
|
||||
String groupId) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl().setName(name).setHA(ha).setBindings(bindings).setFactoryType(JMSFactoryType.valueOf(cfType)).setClientID(clientID).setClientFailureCheckPeriod(clientFailureCheckPeriod).setConnectionTTL(connectionTTL).setCallTimeout(callTimeout).setCallFailoverTimeout(callFailoverTimeout).setMinLargeMessageSize(minLargeMessageSize).setCompressLargeMessages(compressLargeMessages).setConsumerWindowSize(consumerWindowSize).setConsumerMaxRate(consumerMaxRate).setConfirmationWindowSize(confirmationWindowSize).setProducerWindowSize(producerWindowSize).setProducerMaxRate(producerMaxRate).setBlockOnAcknowledge(blockOnAcknowledge).setBlockOnDurableSend(blockOnDurableSend).setBlockOnNonDurableSend(blockOnNonDurableSend).setAutoGroup(autoGroup).setPreAcknowledge(preAcknowledge).setTransactionBatchSize(transactionBatchSize).setDupsOKBatchSize(dupsOKBatchSize).setUseGlobalPools(useGlobalPools).setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize).setThreadPoolMaxSize(threadPoolMaxSize).setRetryInterval(retryInterval).setRetryIntervalMultiplier(retryIntervalMultiplier).setMaxRetryInterval(maxRetryInterval).setReconnectAttempts(reconnectAttempts).setFailoverOnInitialConnection(failoverOnInitialConnection).setGroupID(groupId);
|
||||
|
||||
if (useDiscovery) {
|
||||
configuration.setDiscoveryGroupName(connectorNames[0]);
|
||||
} else {
|
||||
ArrayList<String> connectorNamesList = new ArrayList<>();
|
||||
for (String nameC : connectorNames) {
|
||||
connectorNamesList.add(nameC);
|
||||
}
|
||||
configuration.setConnectorNames(connectorNamesList);
|
||||
}
|
||||
|
||||
if (loadBalancingPolicyClassName != null && !loadBalancingPolicyClassName.trim().equals("")) {
|
||||
configuration.setLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
|
||||
}
|
||||
|
||||
server.createConnectionFactory(true, configuration, bindings);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JMS ConnectionFactory with the specified name connected to a single live-backup pair of servers.
|
||||
* <br>
|
||||
* The ConnectionFactory is bound to the Registry for all the specified bindings Strings.
|
||||
*/
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String connectors,
|
||||
String bindings) throws Exception {
|
||||
createConnectionFactory(name, ha, useDiscovery, cfType, toArray(connectors), toArray(bindings));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(final String name) throws Exception {
|
||||
return createQueue(name, null, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(final String name, final String bindings) throws Exception {
|
||||
return createQueue(name, bindings, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(String name, String bindings, String selector) throws Exception {
|
||||
return createQueue(name, bindings, selector, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
|
||||
@Parameter(name = "bindings", desc = "comma-separated list of Registry bindings (use ',' if u need to use commas in your bindings name)") String bindings,
|
||||
@Parameter(name = "selector", desc = "the jms selector") String selector,
|
||||
@Parameter(name = "durable", desc = "is the queue persistent and resilient to restart") boolean durable) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.createQueue(true, name, selector, durable, JMSServerControlImpl.toArray(bindings));
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyQueue(final String name) throws Exception {
|
||||
return destroyQueue(name, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyQueue(final String name, final boolean removeConsumers) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.destroyQueue(name, removeConsumers);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createTopic(String name) throws Exception {
|
||||
return createTopic(name, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createTopic(final String topicName, final String bindings) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.createTopic(true, topicName, JMSServerControlImpl.toArray(bindings));
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyTopic(final String name) throws Exception {
|
||||
return destroyTopic(name, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyTopic(final String name, final boolean removeConsumers) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.destroyTopic(name, removeConsumers);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyConnectionFactory(final String name) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
server.destroyConnectionFactory(name);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return server.isStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
checkStarted();
|
||||
|
||||
return server.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
Object[] queueControls = server.getActiveMQServer().getManagementService().getResources(JMSQueueControl.class);
|
||||
String[] names = new String[queueControls.length];
|
||||
for (int i = 0; i < queueControls.length; i++) {
|
||||
JMSQueueControl queueControl = (JMSQueueControl) queueControls[i];
|
||||
names[i] = queueControl.getName();
|
||||
}
|
||||
return names;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTopicNames() {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
Object[] topicControls = server.getActiveMQServer().getManagementService().getResources(TopicControl.class);
|
||||
String[] names = new String[topicControls.length];
|
||||
for (int i = 0; i < topicControls.length; i++) {
|
||||
TopicControl topicControl = (TopicControl) topicControls[i];
|
||||
names[i] = topicControl.getName();
|
||||
}
|
||||
return names;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getConnectionFactoryNames() {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
Object[] cfControls = server.getActiveMQServer().getManagementService().getResources(ConnectionFactoryControl.class);
|
||||
String[] names = new String[cfControls.length];
|
||||
for (int i = 0; i < cfControls.length; i++) {
|
||||
ConnectionFactoryControl cfControl = (ConnectionFactoryControl) cfControls[i];
|
||||
names[i] = cfControl.getName();
|
||||
}
|
||||
return names;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeID() {
|
||||
return server.getActiveMQServer().getNodeID().toString();
|
||||
}
|
||||
|
||||
// NotificationEmitter implementation ----------------------------
|
||||
|
||||
@Override
|
||||
public void removeNotificationListener(final NotificationListener listener,
|
||||
final NotificationFilter filter,
|
||||
final Object handback) throws ListenerNotFoundException {
|
||||
broadcaster.removeNotificationListener(listener, filter, handback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException {
|
||||
broadcaster.removeNotificationListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotificationListener(final NotificationListener listener,
|
||||
final NotificationFilter filter,
|
||||
final Object handback) throws IllegalArgumentException {
|
||||
broadcaster.addNotificationListener(listener, filter, handback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
return JMSServerControlImpl.getNotificationInfos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listRemoteAddresses() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listRemoteAddresses();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listRemoteAddresses(final String ipAddress) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listRemoteAddresses(ipAddress);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConnectionsForAddress(final String ipAddress) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.closeConnectionsForAddress(ipAddress);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConsumerConnectionsForAddress(final String address) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.closeConsumerConnectionsForAddress(address);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConnectionsForUser(final String userName) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.closeConnectionsForUser(userName);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listConnectionIDs() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listConnectionIDs();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listConnectionsAsJSON() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
|
||||
Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
|
||||
|
||||
Set<ServerSession> sessions = server.getActiveMQServer().getSessions();
|
||||
|
||||
Map<Object, ServerSession> jmsSessions = new HashMap<>();
|
||||
|
||||
// First separate the real jms sessions, after all we are only interested in those here on the *jms* server controller
|
||||
for (ServerSession session : sessions) {
|
||||
if (session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
|
||||
jmsSessions.put(session.getConnectionID(), session);
|
||||
}
|
||||
}
|
||||
|
||||
for (RemotingConnection connection : connections) {
|
||||
ServerSession session = jmsSessions.get(connection.getID());
|
||||
if (session != null) {
|
||||
JsonObjectBuilder objectBuilder = JsonLoader.createObjectBuilder().add("connectionID", connection.getID().toString()).add("clientAddress", connection.getRemoteAddress()).add("creationTime", connection.getCreationTime());
|
||||
|
||||
if (session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null) {
|
||||
objectBuilder.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY));
|
||||
}
|
||||
|
||||
if (session.getUsername() != null) {
|
||||
objectBuilder.add("principal", session.getUsername());
|
||||
}
|
||||
|
||||
array.add(objectBuilder.build());
|
||||
}
|
||||
}
|
||||
return array.build().toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listConsumersAsJSON(String connectionID) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
|
||||
Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
|
||||
for (RemotingConnection connection : connections) {
|
||||
if (connectionID.equals(connection.getID().toString())) {
|
||||
List<ServerSession> sessions = server.getActiveMQServer().getSessions(connectionID);
|
||||
for (ServerSession session : sessions) {
|
||||
Set<ServerConsumer> consumers = session.getServerConsumers();
|
||||
for (ServerConsumer consumer : consumers) {
|
||||
JsonObject obj = toJSONObject(consumer);
|
||||
if (obj != null) {
|
||||
array.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array.build().toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listAllConsumersAsJSON() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
JsonArray jsonArray = toJsonArray(server.getActiveMQServer().getSessions());
|
||||
return jsonArray.toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listSessions(final String connectionID) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listSessions(connectionID);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listPreparedTransactionDetailsAsJSON() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listPreparedTransactionDetailsAsJSON();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listPreparedTransactionDetailsAsHTML() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listPreparedTransactionDetailsAsHTML();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.activemq.artemis.core.management.impl.AbstractControl#fillMBeanOperationInfo()
|
||||
*/
|
||||
@Override
|
||||
protected MBeanOperationInfo[] fillMBeanOperationInfo() {
|
||||
return MBeanInfoHelper.getMBeanOperationsInfo(JMSServerControl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MBeanAttributeInfo[] fillMBeanAttributeInfo() {
|
||||
return MBeanInfoHelper.getMBeanAttributesInfo(JMSServerControl.class);
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
private void checkStarted() {
|
||||
if (!server.isStarted()) {
|
||||
throw new IllegalStateException("ActiveMQ Artemis JMS Server is not started. It can not be managed yet");
|
||||
}
|
||||
}
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
@Override
|
||||
public String[] listTargetDestinations(String sessionID) throws Exception {
|
||||
String[] addresses = server.getActiveMQServer().getActiveMQServerControl().listTargetAddresses(sessionID);
|
||||
Map<String, DestinationControl> allDests = new HashMap<>();
|
||||
|
||||
Object[] queueControls = server.getActiveMQServer().getManagementService().getResources(JMSQueueControl.class);
|
||||
for (Object queueControl2 : queueControls) {
|
||||
JMSQueueControl queueControl = (JMSQueueControl) queueControl2;
|
||||
allDests.put(queueControl.getAddress(), queueControl);
|
||||
}
|
||||
|
||||
Object[] topicControls = server.getActiveMQServer().getManagementService().getResources(TopicControl.class);
|
||||
for (Object topicControl2 : topicControls) {
|
||||
TopicControl topicControl = (TopicControl) topicControl2;
|
||||
allDests.put(topicControl.getAddress(), topicControl);
|
||||
}
|
||||
|
||||
List<String> destinations = new ArrayList<>();
|
||||
for (String addresse : addresses) {
|
||||
DestinationControl control = allDests.get(addresse);
|
||||
if (control != null) {
|
||||
destinations.add(control.getAddress());
|
||||
}
|
||||
}
|
||||
return destinations.toArray(new String[destinations.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastSentMessageID(String sessionID, String address) throws Exception {
|
||||
ServerSession session = server.getActiveMQServer().getSessionByID(sessionID);
|
||||
if (session != null) {
|
||||
return session.getLastSentMessageID(address);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionCreationTime(String sessionID) throws Exception {
|
||||
ServerSession session = server.getActiveMQServer().getSessionByID(sessionID);
|
||||
if (session != null) {
|
||||
return String.valueOf(session.getCreationTime());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listSessionsAsJSON(final String connectionID) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
||||
try {
|
||||
return server.listSessionsAsJSON(connectionID);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listNetworkTopology() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder brokers = JsonLoader.createArrayBuilder();
|
||||
ClusterManager clusterManager = server.getActiveMQServer().getClusterManager();
|
||||
if (clusterManager != null) {
|
||||
Set<ClusterConnection> clusterConnections = clusterManager.getClusterConnections();
|
||||
for (ClusterConnection clusterConnection : clusterConnections) {
|
||||
Topology topology = clusterConnection.getTopology();
|
||||
Collection<TopologyMemberImpl> members = topology.getMembers();
|
||||
for (TopologyMemberImpl member : members) {
|
||||
|
||||
JsonObjectBuilder obj = JsonLoader.createObjectBuilder();
|
||||
TransportConfiguration live = member.getLive();
|
||||
if (live != null) {
|
||||
obj.add("nodeID", member.getNodeId()).add("live", live.getParams().get("host") + ":" + live.getParams().get("port"));
|
||||
TransportConfiguration backup = member.getBackup();
|
||||
if (backup != null) {
|
||||
obj.add("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port"));
|
||||
}
|
||||
}
|
||||
brokers.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return brokers.build().toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeConnectionWithClientID(final String clientID) throws Exception {
|
||||
return server.getActiveMQServer().destroyConnectionWithSessionMetadata(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
|
||||
}
|
||||
|
||||
private String determineJMSDestinationType(Queue queue) {
|
||||
String result;
|
||||
if (server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(queue.getAddress().toString())).getRoutingType() == AddressInfo.RoutingType.ANYCAST) {
|
||||
if (queue.isTemporary()) {
|
||||
result = "tempqueue";
|
||||
} else {
|
||||
result = "queue";
|
||||
}
|
||||
} else if (server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(queue.getAddress().toString())).getRoutingType() == AddressInfo.RoutingType.MULTICAST) {
|
||||
if (queue.isTemporary()) {
|
||||
result = "temptopic";
|
||||
} else {
|
||||
result = "topic";
|
||||
}
|
||||
} else {
|
||||
ActiveMQJMSServerLogger.LOGGER.debug("JMSServerControlImpl.determineJMSDestinationType() " + queue);
|
||||
// not related to JMS
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private JsonObject toJSONObject(ServerConsumer consumer) {
|
||||
AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(consumer.getQueue().getAddress().toString()));
|
||||
if (addressInfo == null) {
|
||||
return null;
|
||||
}
|
||||
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("consumerID", consumer.getID()).add("connectionID", consumer.getConnectionID().toString()).add("sessionID", consumer.getSessionID()).add("queueName", consumer.getQueue().getName().toString()).add("browseOnly", consumer.isBrowseOnly()).add("creationTime", consumer.getCreationTime()).add("destinationName", consumer.getQueue().getAddress().toString()).add("destinationType", determineJMSDestinationType(consumer.getQueue()));
|
||||
// JMS consumer with message filter use the queue's filter
|
||||
Filter queueFilter = consumer.getQueue().getFilter();
|
||||
if (queueFilter != null) {
|
||||
obj.add("filter", queueFilter.getFilterString().toString());
|
||||
}
|
||||
|
||||
if (addressInfo.getRoutingType().equals(AddressInfo.RoutingType.MULTICAST)) {
|
||||
if (consumer.getQueue().isTemporary()) {
|
||||
obj.add("durable", false);
|
||||
} else {
|
||||
obj.add("durable", true);
|
||||
}
|
||||
} else {
|
||||
obj.add("durable", false);
|
||||
}
|
||||
|
||||
return obj.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotification(org.apache.activemq.artemis.core.server.management.Notification notification) {
|
||||
if (!(notification.getType() instanceof JMSNotificationType))
|
||||
return;
|
||||
JMSNotificationType type = (JMSNotificationType) notification.getType();
|
||||
TypedProperties prop = notification.getProperties();
|
||||
|
||||
this.broadcaster.sendNotification(new Notification(type.toString(), this, notifSeq.incrementAndGet(), prop.getSimpleStringProperty(JMSNotificationType.MESSAGE).toString()));
|
||||
}
|
||||
|
||||
private JsonArray toJsonArray(Collection<ServerSession> sessions) {
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
|
||||
for (ServerSession session : sessions) {
|
||||
Set<ServerConsumer> consumers = session.getServerConsumers();
|
||||
for (ServerConsumer consumer : consumers) {
|
||||
JsonObject obj = toJSONObject(consumer);
|
||||
if (obj != null) {
|
||||
array.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,370 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl;
|
||||
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonObject;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.StandardMBean;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.Pair;
|
||||
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.core.management.impl.MBeanInfoHelper;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
import org.apache.activemq.artemis.utils.SelectorTranslator;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
|
||||
|
||||
public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
|
||||
|
||||
private final ActiveMQDestination managedTopic;
|
||||
|
||||
private final AddressControl addressControl;
|
||||
|
||||
private final ManagementService managementService;
|
||||
|
||||
private final JMSServerManager jmsServerManager;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JMSTopicControlImpl.class);
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
public static String createFilterFromJMSSelector(final String selectorStr) throws ActiveMQException {
|
||||
return selectorStr == null || selectorStr.trim().length() == 0 ? null : SelectorTranslator.convertToActiveMQFilterString(selectorStr);
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public JMSTopicControlImpl(final ActiveMQDestination topic,
|
||||
final JMSServerManager jmsServerManager,
|
||||
final AddressControl addressControl,
|
||||
final ManagementService managementService) throws Exception {
|
||||
super(TopicControl.class);
|
||||
this.jmsServerManager = jmsServerManager;
|
||||
managedTopic = topic;
|
||||
this.addressControl = addressControl;
|
||||
this.managementService = managementService;
|
||||
}
|
||||
|
||||
// TopicControlMBean implementation ------------------------------
|
||||
|
||||
@Override
|
||||
public void addBinding(String binding) throws Exception {
|
||||
jmsServerManager.addTopicToBindingRegistry(managedTopic.getName(), binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegistryBindings() {
|
||||
return jmsServerManager.getBindingsOnTopic(managedTopic.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return managedTopic.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return managedTopic.isTemporary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return managedTopic.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
return getMessageCount(DurabilityType.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeliveringCount() {
|
||||
List<QueueControl> queues = getQueues(DurabilityType.ALL);
|
||||
int count = 0;
|
||||
for (QueueControl queue : queues) {
|
||||
count += queue.getDeliveringCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesAdded() {
|
||||
List<QueueControl> queues = getQueues(DurabilityType.ALL);
|
||||
int count = 0;
|
||||
for (QueueControl queue : queues) {
|
||||
count += queue.getMessagesAdded();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurableMessageCount() {
|
||||
return getMessageCount(DurabilityType.DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNonDurableMessageCount() {
|
||||
return getMessageCount(DurabilityType.NON_DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubscriptionCount() {
|
||||
return getQueues(DurabilityType.ALL).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurableSubscriptionCount() {
|
||||
return getQueues(DurabilityType.DURABLE).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNonDurableSubscriptionCount() {
|
||||
return getQueues(DurabilityType.NON_DURABLE).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] listAllSubscriptions() {
|
||||
return listSubscribersInfos(DurabilityType.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listAllSubscriptionsAsJSON() throws Exception {
|
||||
return listSubscribersInfosAsJSON(DurabilityType.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] listDurableSubscriptions() {
|
||||
return listSubscribersInfos(DurabilityType.DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listDurableSubscriptionsAsJSON() throws Exception {
|
||||
return listSubscribersInfosAsJSON(DurabilityType.DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] listNonDurableSubscriptions() {
|
||||
return listSubscribersInfos(DurabilityType.NON_DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listNonDurableSubscriptionsAsJSON() throws Exception {
|
||||
return listSubscribersInfosAsJSON(DurabilityType.NON_DURABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object>[] listMessagesForSubscription(final String queueName) throws Exception {
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
|
||||
if (coreQueueControl == null) {
|
||||
throw new IllegalArgumentException("No subscriptions with name " + queueName);
|
||||
}
|
||||
|
||||
Map<String, Object>[] coreMessages = coreQueueControl.listMessages(null);
|
||||
|
||||
Map<String, Object>[] jmsMessages = new Map[coreMessages.length];
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (Map<String, Object> coreMessage : coreMessages) {
|
||||
jmsMessages[i++] = ActiveMQMessage.coreMaptoJMSMap(coreMessage);
|
||||
}
|
||||
return jmsMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessagesForSubscriptionAsJSON(final String queueName) throws Exception {
|
||||
return JMSQueueControlImpl.toJSON(listMessagesForSubscription(queueName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countMessagesForSubscription(final String clientID,
|
||||
final String subscriptionName,
|
||||
final String filterStr) throws Exception {
|
||||
String queueName = ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, subscriptionName);
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
|
||||
if (coreQueueControl == null) {
|
||||
throw new IllegalArgumentException("No subscriptions with name " + queueName + " for clientID " + clientID);
|
||||
}
|
||||
String filter = JMSTopicControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
return coreQueueControl.listMessages(filter).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeMessages(final String filterStr) throws Exception {
|
||||
String filter = JMSTopicControlImpl.createFilterFromJMSSelector(filterStr);
|
||||
int count = 0;
|
||||
String[] queues = addressControl.getQueueNames();
|
||||
for (String queue : queues) {
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queue);
|
||||
if (coreQueueControl != null) {
|
||||
count += coreQueueControl.removeMessages(filter);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropDurableSubscription(final String clientID, final String subscriptionName) throws Exception {
|
||||
String queueName = ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, subscriptionName);
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
|
||||
if (coreQueueControl == null) {
|
||||
throw new IllegalArgumentException("No subscriptions with name " + queueName + " for clientID " + clientID);
|
||||
}
|
||||
ActiveMQServerControl serverControl = (ActiveMQServerControl) managementService.getResource(ResourceNames.CORE_SERVER);
|
||||
serverControl.destroyQueue(queueName, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAllSubscriptions() throws Exception {
|
||||
ActiveMQServerControl serverControl = (ActiveMQServerControl) managementService.getResource(ResourceNames.CORE_SERVER);
|
||||
String[] queues = addressControl.getQueueNames();
|
||||
for (String queue : queues) {
|
||||
// Drop all subscription shouldn't delete the dummy queue used to identify if the topic exists on the core queues.
|
||||
// we will just ignore this queue
|
||||
if (!queue.equals(managedTopic.getAddress())) {
|
||||
serverControl.destroyQueue(queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
private Object[] listSubscribersInfos(final DurabilityType durability) {
|
||||
List<QueueControl> queues = getQueues(durability);
|
||||
List<Object[]> subInfos = new ArrayList<>(queues.size());
|
||||
|
||||
for (QueueControl queue : queues) {
|
||||
String clientID = null;
|
||||
String subName = null;
|
||||
|
||||
if (queue.isDurable()) {
|
||||
Pair<String, String> pair = ActiveMQDestination.decomposeQueueNameForDurableSubscription(queue.getName());
|
||||
clientID = pair.getA();
|
||||
subName = pair.getB();
|
||||
}
|
||||
|
||||
String filter = queue.getFilter() != null ? queue.getFilter() : null;
|
||||
|
||||
Object[] subscriptionInfo = new Object[6];
|
||||
subscriptionInfo[0] = queue.getName();
|
||||
subscriptionInfo[1] = clientID;
|
||||
subscriptionInfo[2] = subName;
|
||||
subscriptionInfo[3] = queue.isDurable();
|
||||
subscriptionInfo[4] = queue.getMessageCount();
|
||||
subscriptionInfo[5] = filter;
|
||||
subInfos.add(subscriptionInfo);
|
||||
}
|
||||
return subInfos.toArray(new Object[subInfos.size()]);
|
||||
}
|
||||
|
||||
private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception {
|
||||
try {
|
||||
List<QueueControl> queues = getQueues(durability);
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
|
||||
for (QueueControl queue : queues) {
|
||||
String clientID = null;
|
||||
String subName = null;
|
||||
|
||||
if (queue.isDurable()) {
|
||||
Pair<String, String> pair = ActiveMQDestination.decomposeQueueNameForDurableSubscription(queue.getName());
|
||||
clientID = pair.getA();
|
||||
subName = pair.getB();
|
||||
} else {
|
||||
// in the case of heirarchical topics the queue name will not follow the <part>.<part> pattern of normal
|
||||
// durable subscribers so skip decomposing the name for the client ID and subscription name and just
|
||||
// hard-code it
|
||||
clientID = "";
|
||||
subName = "";
|
||||
}
|
||||
|
||||
String filter = queue.getFilter() != null ? queue.getFilter() : null;
|
||||
|
||||
JsonObject info = JsonLoader.createObjectBuilder().add("queueName", queue.getName()).add("clientID", nullSafe(clientID)).add("selector", nullSafe(filter)).add("name", nullSafe(subName)).add("durable", queue.isDurable()).add("messageCount", queue.getMessageCount()).add("deliveringCount", queue.getDeliveringCount()).add("consumers", queue.listConsumersAsJSON()).build();
|
||||
|
||||
array.add(info);
|
||||
}
|
||||
|
||||
return array.build().toString();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Unable to list subscribers as JSON", e.getMessage(), e);
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private int getMessageCount(final DurabilityType durability) {
|
||||
List<QueueControl> queues = getQueues(durability);
|
||||
int count = 0;
|
||||
for (QueueControl queue : queues) {
|
||||
count += queue.getMessageCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private List<QueueControl> getQueues(final DurabilityType durability) {
|
||||
try {
|
||||
List<QueueControl> matchingQueues = new ArrayList<>();
|
||||
String[] queues = addressControl.getQueueNames();
|
||||
for (String queue : queues) {
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queue);
|
||||
|
||||
// Ignore the "special" subscription
|
||||
if (coreQueueControl != null && !coreQueueControl.getName().equals(addressControl.getAddress())) {
|
||||
if (durability == DurabilityType.ALL || durability == DurabilityType.DURABLE && coreQueueControl.isDurable() ||
|
||||
durability == DurabilityType.NON_DURABLE && !coreQueueControl.isDurable()) {
|
||||
matchingQueues.add(coreQueueControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchingQueues;
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
MBeanInfo info = super.getMBeanInfo();
|
||||
return new MBeanInfo(info.getClassName(), info.getDescription(), MBeanInfoHelper.getMBeanAttributesInfo(TopicControl.class), info.getConstructors(), MBeanInfoHelper.getMBeanOperationsInfo(TopicControl.class), info.getNotifications());
|
||||
}
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
private enum DurabilityType {
|
||||
ALL, DURABLE, NON_DURABLE
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl.openmbean;
|
||||
|
||||
public interface JMSCompositeDataConstants {
|
||||
|
||||
String JMS_DESTINATION = "JMSDestination";
|
||||
String JMS_MESSAGE_ID = "JMSMessageID";
|
||||
String JMS_TYPE = "JMSType";
|
||||
String JMS_DELIVERY_MODE = "JMSDeliveryMode";
|
||||
String JMS_EXPIRATION = "JMSExpiration";
|
||||
String JMS_PRIORITY = "JMSPriority";
|
||||
String JMS_REDELIVERED = "JMSRedelivered";
|
||||
String JMS_TIMESTAMP = "JMSTimestamp";
|
||||
String JMSXGROUP_SEQ = "JMSXGroupSeq";
|
||||
String JMSXGROUP_ID = "JMSXGroupID";
|
||||
String JMSXUSER_ID = "JMSXUserID";
|
||||
String JMS_CORRELATION_ID = "JMSCorrelationID";
|
||||
String ORIGINAL_DESTINATION = "OriginalDestination";
|
||||
String JMS_REPLY_TO = "JMSReplyTo";
|
||||
|
||||
String JMS_DESTINATION_DESCRIPTION = "The message destination";
|
||||
String JMS_MESSAGE_ID_DESCRIPTION = "The message ID";
|
||||
String JMS_TYPE_DESCRIPTION = "The message type";
|
||||
String JMS_DELIVERY_MODE_DESCRIPTION = "The message delivery mode";
|
||||
String JMS_EXPIRATION_DESCRIPTION = "The message expiration";
|
||||
String JMS_PRIORITY_DESCRIPTION = "The message priority";
|
||||
String JMS_REDELIVERED_DESCRIPTION = "Is the message redelivered";
|
||||
String JMS_TIMESTAMP_DESCRIPTION = "The message timestamp";
|
||||
String JMSXGROUP_SEQ_DESCRIPTION = "The message group sequence number";
|
||||
String JMSXGROUP_ID_DESCRIPTION = "The message group ID";
|
||||
String JMSXUSER_ID_DESCRIPTION = "The user that sent the message";
|
||||
String JMS_CORRELATION_ID_DESCRIPTION = "The message correlation ID";
|
||||
String ORIGINAL_DESTINATION_DESCRIPTION = "Original Destination Before Senting To DLQ";
|
||||
String JMS_REPLY_TO_DESCRIPTION = "The reply to address";
|
||||
|
||||
String BODY_LENGTH = "BodyLength";
|
||||
String BODY_PREVIEW = "BodyPreview";
|
||||
String CONTENT_MAP = "ContentMap";
|
||||
String MESSAGE_TEXT = "Text";
|
||||
String MESSAGE_URL = "Url";
|
||||
|
||||
}
|
|
@ -1,357 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* <p/>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p/>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.management.impl.openmbean;
|
||||
|
||||
import javax.management.openmbean.ArrayType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.TabularType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
|
||||
import org.apache.activemq.artemis.api.core.Message;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.management.impl.openmbean.CompositeDataConstants;
|
||||
import org.apache.activemq.artemis.reader.MapMessageUtil;
|
||||
import org.apache.activemq.artemis.utils.TypedProperties;
|
||||
|
||||
public final class JMSOpenTypeSupport {
|
||||
|
||||
public interface OpenTypeFactory {
|
||||
|
||||
CompositeType getCompositeType() throws OpenDataException;
|
||||
|
||||
Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException;
|
||||
}
|
||||
|
||||
private static final Map<Byte, AbstractOpenTypeFactory> OPEN_TYPE_FACTORIES = new HashMap<>();
|
||||
|
||||
public abstract static class AbstractOpenTypeFactory implements OpenTypeFactory {
|
||||
|
||||
private CompositeType compositeType;
|
||||
private final List<String> itemNamesList = new ArrayList<>();
|
||||
private final List<String> itemDescriptionsList = new ArrayList<>();
|
||||
private final List<OpenType> itemTypesList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public CompositeType getCompositeType() throws OpenDataException {
|
||||
if (compositeType == null) {
|
||||
init();
|
||||
compositeType = createCompositeType();
|
||||
}
|
||||
return compositeType;
|
||||
}
|
||||
|
||||
protected void init() throws OpenDataException {
|
||||
}
|
||||
|
||||
protected CompositeType createCompositeType() throws OpenDataException {
|
||||
String[] itemNames = itemNamesList.toArray(new String[itemNamesList.size()]);
|
||||
String[] itemDescriptions = itemDescriptionsList.toArray(new String[itemDescriptionsList.size()]);
|
||||
OpenType[] itemTypes = itemTypesList.toArray(new OpenType[itemTypesList.size()]);
|
||||
return new CompositeType(getTypeName(), getDescription(), itemNames, itemDescriptions, itemTypes);
|
||||
}
|
||||
|
||||
protected abstract String getTypeName();
|
||||
|
||||
protected void addItem(String name, String description, OpenType type) {
|
||||
itemNamesList.add(name);
|
||||
itemDescriptionsList.add(description);
|
||||
itemTypesList.add(type);
|
||||
}
|
||||
|
||||
protected String getDescription() {
|
||||
return getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException {
|
||||
Map<String, Object> rc = new HashMap<>();
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
static class MessageOpenTypeFactory extends AbstractOpenTypeFactory {
|
||||
|
||||
protected TabularType stringPropertyTabularType;
|
||||
protected TabularType booleanPropertyTabularType;
|
||||
protected TabularType bytePropertyTabularType;
|
||||
protected TabularType shortPropertyTabularType;
|
||||
protected TabularType intPropertyTabularType;
|
||||
protected TabularType longPropertyTabularType;
|
||||
protected TabularType floatPropertyTabularType;
|
||||
protected TabularType doublePropertyTabularType;
|
||||
|
||||
protected ArrayType body;
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return Message.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() throws OpenDataException {
|
||||
super.init();
|
||||
|
||||
addItem(JMSCompositeDataConstants.JMS_DESTINATION, JMSCompositeDataConstants.JMS_DESTINATION_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_MESSAGE_ID, JMSCompositeDataConstants.JMS_MESSAGE_ID_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_CORRELATION_ID, JMSCompositeDataConstants.JMS_CORRELATION_ID_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_TYPE, JMSCompositeDataConstants.JMS_TYPE_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_DELIVERY_MODE, JMSCompositeDataConstants.JMS_DELIVERY_MODE_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_EXPIRATION, JMSCompositeDataConstants.JMS_EXPIRATION_DESCRIPTION, SimpleType.LONG);
|
||||
addItem(JMSCompositeDataConstants.JMS_PRIORITY, JMSCompositeDataConstants.JMS_PRIORITY_DESCRIPTION, SimpleType.INTEGER);
|
||||
addItem(JMSCompositeDataConstants.JMS_REDELIVERED, JMSCompositeDataConstants.JMS_REDELIVERED_DESCRIPTION, SimpleType.BOOLEAN);
|
||||
addItem(JMSCompositeDataConstants.JMS_TIMESTAMP, JMSCompositeDataConstants.JMS_TIMESTAMP_DESCRIPTION, SimpleType.DATE);
|
||||
addItem(JMSCompositeDataConstants.JMSXGROUP_ID, JMSCompositeDataConstants.JMSXGROUP_ID_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMSXGROUP_SEQ, JMSCompositeDataConstants.JMSXGROUP_SEQ_DESCRIPTION, SimpleType.INTEGER);
|
||||
addItem(JMSCompositeDataConstants.JMSXUSER_ID, JMSCompositeDataConstants.JMSXUSER_ID_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.JMS_REPLY_TO, JMSCompositeDataConstants.JMS_REPLY_TO_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(JMSCompositeDataConstants.ORIGINAL_DESTINATION, JMSCompositeDataConstants.ORIGINAL_DESTINATION_DESCRIPTION, SimpleType.STRING);
|
||||
addItem(CompositeDataConstants.PROPERTIES, CompositeDataConstants.PROPERTIES_DESCRIPTION, SimpleType.STRING);
|
||||
|
||||
// now lets expose the type safe properties
|
||||
stringPropertyTabularType = createTabularType(String.class, SimpleType.STRING);
|
||||
booleanPropertyTabularType = createTabularType(Boolean.class, SimpleType.BOOLEAN);
|
||||
bytePropertyTabularType = createTabularType(Byte.class, SimpleType.BYTE);
|
||||
shortPropertyTabularType = createTabularType(Short.class, SimpleType.SHORT);
|
||||
intPropertyTabularType = createTabularType(Integer.class, SimpleType.INTEGER);
|
||||
longPropertyTabularType = createTabularType(Long.class, SimpleType.LONG);
|
||||
floatPropertyTabularType = createTabularType(Float.class, SimpleType.FLOAT);
|
||||
doublePropertyTabularType = createTabularType(Double.class, SimpleType.DOUBLE);
|
||||
|
||||
addItem(CompositeDataConstants.STRING_PROPERTIES, CompositeDataConstants.STRING_PROPERTIES_DESCRIPTION, stringPropertyTabularType);
|
||||
addItem(CompositeDataConstants.BOOLEAN_PROPERTIES, CompositeDataConstants.BOOLEAN_PROPERTIES_DESCRIPTION, booleanPropertyTabularType);
|
||||
addItem(CompositeDataConstants.BYTE_PROPERTIES, CompositeDataConstants.BYTE_PROPERTIES_DESCRIPTION, bytePropertyTabularType);
|
||||
addItem(CompositeDataConstants.SHORT_PROPERTIES, CompositeDataConstants.SHORT_PROPERTIES_DESCRIPTION, shortPropertyTabularType);
|
||||
addItem(CompositeDataConstants.INT_PROPERTIES, CompositeDataConstants.INT_PROPERTIES_DESCRIPTION, intPropertyTabularType);
|
||||
addItem(CompositeDataConstants.LONG_PROPERTIES, CompositeDataConstants.LONG_PROPERTIES_DESCRIPTION, longPropertyTabularType);
|
||||
addItem(CompositeDataConstants.FLOAT_PROPERTIES, CompositeDataConstants.FLOAT_PROPERTIES_DESCRIPTION, floatPropertyTabularType);
|
||||
addItem(CompositeDataConstants.DOUBLE_PROPERTIES, CompositeDataConstants.DOUBLE_PROPERTIES_DESCRIPTION, doublePropertyTabularType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException {
|
||||
Map<String, Object> rc = super.getFields(data);
|
||||
putString(rc, data, JMSCompositeDataConstants.JMS_MESSAGE_ID, CompositeDataConstants.USER_ID);
|
||||
putString(rc, data, JMSCompositeDataConstants.JMS_DESTINATION, CompositeDataConstants.ADDRESS);
|
||||
putStringProperty(rc, data, JMSCompositeDataConstants.JMS_REPLY_TO, "JMSReplyTo");
|
||||
rc.put(JMSCompositeDataConstants.JMS_TYPE, getType());
|
||||
rc.put(JMSCompositeDataConstants.JMS_DELIVERY_MODE, ((Boolean) data.get(CompositeDataConstants.DURABLE)) ? "PERSISTENT" : "NON-PERSISTENT");
|
||||
rc.put(JMSCompositeDataConstants.JMS_EXPIRATION, data.get(CompositeDataConstants.EXPIRATION));
|
||||
rc.put(JMSCompositeDataConstants.JMS_TIMESTAMP, new Date((Long) data.get(CompositeDataConstants.TIMESTAMP)));
|
||||
rc.put(JMSCompositeDataConstants.JMS_PRIORITY, ((Byte) data.get(CompositeDataConstants.PRIORITY)).intValue());
|
||||
putStringProperty(rc, data, JMSCompositeDataConstants.JMS_CORRELATION_ID, JMSCompositeDataConstants.JMS_CORRELATION_ID);
|
||||
rc.put(JMSCompositeDataConstants.JMS_REDELIVERED, data.get(CompositeDataConstants.REDELIVERED));
|
||||
putStringProperty(rc, data, JMSCompositeDataConstants.JMSXGROUP_ID, Message.HDR_GROUP_ID.toString());
|
||||
putIntProperty(rc, data, JMSCompositeDataConstants.JMSXGROUP_SEQ, JMSCompositeDataConstants.JMSXGROUP_SEQ);
|
||||
putStringProperty(rc, data, JMSCompositeDataConstants.JMSXUSER_ID, Message.HDR_VALIDATED_USER.toString());
|
||||
putStringProperty(rc, data, JMSCompositeDataConstants.ORIGINAL_DESTINATION, Message.HDR_ORIGINAL_ADDRESS.toString());
|
||||
|
||||
rc.put(CompositeDataConstants.PROPERTIES, "" + data.get(CompositeDataConstants.PROPERTIES));
|
||||
|
||||
rc.put(CompositeDataConstants.STRING_PROPERTIES, data.get(CompositeDataConstants.STRING_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.BOOLEAN_PROPERTIES, data.get(CompositeDataConstants.BOOLEAN_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.BYTE_PROPERTIES, data.get(CompositeDataConstants.BYTE_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.SHORT_PROPERTIES, data.get(CompositeDataConstants.SHORT_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.INT_PROPERTIES, data.get(CompositeDataConstants.INT_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.LONG_PROPERTIES, data.get(CompositeDataConstants.LONG_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.FLOAT_PROPERTIES, data.get(CompositeDataConstants.FLOAT_PROPERTIES));
|
||||
rc.put(CompositeDataConstants.DOUBLE_PROPERTIES, data.get(CompositeDataConstants.DOUBLE_PROPERTIES));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
private void putString(Map<String, Object> rc, CompositeDataSupport data, String target, String source) {
|
||||
String prop = (String) data.get(source);
|
||||
if (prop != null) {
|
||||
rc.put(target, prop);
|
||||
} else {
|
||||
rc.put(target, "");
|
||||
}
|
||||
}
|
||||
|
||||
private void putStringProperty(Map<String, Object> rc, CompositeDataSupport data, String target, String source) {
|
||||
TabularDataSupport properties = (TabularDataSupport) data.get(CompositeDataConstants.STRING_PROPERTIES);
|
||||
Object[] keys = new Object[]{source};
|
||||
CompositeDataSupport cds = (CompositeDataSupport) properties.get(keys);
|
||||
String prop = "";
|
||||
if (cds != null && cds.get("value") != null) {
|
||||
prop = (String) cds.get("value");
|
||||
}
|
||||
rc.put(target, prop);
|
||||
}
|
||||
|
||||
private void putIntProperty(Map<String, Object> rc, CompositeDataSupport data, String target, String source) {
|
||||
TabularDataSupport properties = (TabularDataSupport) data.get(CompositeDataConstants.INT_PROPERTIES);
|
||||
Object[] keys = new Object[]{source};
|
||||
CompositeDataSupport cds = (CompositeDataSupport) properties.get(keys);
|
||||
Integer prop = 0;
|
||||
if (cds != null && cds.get("value") != null) {
|
||||
prop = (Integer) cds.get("value");
|
||||
}
|
||||
rc.put(target, prop);
|
||||
}
|
||||
|
||||
private String getType() {
|
||||
return "Message";
|
||||
}
|
||||
|
||||
protected String toString(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
protected <T> TabularType createTabularType(Class<T> type, OpenType openType) throws OpenDataException {
|
||||
String typeName = "java.util.Map<java.lang.String, " + type.getName() + ">";
|
||||
String[] keyValue = new String[]{"key", "value"};
|
||||
OpenType[] openTypes = new OpenType[]{SimpleType.STRING, openType};
|
||||
CompositeType rowType = new CompositeType(typeName, typeName, keyValue, keyValue, openTypes);
|
||||
return new TabularType(typeName, typeName, rowType, new String[]{"key"});
|
||||
}
|
||||
}
|
||||
|
||||
static class ByteMessageOpenTypeFactory extends MessageOpenTypeFactory {
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "BytesMessage";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() throws OpenDataException {
|
||||
super.init();
|
||||
addItem(JMSCompositeDataConstants.BODY_LENGTH, "Body length", SimpleType.LONG);
|
||||
addItem(JMSCompositeDataConstants.BODY_PREVIEW, "Body preview", new ArrayType(SimpleType.BYTE, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException {
|
||||
Map<String, Object> rc = super.getFields(data);
|
||||
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer((byte[]) data.get("body"));
|
||||
long length = 0;
|
||||
length = buffer.readableBytes();
|
||||
rc.put(JMSCompositeDataConstants.BODY_LENGTH, Long.valueOf(length));
|
||||
byte[] preview = new byte[(int) Math.min(length, 255)];
|
||||
buffer.readBytes(preview);
|
||||
rc.put(JMSCompositeDataConstants.BODY_PREVIEW, preview);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
static class MapMessageOpenTypeFactory extends MessageOpenTypeFactory {
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "MapMessage";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() throws OpenDataException {
|
||||
super.init();
|
||||
addItem(JMSCompositeDataConstants.CONTENT_MAP, "Content map", SimpleType.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException {
|
||||
Map<String, Object> rc = super.getFields(data);
|
||||
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer((byte[]) data.get("body"));
|
||||
TypedProperties properties = new TypedProperties();
|
||||
MapMessageUtil.readBodyMap(buffer, properties);
|
||||
rc.put(JMSCompositeDataConstants.CONTENT_MAP, "" + properties.getMap());
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
static class ObjectMessageOpenTypeFactory extends MessageOpenTypeFactory {
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "ObjectMessage";
|
||||
}
|
||||
}
|
||||
|
||||
static class StreamMessageOpenTypeFactory extends MessageOpenTypeFactory {
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "StreamMessage";
|
||||
}
|
||||
}
|
||||
|
||||
static class TextMessageOpenTypeFactory extends MessageOpenTypeFactory {
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "TextMessage";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() throws OpenDataException {
|
||||
super.init();
|
||||
addItem(JMSCompositeDataConstants.MESSAGE_TEXT, JMSCompositeDataConstants.MESSAGE_TEXT, SimpleType.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getFields(CompositeDataSupport data) throws OpenDataException {
|
||||
Map<String, Object> rc = super.getFields(data);
|
||||
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer((byte[]) data.get("body"));
|
||||
SimpleString value = buffer.readNullableSimpleString();
|
||||
rc.put(JMSCompositeDataConstants.MESSAGE_TEXT, value != null ? value.toString() : "");
|
||||
return rc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
OPEN_TYPE_FACTORIES.put(Message.DEFAULT_TYPE, new MessageOpenTypeFactory());
|
||||
OPEN_TYPE_FACTORIES.put(Message.TEXT_TYPE, new TextMessageOpenTypeFactory());
|
||||
OPEN_TYPE_FACTORIES.put(Message.BYTES_TYPE, new ByteMessageOpenTypeFactory());
|
||||
OPEN_TYPE_FACTORIES.put(Message.MAP_TYPE, new MapMessageOpenTypeFactory());
|
||||
OPEN_TYPE_FACTORIES.put(Message.OBJECT_TYPE, new ObjectMessageOpenTypeFactory());
|
||||
OPEN_TYPE_FACTORIES.put(Message.STREAM_TYPE, new StreamMessageOpenTypeFactory());
|
||||
}
|
||||
|
||||
private JMSOpenTypeSupport() {
|
||||
}
|
||||
|
||||
public static OpenTypeFactory getFactory(Byte type) throws OpenDataException {
|
||||
return OPEN_TYPE_FACTORIES.get(type);
|
||||
}
|
||||
|
||||
public static CompositeData convert(CompositeDataSupport data) throws OpenDataException {
|
||||
OpenTypeFactory f = getFactory((Byte) data.get("type"));
|
||||
if (f == null) {
|
||||
throw new OpenDataException("Cannot create a CompositeData for type: " + data.get("type"));
|
||||
}
|
||||
CompositeType ct = f.getCompositeType();
|
||||
Map<String, Object> fields = f.getFields(data);
|
||||
return new CompositeDataSupport(ct, fields);
|
||||
}
|
||||
|
||||
}
|
|
@ -86,9 +86,7 @@ import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration;
|
|||
import org.apache.activemq.artemis.jms.server.config.TopicConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.management.JMSManagementService;
|
||||
import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
|
||||
import org.apache.activemq.artemis.jms.server.management.impl.JMSManagementServiceImpl;
|
||||
import org.apache.activemq.artemis.jms.transaction.JMSTransactionDetail;
|
||||
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
|
@ -134,8 +132,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
|
||||
private final ActiveMQServer server;
|
||||
|
||||
private JMSManagementService jmsManagementService;
|
||||
|
||||
private boolean startCalled;
|
||||
|
||||
private boolean active;
|
||||
|
@ -194,10 +190,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
|
||||
try {
|
||||
|
||||
jmsManagementService = new JMSManagementServiceImpl(server.getManagementService(), server, this);
|
||||
|
||||
jmsManagementService.registerJMSServer(this);
|
||||
|
||||
// Must be set to active before calling initJournal
|
||||
active = true;
|
||||
|
||||
|
@ -252,15 +244,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
topicBindings.clear();
|
||||
topics.clear();
|
||||
|
||||
// it could be null if a backup
|
||||
if (jmsManagementService != null) {
|
||||
jmsManagementService.unregisterJMSServer();
|
||||
|
||||
jmsManagementService.stop();
|
||||
}
|
||||
|
||||
jmsManagementService = null;
|
||||
|
||||
active = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -391,7 +374,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
// server.setJMSQueueCreator(new JMSDestinationCreator());
|
||||
//
|
||||
// server.setJMSQueueDeleter(new JMSQueueDeleter());
|
||||
|
||||
server.registerActivateCallback(this);
|
||||
|
||||
// server.registerPostQueueCreationCallback(new JMSPostQueueCreationCallback());
|
||||
|
@ -803,8 +785,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
queues.remove(name);
|
||||
queueBindings.remove(name);
|
||||
|
||||
jmsManagementService.unregisterQueue(name);
|
||||
|
||||
storage.deleteDestination(PersistedType.Queue, name);
|
||||
|
||||
sendNotification(JMSNotificationType.QUEUE_DESTROYED, name);
|
||||
|
@ -822,7 +802,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
@Override
|
||||
public synchronized boolean destroyTopic(final String name, final boolean removeConsumers) throws Exception {
|
||||
checkInitialised();
|
||||
AddressControl addressControl = (AddressControl) server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + name);
|
||||
AddressControl addressControl = (AddressControl) server.getManagementService().getResource(ResourceNames.ADDRESS + name);
|
||||
if (addressControl != null) {
|
||||
for (String queueName : addressControl.getQueueNames()) {
|
||||
Binding binding = server.getPostOffice().getBinding(new SimpleString(queueName));
|
||||
|
@ -843,8 +823,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
topics.remove(name);
|
||||
topicBindings.remove(name);
|
||||
|
||||
jmsManagementService.unregisterTopic(name);
|
||||
|
||||
storage.deleteDestination(PersistedType.Topic, name);
|
||||
|
||||
sendNotification(JMSNotificationType.TOPIC_DESTROYED, name);
|
||||
|
@ -1100,8 +1078,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
|
||||
this.recoverregistryBindings(queueName, PersistedType.Queue);
|
||||
|
||||
jmsManagementService.registerQueue(activeMQQueue, queue);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1136,8 +1112,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
|
||||
this.recoverregistryBindings(topicName, PersistedType.Topic);
|
||||
|
||||
jmsManagementService.registerTopic(activeMQTopic);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1157,8 +1131,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
|
||||
connectionFactories.put(cfConfig.getName(), cf);
|
||||
|
||||
jmsManagementService.registerConnectionFactory(cfConfig.getName(), cfConfig, cf);
|
||||
|
||||
return cf;
|
||||
}
|
||||
|
||||
|
@ -1284,8 +1256,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
|
|||
connectionFactoryBindings.remove(name);
|
||||
connectionFactories.remove(name);
|
||||
|
||||
jmsManagementService.unregisterConnectionFactory(name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.server.management;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
|
||||
public interface JMSManagementService {
|
||||
|
||||
JMSServerControl registerJMSServer(JMSServerManager server) throws Exception;
|
||||
|
||||
void unregisterJMSServer() throws Exception;
|
||||
|
||||
void registerQueue(ActiveMQQueue queue, Queue serverQueue) throws Exception;
|
||||
|
||||
void unregisterQueue(String name) throws Exception;
|
||||
|
||||
void registerTopic(ActiveMQTopic topic) throws Exception;
|
||||
|
||||
void unregisterTopic(String name) throws Exception;
|
||||
|
||||
void registerConnectionFactory(String name,
|
||||
ConnectionFactoryConfiguration config,
|
||||
ActiveMQConnectionFactory connectionFactory) throws Exception;
|
||||
|
||||
void unregisterConnectionFactory(String name) throws Exception;
|
||||
|
||||
void stop() throws Exception;
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.jms.server.management.impl;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
|
||||
import org.apache.activemq.artemis.core.messagecounter.MessageCounterManager;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
|
||||
import org.apache.activemq.artemis.jms.management.impl.JMSConnectionFactoryControlImpl;
|
||||
import org.apache.activemq.artemis.jms.management.impl.JMSQueueControlImpl;
|
||||
import org.apache.activemq.artemis.jms.management.impl.JMSServerControlImpl;
|
||||
import org.apache.activemq.artemis.jms.management.impl.JMSTopicControlImpl;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
|
||||
import org.apache.activemq.artemis.jms.server.management.JMSManagementService;
|
||||
|
||||
public class JMSManagementServiceImpl implements JMSManagementService {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final ManagementService managementService;
|
||||
|
||||
private final JMSServerManager jmsServerManager;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
public JMSManagementServiceImpl(final ManagementService managementService,
|
||||
final ActiveMQServer server,
|
||||
final JMSServerManager jmsServerManager) {
|
||||
this.managementService = managementService;
|
||||
this.jmsServerManager = jmsServerManager;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// JMSManagementRegistration implementation ----------------------
|
||||
|
||||
@Override
|
||||
public synchronized JMSServerControl registerJMSServer(final JMSServerManager server) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSServerObjectName();
|
||||
JMSServerControlImpl control = new JMSServerControlImpl(server);
|
||||
managementService.registerInJMX(objectName, control);
|
||||
managementService.registerInRegistry(ResourceNames.JMS_SERVER, control);
|
||||
return control;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterJMSServer() throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSServerObjectName();
|
||||
managementService.unregisterFromJMX(objectName);
|
||||
managementService.unregisterFromRegistry(ResourceNames.JMS_SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerQueue(final ActiveMQQueue queue, final Queue serverQueue) throws Exception {
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queue.getAddress());
|
||||
MessageCounterManager messageCounterManager = managementService.getMessageCounterManager();
|
||||
MessageCounter counter = new MessageCounter(queue.getName(), null, serverQueue, false, coreQueueControl.isDurable(), messageCounterManager.getMaxDayCount());
|
||||
messageCounterManager.registerMessageCounter(queue.getName(), counter);
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSQueueObjectName(queue.getQueueName());
|
||||
JMSQueueControlImpl control = new JMSQueueControlImpl(queue, coreQueueControl, jmsServerManager, counter);
|
||||
managementService.registerInJMX(objectName, control);
|
||||
managementService.registerInRegistry(queue.getQueueName(), control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterQueue(final String name) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSQueueObjectName(name);
|
||||
managementService.unregisterFromJMX(objectName);
|
||||
managementService.unregisterFromRegistry(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerTopic(final ActiveMQTopic topic) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSTopicObjectName(topic.getTopicName());
|
||||
AddressControl addressControl = (AddressControl) managementService.getResource(ResourceNames.CORE_ADDRESS + topic.getAddress());
|
||||
JMSTopicControlImpl control = new JMSTopicControlImpl(topic, jmsServerManager, addressControl, managementService);
|
||||
managementService.registerInJMX(objectName, control);
|
||||
managementService.registerInRegistry(topic.getTopicName(), control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterTopic(final String name) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getJMSTopicObjectName(name);
|
||||
managementService.unregisterFromJMX(objectName);
|
||||
managementService.unregisterFromRegistry(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerConnectionFactory(final String name,
|
||||
final ConnectionFactoryConfiguration cfConfig,
|
||||
final ActiveMQConnectionFactory connectionFactory) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getConnectionFactoryObjectName(name);
|
||||
JMSConnectionFactoryControlImpl control = new JMSConnectionFactoryControlImpl(cfConfig, connectionFactory, jmsServerManager, name);
|
||||
managementService.registerInJMX(objectName, control);
|
||||
managementService.registerInRegistry(ResourceNames.JMS_CONNECTION_FACTORY + name, control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterConnectionFactory(final String name) throws Exception {
|
||||
ObjectName objectName = managementService.getObjectNameBuilder().getConnectionFactoryObjectName(name);
|
||||
managementService.unregisterFromJMX(objectName);
|
||||
managementService.unregisterFromRegistry(ResourceNames.JMS_CONNECTION_FACTORY + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
for (Object resource : managementService.getResources(ConnectionFactoryControl.class)) {
|
||||
unregisterConnectionFactory(((ConnectionFactoryControl) resource).getName());
|
||||
}
|
||||
for (Object resource : managementService.getResources(JMSQueueControl.class)) {
|
||||
unregisterQueue(((JMSQueueControl) resource).getName());
|
||||
}
|
||||
for (Object resource : managementService.getResources(TopicControl.class)) {
|
||||
unregisterTopic(((TopicControl) resource).getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
}
|
|
@ -423,13 +423,6 @@ public final class ClusterConnectionConfiguration implements Serializable {
|
|||
ActiveMQServerLogger.LOGGER.clusterConnectionNotUnique();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getAddress() == null) {
|
||||
ActiveMQServerLogger.LOGGER.clusterConnectionNoForwardAddress();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1340,7 +1340,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
private void parseClusterConnectionConfiguration(final Element e, final Configuration mainConfig) throws Exception {
|
||||
String name = e.getAttribute("name");
|
||||
|
||||
String address = getString(e, "address", null, Validators.NOT_NULL_OR_EMPTY);
|
||||
String address = getString(e, "address", "", Validators.NO_CHECK);
|
||||
|
||||
String connectorName = getString(e, "connector-ref", null, Validators.NOT_NULL_OR_EMPTY);
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ import org.apache.activemq.artemis.api.core.management.BridgeControl;
|
|||
import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
|
||||
import org.apache.activemq.artemis.api.core.management.DivertControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.core.client.impl.Topology;
|
||||
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
|
||||
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
|
||||
|
@ -75,11 +77,14 @@ import org.apache.activemq.artemis.core.server.JournalType;
|
|||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.ServerConsumer;
|
||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
|
||||
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
|
||||
|
@ -551,6 +556,30 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAddress(String name, int routingType, boolean defaultDeleteOnNoConsumers, int defaultMaxConsumers) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
server.createOrUpdateAddressInfo(new AddressInfo(new SimpleString(name), AddressInfo.RoutingType.getType((byte)routingType), defaultDeleteOnNoConsumers, defaultMaxConsumers));
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAddress(String name) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
server.removeAddressInfo(new SimpleString(name));
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployQueue(final String address, final String name, final String filterString) throws Exception {
|
||||
checkStarted();
|
||||
|
@ -1694,7 +1723,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
|
||||
clearIO();
|
||||
try {
|
||||
postOffice.sendQueueInfoToQueue(new SimpleString(queueName), new SimpleString(address));
|
||||
postOffice.sendQueueInfoToQueue(new SimpleString(queueName), new SimpleString(address == null ? "" : address));
|
||||
|
||||
GroupingHandler handler = server.getGroupingHandler();
|
||||
if (handler != null) {
|
||||
|
@ -1950,6 +1979,42 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String listNetworkTopology() throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder brokers = JsonLoader.createArrayBuilder();
|
||||
ClusterManager clusterManager = server.getClusterManager();
|
||||
if (clusterManager != null) {
|
||||
Set<ClusterConnection> clusterConnections = clusterManager.getClusterConnections();
|
||||
for (ClusterConnection clusterConnection : clusterConnections) {
|
||||
Topology topology = clusterConnection.getTopology();
|
||||
Collection<TopologyMemberImpl> members = topology.getMembers();
|
||||
for (TopologyMemberImpl member : members) {
|
||||
|
||||
JsonObjectBuilder obj = JsonLoader.createObjectBuilder();
|
||||
TransportConfiguration live = member.getLive();
|
||||
if (live != null) {
|
||||
obj.add("nodeID", member.getNodeId()).add("live", live.getParams().get("host") + ":" + live.getParams().get("port"));
|
||||
TransportConfiguration backup = member.getBackup();
|
||||
if (backup != null) {
|
||||
obj.add("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port"));
|
||||
}
|
||||
}
|
||||
brokers.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return brokers.build().toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NotificationEmitter implementation ----------------------------
|
||||
|
||||
@Override
|
||||
|
@ -2045,6 +2110,11 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
return configuration.getManagementAddress().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeID() {
|
||||
return server.getNodeID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagementNotificationAddress() {
|
||||
return configuration.getManagementNotificationAddress().toString();
|
||||
|
|
|
@ -20,11 +20,15 @@ import javax.json.JsonArrayBuilder;
|
|||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.core.paging.PagingManager;
|
||||
import org.apache.activemq.artemis.core.paging.PagingStore;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
|
@ -34,7 +38,14 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice;
|
|||
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
|
||||
import org.apache.activemq.artemis.core.security.CheckType;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.security.SecurityAuth;
|
||||
import org.apache.activemq.artemis.core.security.SecurityStore;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.utils.Base64;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
|
||||
public class AddressControlImpl extends AbstractControl implements AddressControl {
|
||||
|
@ -43,7 +54,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final SimpleString address;
|
||||
private AddressInfo addressInfo;
|
||||
|
||||
private final PostOffice postOffice;
|
||||
|
||||
|
@ -51,20 +62,28 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
private final HierarchicalRepository<Set<Role>> securityRepository;
|
||||
|
||||
private final SecurityStore securityStore;
|
||||
|
||||
private final ManagementService managementService;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public AddressControlImpl(final SimpleString address,
|
||||
public AddressControlImpl(AddressInfo addressInfo,
|
||||
final PostOffice postOffice,
|
||||
final PagingManager pagingManager,
|
||||
final StorageManager storageManager,
|
||||
final HierarchicalRepository<Set<Role>> securityRepository) throws Exception {
|
||||
final HierarchicalRepository<Set<Role>> securityRepository,
|
||||
final SecurityStore securityStore,
|
||||
final ManagementService managementService)throws Exception {
|
||||
super(AddressControl.class, storageManager);
|
||||
this.address = address;
|
||||
this.addressInfo = addressInfo;
|
||||
this.postOffice = postOffice;
|
||||
this.pagingManager = pagingManager;
|
||||
this.securityRepository = securityRepository;
|
||||
this.securityStore = securityStore;
|
||||
this.managementService = managementService;
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
@ -73,14 +92,19 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return address.toString();
|
||||
return addressInfo.getName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoutingType() {
|
||||
return addressInfo.getRoutingType().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
Bindings bindings = postOffice.getBindingsForAddress(address);
|
||||
Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
|
||||
List<String> queueNames = new ArrayList<>();
|
||||
for (Binding binding : bindings.getBindings()) {
|
||||
if (binding instanceof QueueBinding) {
|
||||
|
@ -99,7 +123,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public String[] getBindingNames() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
Bindings bindings = postOffice.getBindingsForAddress(address);
|
||||
Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
|
||||
String[] bindingNames = new String[bindings.getBindings().size()];
|
||||
int i = 0;
|
||||
for (Binding binding : bindings.getBindings()) {
|
||||
|
@ -117,7 +141,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public Object[] getRoles() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
Set<Role> roles = securityRepository.getMatch(address.toString());
|
||||
Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString());
|
||||
|
||||
Object[] objRoles = new Object[roles.size()];
|
||||
|
||||
|
@ -136,7 +160,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder json = JsonLoader.createArrayBuilder();
|
||||
Set<Role> roles = securityRepository.getMatch(address.toString());
|
||||
Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString());
|
||||
|
||||
for (Role role : roles) {
|
||||
json.add(role.toJson());
|
||||
|
@ -151,7 +175,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public long getNumberOfBytesPerPage() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
return pagingManager.getPageStore(address).getPageSizeBytes();
|
||||
return pagingManager.getPageStore(addressInfo.getName()).getPageSizeBytes();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
@ -161,7 +185,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public long getAddressSize() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
return pagingManager.getPageStore(address).getAddressSize();
|
||||
return pagingManager.getPageStore(addressInfo.getName()).getAddressSize();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
@ -172,7 +196,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
clearIO();
|
||||
long totalMsgs = 0;
|
||||
try {
|
||||
Bindings bindings = postOffice.getBindingsForAddress(address);
|
||||
Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
|
||||
for (Binding binding : bindings.getBindings()) {
|
||||
if (binding instanceof QueueBinding) {
|
||||
totalMsgs += ((QueueBinding) binding).getQueue().getMessageCount();
|
||||
|
@ -190,7 +214,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public boolean isPaging() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
return pagingManager.getPageStore(address).isPaging();
|
||||
return pagingManager.getPageStore(addressInfo.getName()).isPaging();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
@ -200,18 +224,62 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
public int getNumberOfPages() throws Exception {
|
||||
clearIO();
|
||||
try {
|
||||
PagingStore pageStore = pagingManager.getPageStore(address);
|
||||
PagingStore pageStore = pagingManager.getPageStore(addressInfo.getName());
|
||||
|
||||
if (!pageStore.isPaging()) {
|
||||
return 0;
|
||||
} else {
|
||||
return pagingManager.getPageStore(address).getNumberOfPages();
|
||||
return pagingManager.getPageStore(addressInfo.getName()).getNumberOfPages();
|
||||
}
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
return getMessageCount(DurabilityType.ALL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String sendMessage(final Map<String, String> headers,
|
||||
final int type,
|
||||
final String body,
|
||||
boolean durable,
|
||||
final String user,
|
||||
final String password) throws Exception {
|
||||
securityStore.check(addressInfo.getName(), CheckType.SEND, new SecurityAuth() {
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemotingConnection getRemotingConnection() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
ServerMessageImpl message = new ServerMessageImpl(storageManager.generateID(), 50);
|
||||
for (String header : headers.keySet()) {
|
||||
message.putStringProperty(new SimpleString(header), new SimpleString(headers.get(header)));
|
||||
}
|
||||
message.setType((byte) type);
|
||||
message.setDurable(durable);
|
||||
message.setTimestamp(System.currentTimeMillis());
|
||||
if (body != null) {
|
||||
message.getBodyBuffer().writeBytes(Base64.decode(body));
|
||||
}
|
||||
message.setAddress(addressInfo.getName());
|
||||
postOffice.route(message, null, true);
|
||||
return "" + message.getMessageID();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MBeanOperationInfo[] fillMBeanOperationInfo() {
|
||||
return MBeanInfoHelper.getMBeanOperationsInfo(AddressControl.class);
|
||||
|
@ -228,5 +296,39 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
private int getMessageCount(final DurabilityType durability) {
|
||||
List<QueueControl> queues = getQueues(durability);
|
||||
int count = 0;
|
||||
for (QueueControl queue : queues) {
|
||||
count += queue.getMessageCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private List<QueueControl> getQueues(final DurabilityType durability) {
|
||||
try {
|
||||
List<QueueControl> matchingQueues = new ArrayList<>();
|
||||
String[] queues = getQueueNames();
|
||||
for (String queue : queues) {
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queue);
|
||||
|
||||
// Ignore the "special" subscription
|
||||
if (coreQueueControl != null && !coreQueueControl.getName().equals(getAddress())) {
|
||||
if (durability == DurabilityType.ALL || durability == DurabilityType.DURABLE && coreQueueControl.isDurable() ||
|
||||
durability == DurabilityType.NON_DURABLE && !coreQueueControl.isDurable()) {
|
||||
matchingQueues.add(coreQueueControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchingQueues;
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
private enum DurabilityType {
|
||||
ALL, DURABLE, NON_DURABLE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.json.JsonObjectBuilder;
|
|||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanOperationInfo;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
@ -38,6 +39,7 @@ import org.apache.activemq.artemis.api.core.management.QueueControl;
|
|||
import org.apache.activemq.artemis.core.filter.Filter;
|
||||
import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
|
||||
import org.apache.activemq.artemis.core.management.impl.openmbean.OpenTypeSupport;
|
||||
import org.apache.activemq.artemis.core.message.impl.MessageImpl;
|
||||
import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
|
||||
import org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterHelper;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
|
@ -59,7 +61,6 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
|||
import org.apache.activemq.artemis.utils.Base64;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
import org.apache.activemq.artemis.utils.LinkedListIterator;
|
||||
import org.apache.activemq.artemis.utils.UUID;
|
||||
|
||||
public class QueueControlImpl extends AbstractControl implements QueueControl {
|
||||
|
||||
|
@ -694,7 +695,6 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
public String sendMessage(final Map<String, String> headers,
|
||||
final int type,
|
||||
final String body,
|
||||
final String userID,
|
||||
boolean durable,
|
||||
final String user,
|
||||
final String password) throws Exception {
|
||||
|
@ -721,11 +721,13 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
message.setType((byte) type);
|
||||
message.setDurable(durable);
|
||||
message.setTimestamp(System.currentTimeMillis());
|
||||
message.setUserID(new UUID(UUID.TYPE_TIME_BASED, UUID.stringToBytes(userID)));
|
||||
if (body != null) {
|
||||
message.getBodyBuffer().writeBytes(Base64.decode(body));
|
||||
}
|
||||
message.setAddress(queue.getAddress());
|
||||
ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.putLong(queue.getID());
|
||||
message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
|
||||
postOffice.route(message, null, true);
|
||||
return "" + message.getMessageID();
|
||||
}
|
||||
|
@ -884,6 +886,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse() throws Exception {
|
||||
return browse(null);
|
||||
}
|
||||
@Override
|
||||
public CompositeData[] browse(String filterStr) throws Exception {
|
||||
checkStarted();
|
||||
|
|
|
@ -47,7 +47,7 @@ public interface PostOffice extends ActiveMQComponent {
|
|||
|
||||
AddressInfo addOrUpdateAddressInfo(AddressInfo addressInfo);
|
||||
|
||||
AddressInfo removeAddressInfo(SimpleString address);
|
||||
AddressInfo removeAddressInfo(SimpleString address) throws Exception;
|
||||
|
||||
AddressInfo getAddressInfo(SimpleString address);
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
|||
@Override
|
||||
public AddressInfo addAddressInfo(AddressInfo addressInfo) {
|
||||
try {
|
||||
getServer().getManagementService().registerAddress(addressInfo.getName());
|
||||
managementService.registerAddress(addressInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
|||
@Override
|
||||
public AddressInfo addOrUpdateAddressInfo(AddressInfo addressInfo) {
|
||||
try {
|
||||
getServer().getManagementService().registerAddress(addressInfo.getName());
|
||||
managementService.registerAddress(addressInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
|||
if (binding.getType() == BindingType.LOCAL_QUEUE) {
|
||||
managementService.unregisterQueue(uniqueName, binding.getAddress());
|
||||
} else if (binding.getType() == BindingType.DIVERT) {
|
||||
managementService.unregisterDivert(uniqueName);
|
||||
managementService.unregisterDivert(uniqueName, binding.getAddress());
|
||||
}
|
||||
|
||||
if (binding.getType() != BindingType.DIVERT) {
|
||||
|
|
|
@ -477,7 +477,7 @@ public interface ActiveMQServer extends ActiveMQComponent {
|
|||
|
||||
AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception;
|
||||
|
||||
AddressInfo removeAddressInfo(SimpleString address) throws Exception;
|
||||
void removeAddressInfo(SimpleString address) throws Exception;
|
||||
|
||||
String getInternalNamingPrefix();
|
||||
}
|
||||
|
|
|
@ -601,7 +601,7 @@ public final class ClusterManager implements ActiveMQComponent {
|
|||
dg);
|
||||
}
|
||||
|
||||
clusterConnection = new ClusterConnectionImpl(this, dg, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress()), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts());
|
||||
clusterConnection = new ClusterConnectionImpl(this, dg, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress() != null ? config.getAddress() : ""), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts());
|
||||
|
||||
clusterController.addClusterConnection(clusterConnection.getName(), dg, config);
|
||||
} else {
|
||||
|
|
|
@ -221,8 +221,6 @@ public class ClusterConnectionBridge extends BridgeImpl {
|
|||
|
||||
SimpleString notifQueueName = new SimpleString(qName);
|
||||
|
||||
String filterString = flowRecord.getAddress();
|
||||
|
||||
SimpleString filter = new SimpleString(ManagementHelper.HDR_BINDING_TYPE + "<>" +
|
||||
BindingType.DIVERT.toInt() +
|
||||
" AND " +
|
||||
|
@ -261,7 +259,7 @@ public class ClusterConnectionBridge extends BridgeImpl {
|
|||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Requesting sendQueueInfoToQueue through " + this, new Exception("trace"));
|
||||
}
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "sendQueueInfoToQueue", notifQueueName.toString(), flowRecord.getAddress());
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "sendQueueInfoToQueue", notifQueueName.toString(), flowRecord.getAddress());
|
||||
|
||||
try (ClientProducer prod = sessionConsumer.createProducer(managementAddress)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
|
@ -888,7 +888,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn
|
|||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return address.toString();
|
||||
return address != null ? address.toString() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2354,15 +2354,14 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo removeAddressInfo(SimpleString address) throws Exception {
|
||||
AddressInfo result = postOffice.removeAddressInfo(address);
|
||||
public void removeAddressInfo(SimpleString address) throws Exception {
|
||||
postOffice.removeAddressInfo(address);
|
||||
|
||||
// TODO: is this the right way to do this?
|
||||
// long txID = storageManager.generateID();
|
||||
// storageManager.deleteAddressBinding(txID, getAddressInfo(address).getID());
|
||||
// storageManager.commitBindings(txID);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2502,9 +2501,6 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
throw e;
|
||||
}
|
||||
|
||||
if (!addressAlreadyExists) {
|
||||
managementService.registerAddress(queue.getAddress());
|
||||
}
|
||||
managementService.registerQueue(queue, queue.getAddress(), storageManager);
|
||||
|
||||
callPostQueueCreationCallbacks(queue.getName());
|
||||
|
|
|
@ -33,6 +33,13 @@ public class AddressInfo {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public AddressInfo(SimpleString name, RoutingType routingType, boolean defaultDeleteOnNoConsumers, int defaultMaxConsumers) {
|
||||
this(name);
|
||||
this.routingType = routingType;
|
||||
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
|
||||
this.defaultMaxQueueConsumers = defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public RoutingType getRoutingType() {
|
||||
return routingType;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
|
|||
|
||||
queues.put(queue.getID(), queue);
|
||||
postOffice.addBinding(binding);
|
||||
managementService.registerAddress(queue.getAddress());
|
||||
//managementService.registerAddress(queue.getAddress());
|
||||
managementService.registerQueue(queue, queue.getAddress(), storageManager);
|
||||
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
|
|||
.setDefaultMaxQueueConsumers(addressBindingInfo.getDefaultMaxConsumers());
|
||||
|
||||
postOffice.addAddressInfo(addressInfo);
|
||||
managementService.registerAddress(addressInfo.getName());
|
||||
managementService.registerAddress(addressInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ public class ScaleDownHandler {
|
|||
Pair<byte[], Long> pair = list.get(i);
|
||||
array[i] = new String(pair.getA());
|
||||
}
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "updateDuplicateIdCache", entry.getKey().toString(), array);
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "updateDuplicateIdCache", entry.getKey().toString(), array);
|
||||
producer.send(message);
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ public class ScaleDownHandler {
|
|||
Object result;
|
||||
try (ClientRequestor requestor = new ClientRequestor(session, "activemq.management")) {
|
||||
ClientMessage managementMessage = session.createMessage(false);
|
||||
ManagementHelper.putAttribute(managementMessage, "core.queue." + queueName, "ID");
|
||||
ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queueName, "ID");
|
||||
session.start();
|
||||
logger.debug("Requesting ID for: " + queueName);
|
||||
ClientMessage reply = requestor.request(managementMessage);
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
|
|||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.core.transaction.ResourceManager;
|
||||
|
@ -89,7 +90,7 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
|
|||
|
||||
void unregisterFromRegistry(final String resourceName);
|
||||
|
||||
void registerAddress(SimpleString address) throws Exception;
|
||||
void registerAddress(AddressInfo addressInfo) throws Exception;
|
||||
|
||||
void unregisterAddress(SimpleString address) throws Exception;
|
||||
|
||||
|
@ -103,7 +104,7 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
|
|||
|
||||
void registerDivert(Divert divert, DivertConfiguration config) throws Exception;
|
||||
|
||||
void unregisterDivert(SimpleString name) throws Exception;
|
||||
void unregisterDivert(SimpleString name, SimpleString address) throws Exception;
|
||||
|
||||
void registerBroadcastGroup(BroadcastGroup broadcastGroup,
|
||||
BroadcastGroupConfiguration configuration) throws Exception;
|
||||
|
|
|
@ -75,6 +75,7 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
|
|||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.server.management.Notification;
|
||||
|
@ -197,7 +198,7 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
messagingServerControl = new ActiveMQServerControlImpl(postOffice, configuration, resourceManager, remotingService, messagingServer, messageCounterManager, storageManager1, broadcaster);
|
||||
ObjectName objectName = objectNameBuilder.getActiveMQServerObjectName();
|
||||
registerInJMX(objectName, messagingServerControl);
|
||||
registerInRegistry(ResourceNames.CORE_SERVER, messagingServerControl);
|
||||
registerInRegistry(ResourceNames.BROKER, messagingServerControl);
|
||||
|
||||
return messagingServerControl;
|
||||
}
|
||||
|
@ -206,17 +207,17 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
public synchronized void unregisterServer() throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getActiveMQServerObjectName();
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_SERVER);
|
||||
unregisterFromRegistry(ResourceNames.BROKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerAddress(final SimpleString address) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getAddressObjectName(address);
|
||||
AddressControlImpl addressControl = new AddressControlImpl(address, postOffice, pagingManager, storageManager, securityRepository);
|
||||
public void registerAddress(AddressInfo addressInfo) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getAddressObjectName(addressInfo.getName());
|
||||
AddressControlImpl addressControl = new AddressControlImpl(addressInfo, postOffice, pagingManager, storageManager, securityRepository, securityStore, this);
|
||||
|
||||
registerInJMX(objectName, addressControl);
|
||||
|
||||
registerInRegistry(ResourceNames.CORE_ADDRESS + address, addressControl);
|
||||
registerInRegistry(ResourceNames.ADDRESS + addressInfo.getName(), addressControl);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("registered address " + objectName);
|
||||
|
@ -228,9 +229,8 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
ObjectName objectName = objectNameBuilder.getAddressObjectName(address);
|
||||
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_ADDRESS + address);
|
||||
unregisterFromRegistry(ResourceNames.ADDRESS + address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerQueue(final Queue queue,
|
||||
final SimpleString address,
|
||||
|
@ -243,7 +243,7 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
}
|
||||
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, queue.getName());
|
||||
registerInJMX(objectName, queueControl);
|
||||
registerInRegistry(ResourceNames.CORE_QUEUE + queue.getName(), queueControl);
|
||||
registerInRegistry(ResourceNames.QUEUE + queue.getName(), queueControl);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("registered queue " + objectName);
|
||||
|
@ -254,16 +254,16 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name);
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_QUEUE + name);
|
||||
unregisterFromRegistry(ResourceNames.QUEUE + name);
|
||||
messageCounterManager.unregisterMessageCounter(name.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerDivert(final Divert divert, final DivertConfiguration config) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getDivertObjectName(divert.getUniqueName().toString());
|
||||
ObjectName objectName = objectNameBuilder.getDivertObjectName(divert.getUniqueName().toString(), config.getAddress());
|
||||
DivertControl divertControl = new DivertControlImpl(divert, storageManager, config);
|
||||
registerInJMX(objectName, divertControl);
|
||||
registerInRegistry(ResourceNames.CORE_DIVERT + config.getName(), divertControl);
|
||||
registerInRegistry(ResourceNames.DIVERT + config.getName(), divertControl);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("registered divert " + objectName);
|
||||
|
@ -271,10 +271,10 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterDivert(final SimpleString name) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getDivertObjectName(name.toString());
|
||||
public synchronized void unregisterDivert(final SimpleString name, final SimpleString address) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getDivertObjectName(name.toString(), address.toString());
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_DIVERT + name);
|
||||
unregisterFromRegistry(ResourceNames.DIVERT + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,7 +283,7 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
ObjectName objectName = objectNameBuilder.getAcceptorObjectName(configuration.getName());
|
||||
AcceptorControl control = new AcceptorControlImpl(acceptor, storageManager, configuration);
|
||||
registerInJMX(objectName, control);
|
||||
registerInRegistry(ResourceNames.CORE_ACCEPTOR + configuration.getName(), control);
|
||||
registerInRegistry(ResourceNames.ACCEPTOR + configuration.getName(), control);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -291,14 +291,14 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
List<String> acceptors = new ArrayList<>();
|
||||
synchronized (this) {
|
||||
for (String resourceName : registry.keySet()) {
|
||||
if (resourceName.startsWith(ResourceNames.CORE_ACCEPTOR)) {
|
||||
if (resourceName.startsWith(ResourceNames.ACCEPTOR)) {
|
||||
acceptors.add(resourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String acceptor : acceptors) {
|
||||
String name = acceptor.substring(ResourceNames.CORE_ACCEPTOR.length());
|
||||
String name = acceptor.substring(ResourceNames.ACCEPTOR.length());
|
||||
try {
|
||||
unregisterAcceptor(name);
|
||||
} catch (Exception e) {
|
||||
|
@ -310,7 +310,7 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
public synchronized void unregisterAcceptor(final String name) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getAcceptorObjectName(name);
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_ACCEPTOR + name);
|
||||
unregisterFromRegistry(ResourceNames.ACCEPTOR + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,14 +320,14 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
ObjectName objectName = objectNameBuilder.getBroadcastGroupObjectName(configuration.getName());
|
||||
BroadcastGroupControl control = new BroadcastGroupControlImpl(broadcastGroup, storageManager, configuration);
|
||||
registerInJMX(objectName, control);
|
||||
registerInRegistry(ResourceNames.CORE_BROADCAST_GROUP + configuration.getName(), control);
|
||||
registerInRegistry(ResourceNames.BROADCAST_GROUP + configuration.getName(), control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterBroadcastGroup(final String name) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getBroadcastGroupObjectName(name);
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_BROADCAST_GROUP + name);
|
||||
unregisterFromRegistry(ResourceNames.BROADCAST_GROUP + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -337,14 +337,14 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
ObjectName objectName = objectNameBuilder.getBridgeObjectName(configuration.getName());
|
||||
BridgeControl control = new BridgeControlImpl(bridge, storageManager, configuration);
|
||||
registerInJMX(objectName, control);
|
||||
registerInRegistry(ResourceNames.CORE_BRIDGE + configuration.getName(), control);
|
||||
registerInRegistry(ResourceNames.BRIDGE + configuration.getName(), control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unregisterBridge(final String name) throws Exception {
|
||||
ObjectName objectName = objectNameBuilder.getBridgeObjectName(name);
|
||||
unregisterFromJMX(objectName);
|
||||
unregisterFromRegistry(ResourceNames.CORE_BRIDGE + name);
|
||||
unregisterFromRegistry(ResourceNames.BRIDGE + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -470,7 +470,6 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
|
||||
@Override
|
||||
public synchronized void unregisterFromRegistry(final String resourceName) {
|
||||
ActiveMQServerLogger.LOGGER.info("Unregistering: " + resourceName, new Exception());
|
||||
registry.remove(resourceName);
|
||||
}
|
||||
|
||||
|
@ -536,7 +535,7 @@ public class ManagementServiceImpl implements ManagementService {
|
|||
List<String> unexpectedResourceNames = new ArrayList<>();
|
||||
for (String name : resourceNames) {
|
||||
// only addresses, queues, and diverts should still be registered
|
||||
if (!(name.startsWith(ResourceNames.CORE_ADDRESS) || name.startsWith(ResourceNames.CORE_QUEUE) || name.startsWith(ResourceNames.CORE_DIVERT))) {
|
||||
if (!(name.startsWith(ResourceNames.ADDRESS) || name.startsWith(ResourceNames.QUEUE) || name.startsWith(ResourceNames.DIVERT))) {
|
||||
unexpectedResourceNames.add(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1291,7 +1291,7 @@
|
|||
|
||||
<xsd:complexType name="cluster-connectionType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="address" type="xsd:string" maxOccurs="1" minOccurs="1">
|
||||
<xsd:element name="address" type="xsd:string" maxOccurs="1" minOccurs="0">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
name of the address this cluster connection applies to
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
|
|||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.server.management.Notification;
|
||||
import org.apache.activemq.artemis.core.server.management.NotificationListener;
|
||||
|
@ -245,7 +246,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerAddress(SimpleString address) throws Exception {
|
||||
public void registerAddress(AddressInfo addressInfo) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
@ -280,7 +281,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDivert(SimpleString name) throws Exception {
|
||||
public void unregisterDivert(SimpleString name, SimpleString address) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ import javax.naming.InitialContext;
|
|||
import java.util.HashMap;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
|
||||
|
||||
/**
|
||||
* An example that shows how to manage ActiveMQ Artemis using JMX.
|
||||
|
@ -81,13 +82,13 @@ public class JMXExample {
|
|||
// Step 11. Retrieve the MBeanServerConnection
|
||||
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
|
||||
|
||||
// Step 12. Create a JMSQueueControl proxy to manage the queue on the server
|
||||
JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, JMSQueueControl.class, false);
|
||||
// Step 12. Create a QueueControl proxy to manage the queue on the server
|
||||
QueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, QueueControl.class, false);
|
||||
// Step 13. Display the number of messages in the queue
|
||||
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
|
||||
|
||||
// Step 14. Remove the message sent at step #8
|
||||
System.out.println("message has been removed: " + queueControl.removeMessage(message.getJMSMessageID()));
|
||||
System.out.println("message has been removed: " + queueControl.removeMessage(((ActiveMQTextMessage) message).getCoreMessage().getMessageID()));
|
||||
|
||||
// Step 15. Display the number of messages in the queue
|
||||
System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages");
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.HashMap;
|
|||
|
||||
import org.apache.activemq.artemis.api.core.management.MessageCounterInfo;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
|
||||
/**
|
||||
* An example showing how to use message counters to have information on a queue.
|
||||
|
@ -75,7 +75,7 @@ public class MessageCounterExample {
|
|||
ObjectName on = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());
|
||||
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap<String, Object>());
|
||||
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
|
||||
JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, JMSQueueControl.class, false);
|
||||
QueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, QueueControl.class, false);
|
||||
|
||||
// Step 8. List the message counters and convert them to MessageCounterInfo data structure.
|
||||
String counters = queueControl.listMessageCounter();
|
||||
|
|
|
@ -27,9 +27,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
|
@ -195,15 +192,6 @@ public class OpenwireArtemisBaseTest {
|
|||
return "tcp://" + localhostAddress + ":" + port + "?" + URISupport.createQueryString(params);
|
||||
}
|
||||
|
||||
public static JMSServerControl createJMSServerControl(final MBeanServer mbeanServer) throws Exception {
|
||||
return (JMSServerControl) createProxy(ObjectNameBuilder.DEFAULT.getJMSServerObjectName(), JMSServerControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static JMSQueueControl createJMSQueueControl(final String name,
|
||||
final MBeanServer mbeanServer) throws Exception {
|
||||
return (JMSQueueControl) createProxy(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(name), JMSQueueControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
private static Object createProxy(final ObjectName objectName,
|
||||
final Class mbeanInterface,
|
||||
final MBeanServer mbeanServer) {
|
||||
|
|
|
@ -40,11 +40,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.management.DestinationControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
|
@ -868,7 +866,6 @@ public class JMSConsumerTest extends JmsTestSupport {
|
|||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
destination = (ActiveMQDestination) (destinationType == ActiveMQDestination.QUEUE_TYPE ? session.createQueue("test") : session.createTopic("test"));
|
||||
|
||||
createManagedDestinationOnServer(destination);
|
||||
MessageConsumer consumer = session.createConsumer(destination);
|
||||
connection.setStatsEnabled(true);
|
||||
|
||||
|
@ -902,42 +899,17 @@ public class JMSConsumerTest extends JmsTestSupport {
|
|||
}
|
||||
assertEquals("consumer has expiredMessages", count, amqConsumer.getConsumerStats().getExpiredMessageCount().getCount());
|
||||
|
||||
DestinationControl view = createView(destination);
|
||||
QueueControl view = createQueueControl(destination.getPhysicalName());
|
||||
|
||||
assertEquals("Wrong inFlightCount: " + view.getDeliveringCount(), 0, view.getDeliveringCount());
|
||||
assertEquals("Wrong dispatch count: " + view.getMessagesAdded(), 8, view.getMessagesAdded());
|
||||
}
|
||||
|
||||
private void createManagedDestinationOnServer(ActiveMQDestination destination) throws Exception {
|
||||
String destName = destination.getPhysicalName();
|
||||
private QueueControl createQueueControl(String destName) throws Exception {
|
||||
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
|
||||
MBeanServer beanServer = wrapper.getMbeanServer();
|
||||
ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSServerObjectName();
|
||||
JMSServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, JMSServerControl.class, false);
|
||||
serverControl.createQueue(destName);
|
||||
}
|
||||
|
||||
protected DestinationControl createView(ActiveMQDestination destination) throws Exception {
|
||||
|
||||
String destName = destination.getPhysicalName();
|
||||
if (destination.isQueue()) {
|
||||
return createJMSQueueControl(destName);
|
||||
} else {
|
||||
return createJMSTopicControl(destName);
|
||||
}
|
||||
}
|
||||
|
||||
private JMSQueueControl createJMSQueueControl(String destName) throws Exception {
|
||||
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
|
||||
MBeanServer beanServer = wrapper.getMbeanServer();
|
||||
ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(destName);
|
||||
return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, JMSQueueControl.class, false);
|
||||
}
|
||||
|
||||
private TopicControl createJMSTopicControl(String destName) throws Exception {
|
||||
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
|
||||
MBeanServer beanServer = wrapper.getMbeanServer();
|
||||
ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(destName);
|
||||
return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, TopicControl.class, false);
|
||||
SimpleString address = new SimpleString(destName);
|
||||
ObjectName objName = ObjectNameBuilder.DEFAULT.getQueueObjectName(address, address);
|
||||
return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, QueueControl.class, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ import javax.jms.Session;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
|
||||
|
@ -112,7 +113,7 @@ public class FailoverBackupLeakTest extends OpenwireArtemisBaseTest {
|
|||
|
||||
private int getConnectionCount(EmbeddedJMS server) throws Exception {
|
||||
ManagementService managementService = server.getActiveMQServer().getManagementService();
|
||||
JMSServerControl jmsControl = (JMSServerControl) managementService.getResource("jms.server");
|
||||
ActiveMQServerControl jmsControl = (ActiveMQServerControl) managementService.getResource(ResourceNames.BROKER);
|
||||
String[] ids = jmsControl.listConnectionIDs();
|
||||
if (ids != null) {
|
||||
return ids.length;
|
||||
|
|
|
@ -38,10 +38,11 @@ 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.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
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.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
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;
|
||||
|
@ -485,7 +486,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
if (index == 1) {
|
||||
managementService = server1.getManagementService();
|
||||
}
|
||||
JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(queue.getQueueName());
|
||||
QueueControl queueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queue.getQueueName());
|
||||
|
||||
//server may be closed
|
||||
if (queueControl != null) {
|
||||
|
@ -504,8 +505,8 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
if (index == 1) {
|
||||
managementService = server1.getManagementService();
|
||||
}
|
||||
TopicControl topicControl = (TopicControl) managementService.getResource(topic.getTopicName());
|
||||
Assert.assertEquals(0, topicControl.getSubscriptionCount());
|
||||
AddressControl topicControl = (AddressControl) managementService.getResource(ResourceNames.ADDRESS + topic.getTopicName());
|
||||
Assert.assertEquals(0, topicControl.getQueueNames().length);
|
||||
|
||||
}
|
||||
|
||||
|
@ -514,7 +515,7 @@ public abstract class BridgeTestBase extends ActiveMQTestBase {
|
|||
if (index == 1) {
|
||||
managementService = server1.getManagementService();
|
||||
}
|
||||
JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(queueName);
|
||||
QueueControl queueControl = (QueueControl) managementService.getResource("queue." + queueName);
|
||||
queueControl.removeMessages(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.apache.activemq.artemis.api.core.management.ResourceNames.CORE_ADDRESS;
|
||||
import static org.apache.activemq.artemis.api.core.management.ResourceNames.CORE_QUEUE;
|
||||
import static org.apache.activemq.artemis.api.core.management.ResourceNames.ADDRESS;
|
||||
import static org.apache.activemq.artemis.api.core.management.ResourceNames.QUEUE;
|
||||
|
||||
public class AutoCreateJmsDestinationTest extends JMSTestBase {
|
||||
|
||||
|
@ -73,8 +73,8 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase {
|
|||
}
|
||||
|
||||
// make sure the JMX control was created for the address and queue
|
||||
assertNotNull(server.getManagementService().getResource(CORE_ADDRESS + QUEUE_NAME));
|
||||
assertNotNull(server.getManagementService().getResource(CORE_QUEUE + QUEUE_NAME));
|
||||
assertNotNull(server.getManagementService().getResource(ADDRESS + QUEUE_NAME));
|
||||
assertNotNull(server.getManagementService().getResource(QUEUE + QUEUE_NAME));
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ import javax.jms.Queue;
|
|||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.tests.util.JMSTestBase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class JMSMessageCounterTest extends JMSTestBase {
|
|||
|
||||
conn.close();
|
||||
|
||||
JMSQueueControl control = (JMSQueueControl) server.getManagementService().getResource(queue.getQueueName());
|
||||
QueueControl control = (QueueControl) server.getManagementService().getResource(ResourceNames.QUEUE + queue.getQueueName());
|
||||
assertNotNull(control);
|
||||
|
||||
System.out.println(control.listMessageCounterAsHTML());
|
||||
|
@ -62,7 +63,7 @@ public class JMSMessageCounterTest extends JMSTestBase {
|
|||
|
||||
restartServer();
|
||||
|
||||
control = (JMSQueueControl) server.getManagementService().getResource(queue.getQueueName());
|
||||
control = (QueueControl) server.getManagementService().getResource(ResourceNames.QUEUE + queue.getQueueName());
|
||||
assertNotNull(control);
|
||||
|
||||
System.out.println(control.listMessageCounterAsHTML());
|
||||
|
|
|
@ -25,7 +25,8 @@ import javax.jms.Queue;
|
|||
import javax.jms.Session;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
|
@ -47,7 +48,7 @@ public class MultipleProducersTest extends JMSTestBase {
|
|||
|
||||
public SimpleString queueOneName = new SimpleString("queueOne");
|
||||
public SimpleString queueTwoName = new SimpleString("queueTwo");
|
||||
public JMSQueueControl control = null;
|
||||
public QueueControl control = null;
|
||||
public long queueOneMsgCount = 0;
|
||||
public long queueTwoMsgCount = 0;
|
||||
|
||||
|
@ -126,7 +127,7 @@ public class MultipleProducersTest extends JMSTestBase {
|
|||
// after draining queueOne send 5 message to queueOne
|
||||
queueTwoMsgCount = server.locateQueue(queueTwoName).getMessageCount();
|
||||
|
||||
control = (JMSQueueControl) server.getManagementService().getResource(queueOne.getQueueName());
|
||||
control = (QueueControl) server.getManagementService().getResource(ResourceNames.QUEUE + queueOne.getQueueName());
|
||||
|
||||
control.removeMessages(null);
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ public class BridgeReconnectTest extends BridgeTestBase {
|
|||
forwardingConnection.fail(new ActiveMQNotConnectedException());
|
||||
|
||||
final ManagementService managementService = server0.getManagementService();
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
|
||||
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queueName);
|
||||
assertEquals(0, coreQueueControl.getDeliveringCount());
|
||||
|
||||
final int numMessages = NUM_MESSAGES;
|
||||
|
|
|
@ -132,7 +132,7 @@ public class ClusteredMessageCounterTest extends ClusterTestBase {
|
|||
|
||||
verifyReceiveAllOnSingleConsumer(true, numMsg, 1);
|
||||
|
||||
QueueControl control = (QueueControl) servers[1].getManagementService().getResource(ResourceNames.CORE_QUEUE + "queue0");
|
||||
QueueControl control = (QueueControl) servers[1].getManagementService().getResource(ResourceNames.QUEUE + "queue0");
|
||||
|
||||
//wait up to 30sec to allow the counter get updated
|
||||
long timeout = 30000;
|
||||
|
@ -173,8 +173,8 @@ public class ClusteredMessageCounterTest extends ClusterTestBase {
|
|||
}
|
||||
});
|
||||
|
||||
QueueControl control = (QueueControl) servers[1].getManagementService().getResource(ResourceNames.CORE_QUEUE + "queue0");
|
||||
ActiveMQServerControl serverControl = (ActiveMQServerControl) servers[1].getManagementService().getResource(ResourceNames.CORE_SERVER);
|
||||
QueueControl control = (QueueControl) servers[1].getManagementService().getResource(ResourceNames.QUEUE + "queue0");
|
||||
ActiveMQServerControl serverControl = (ActiveMQServerControl) servers[1].getManagementService().getResource(ResourceNames.BROKER);
|
||||
serverControl.setMessageCounterSamplePeriod(300);
|
||||
|
||||
CountDownLatch resultLatch = new CountDownLatch(40);
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.activemq.artemis.core.config.Configuration;
|
|||
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.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.qpid.jms.JmsConnectionFactory;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -22,7 +22,8 @@ import javax.jms.Session;
|
|||
import javax.jms.TextMessage;
|
||||
import javax.jms.Topic;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.util.JMSTestBase;
|
||||
|
@ -47,7 +48,7 @@ public class ExpiryMessageTest extends JMSTestBase {
|
|||
@Test
|
||||
public void testSendTopicNoSubscription() throws Exception {
|
||||
Topic topic = createTopic("test-topic");
|
||||
TopicControl control = ManagementControlHelper.createTopicControl(topic, mbeanServer);
|
||||
AddressControl control = ManagementControlHelper.createAddressControl(new SimpleString(topic.getTopicName()), mbeanServer);
|
||||
|
||||
Connection conn2 = cf.createConnection();
|
||||
|
||||
|
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.management.Notification;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
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.jms.server.management.JMSNotificationType;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* A Connection Factory Control Test
|
||||
*/
|
||||
public class ConnectionFactoryControlTest extends ManagementTestBase {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl jmsServerManager;
|
||||
|
||||
private InVMNamingContext ctx;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void testCreateCF() throws Exception {
|
||||
JMSServerControl control = createJMSControl();
|
||||
control.createConnectionFactory("test", false, false, 0, "invm", "test");
|
||||
|
||||
ConnectionFactoryControl controlCF = createCFControl("test");
|
||||
|
||||
ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("test");
|
||||
|
||||
Assert.assertFalse(cf.isCompressLargeMessage());
|
||||
|
||||
controlCF.setCompressLargeMessages(true);
|
||||
|
||||
cf = (ActiveMQConnectionFactory) ctx.lookup("test");
|
||||
Assert.assertTrue(cf.isCompressLargeMessage());
|
||||
|
||||
server.stop();
|
||||
|
||||
waitForServerToStop(server);
|
||||
|
||||
startServer();
|
||||
|
||||
cf = (ActiveMQConnectionFactory) ctx.lookup("test");
|
||||
Assert.assertTrue(cf.isCompressLargeMessage());
|
||||
|
||||
}
|
||||
|
||||
//make sure notifications are always received no matter whether
|
||||
//a CF is created via JMSServerControl or by JMSServerManager directly.
|
||||
@Test
|
||||
public void testCreateCFNotification() throws Exception {
|
||||
JMSUtil.JMXListener listener = new JMSUtil.JMXListener();
|
||||
this.mbeanServer.addNotificationListener(ObjectNameBuilder.DEFAULT.getJMSServerObjectName(), listener, null, null);
|
||||
|
||||
List<String> connectors = new ArrayList<>();
|
||||
connectors.add("invm");
|
||||
|
||||
this.jmsServerManager.createConnectionFactory("NewCF", false, JMSFactoryType.CF, connectors, "/NewConnectionFactory");
|
||||
|
||||
Notification notif = listener.getNotification();
|
||||
|
||||
Assert.assertEquals(JMSNotificationType.CONNECTION_FACTORY_CREATED.toString(), notif.getType());
|
||||
Assert.assertEquals("NewCF", notif.getMessage());
|
||||
|
||||
this.jmsServerManager.destroyConnectionFactory("NewCF");
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.CONNECTION_FACTORY_DESTROYED.toString(), notif.getType());
|
||||
Assert.assertEquals("NewCF", notif.getMessage());
|
||||
|
||||
JMSServerControl control = createJMSControl();
|
||||
|
||||
control.createConnectionFactory("test", false, false, 0, "invm", "test");
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.CONNECTION_FACTORY_CREATED.toString(), notif.getType());
|
||||
Assert.assertEquals("test", notif.getMessage());
|
||||
|
||||
control.destroyConnectionFactory("test");
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.CONNECTION_FACTORY_DESTROYED.toString(), notif.getType());
|
||||
Assert.assertEquals("test", notif.getMessage());
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
startServer();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void startServer() throws Exception {
|
||||
Configuration config = createDefaultInVMConfig().addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)).setJMXManagementEnabled(true);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));
|
||||
server.start();
|
||||
|
||||
jmsServerManager = new JMSServerManagerImpl(server);
|
||||
jmsServerManager.start();
|
||||
|
||||
ctx = new InVMNamingContext();
|
||||
|
||||
jmsServerManager.setRegistry(new JndiBindingRegistry(ctx));
|
||||
jmsServerManager.activated();
|
||||
}
|
||||
|
||||
protected ConnectionFactoryControl createCFControl(String name) throws Exception {
|
||||
return ManagementControlHelper.createConnectionFactoryControl(name, mbeanServer);
|
||||
}
|
||||
|
||||
protected JMSServerControl createJMSControl() throws Exception {
|
||||
return ManagementControlHelper.createJMSServerControl(mbeanServer);
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.Message;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueRequestor;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
|
||||
|
||||
public class JMSMessagingProxy {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final String resourceName;
|
||||
|
||||
private final Session session;
|
||||
|
||||
private final QueueRequestor requestor;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
public JMSMessagingProxy(final QueueSession session,
|
||||
final Queue managementQueue,
|
||||
final String resourceName) throws Exception {
|
||||
this.session = session;
|
||||
|
||||
this.resourceName = resourceName;
|
||||
|
||||
requestor = new QueueRequestor(session, managementQueue);
|
||||
}
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
public Object retrieveAttributeValue(final String attributeName) {
|
||||
return retrieveAttributeValue(attributeName, null);
|
||||
}
|
||||
|
||||
public Object retrieveAttributeValue(final String attributeName, final Class desiredType) {
|
||||
try {
|
||||
Message m = session.createMessage();
|
||||
JMSManagementHelper.putAttribute(m, resourceName, attributeName);
|
||||
Message reply = requestor.request(m);
|
||||
return JMSManagementHelper.getResult(reply, desiredType);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object invokeOperation(final String operationName, final Object... args) throws Exception {
|
||||
return invokeOperation(null, operationName, args);
|
||||
}
|
||||
|
||||
public Object invokeOperation(final Class desiredType,
|
||||
final String operationName,
|
||||
final Object... args) throws Exception {
|
||||
Message m = session.createMessage();
|
||||
JMSManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
|
||||
Message reply = requestor.request(m);
|
||||
if (JMSManagementHelper.hasOperationSucceeded(reply)) {
|
||||
return JMSManagementHelper.getResult(reply, desiredType);
|
||||
} else {
|
||||
throw new Exception((String) JMSManagementHelper.getResult(reply));
|
||||
}
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,409 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* A JMSQueueControlUsingJMSTest
|
||||
*/
|
||||
public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private QueueConnection connection;
|
||||
|
||||
private QueueSession session;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(InVMConnectorFactory.class.getName()));
|
||||
connection = cf.createQueueConnection();
|
||||
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
connection.start();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Override
|
||||
@Test
|
||||
public void testListDeliveringMessages() throws Exception {
|
||||
// I'm not implementing the required proxy for this test on this JMS test
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JMSQueueControl createManagementControl() throws Exception {
|
||||
ActiveMQQueue managementQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue("activemq.management");
|
||||
|
||||
final JMSMessagingProxy proxy = new JMSMessagingProxy(session, managementQueue, queue.getQueueName());
|
||||
|
||||
return new JMSQueueControl() {
|
||||
|
||||
@Override
|
||||
public void flushExecutor() {
|
||||
try {
|
||||
proxy.invokeOperation("flushExecutor");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeMessagePriority(final String messageID, final int newPriority) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("changeMessagePriority", messageID, newPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int changeMessagesPriority(final String filter, final int newPriority) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "changeMessagesPriority", filter, newPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countMessages(final String filter) throws Exception {
|
||||
return ((Number) proxy.invokeOperation("countMessages", filter)).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean expireMessage(final String messageID) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("expireMessage", messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expireMessages(final String filter) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "expireMessages", filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConsumerCount() {
|
||||
return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesExpired() {
|
||||
return ((Number) proxy.retrieveAttributeValue("getMessagesExpired")).longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesKilled() {
|
||||
return ((Number) proxy.retrieveAttributeValue("messagesKilled")).longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDeadLetterAddress() {
|
||||
return (String) proxy.retrieveAttributeValue("deadLetterAddress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDeliveringCount() {
|
||||
return (Integer) proxy.retrieveAttributeValue("deliveringCount", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpiryAddress() {
|
||||
return (String) proxy.retrieveAttributeValue("expiryAddress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFirstMessageAsJSON() throws Exception {
|
||||
return (String) proxy.retrieveAttributeValue("firstMessageAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFirstMessageTimestamp() throws Exception {
|
||||
return (Long) proxy.retrieveAttributeValue("firstMessageTimestamp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFirstMessageAge() throws Exception {
|
||||
return (Long) proxy.retrieveAttributeValue("firstMessageAge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
return ((Number) proxy.retrieveAttributeValue("messageCount")).longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesAdded() {
|
||||
return (Integer) proxy.retrieveAttributeValue("messagesAdded", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return (String) proxy.retrieveAttributeValue("name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getScheduledCount() {
|
||||
return (Long) proxy.retrieveAttributeValue("scheduledCount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return (Boolean) proxy.retrieveAttributeValue("temporary");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounter() throws Exception {
|
||||
return (String) proxy.invokeOperation("listMessageCounter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMessageCounter() throws Exception {
|
||||
proxy.invokeOperation("resetMessageCounter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterAsHTML() throws Exception {
|
||||
return (String) proxy.invokeOperation("listMessageCounterAsHTML");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterHistory() throws Exception {
|
||||
return (String) proxy.invokeOperation("listMessageCounterHistory");
|
||||
}
|
||||
|
||||
public boolean retryMessage(@Parameter(name = "messageID", desc = "A message ID") long messageID) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("retryMessage", messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int retryMessages() throws Exception {
|
||||
return (Integer) proxy.invokeOperation("retryMessages", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retryMessage(final String messageID) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("retryMessage", messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object>[] listScheduledMessages() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listScheduledMessagesAsJSON() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, Object>[]> listDeliveringMessages() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listDeliveringMessagesAsJSON() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessageCounterHistoryAsHTML() throws Exception {
|
||||
return (String) proxy.invokeOperation("listMessageCounterHistoryAsHTML");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object>[] listMessages(final String filter) throws Exception {
|
||||
Object[] res = (Object[]) proxy.invokeOperation("listMessages", filter);
|
||||
Map<String, Object>[] results = new Map[res.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
results[i] = (Map<String, Object>) res[i];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listMessagesAsJSON(final String filter) throws Exception {
|
||||
return (String) proxy.invokeOperation("listMessagesAsJSON", filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveMessage(String messageID,
|
||||
String otherQueueName,
|
||||
boolean rejectDuplicates) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("moveMessage", messageID, otherQueueName, rejectDuplicates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int moveMessages(String filter, String otherQueueName, boolean rejectDuplicates) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "moveMessages", filter, otherQueueName, rejectDuplicates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int moveMessages(final String filter, final String otherQueueName) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "moveMessages", filter, otherQueueName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveMessage(final String messageID, final String otherQueueName) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("moveMessage", messageID, otherQueueName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeMessages(final String filter) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "removeMessages", filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeMessage(final String messageID) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("removeMessage", messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendMessageToDeadLetterAddress(final String messageID) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("sendMessageToDeadLetterAddress", messageID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
|
||||
return (Integer) proxy.invokeOperation(Integer.class, "sendMessagesToDeadLetterAddress", filterStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(@Parameter(name = "body") String body) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessageWithProperties(String properties) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(Map<String, String> headers, String body) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(String body, String user, String password) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendTextMessage(Map<String, String> headers,
|
||||
String body,
|
||||
String user,
|
||||
String password) throws Exception {
|
||||
return (String) proxy.invokeOperation("sendTextMessage", headers, body, user, password);
|
||||
}
|
||||
|
||||
public void setDeadLetterAddress(final String deadLetterAddress) throws Exception {
|
||||
proxy.invokeOperation("setDeadLetterAddress", deadLetterAddress);
|
||||
}
|
||||
|
||||
public void setExpiryAddress(final String expiryAddress) throws Exception {
|
||||
proxy.invokeOperation("setExpiryAddress", expiryAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return (String) proxy.retrieveAttributeValue("address");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("isPaused");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() throws Exception {
|
||||
proxy.invokeOperation("pause");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(boolean persist) throws Exception {
|
||||
proxy.invokeOperation("pause", persist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() throws Exception {
|
||||
proxy.invokeOperation("resume");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse() throws Exception {
|
||||
Map map = (Map) proxy.invokeOperation("browse");
|
||||
CompositeData[] compositeDatas = (CompositeData[]) map.get(CompositeData.class.getName());
|
||||
if (compositeDatas == null) {
|
||||
compositeDatas = new CompositeData[0];
|
||||
}
|
||||
return compositeDatas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse(String filter) throws Exception {
|
||||
return new CompositeData[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelector() {
|
||||
return (String) proxy.retrieveAttributeValue("selector");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(String jndi) throws Exception {
|
||||
// TODO: Add a test for this
|
||||
proxy.invokeOperation("addBindings", jndi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegistryBindings() {
|
||||
// TODO: Add a test for this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listConsumersAsJSON() throws Exception {
|
||||
return (String) proxy.invokeOperation("listConsumersAsJSON");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueRequestor;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
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.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase;
|
||||
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;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JMSServerControlRestartTest extends ManagementTestBase {
|
||||
|
||||
protected InVMNamingContext context;
|
||||
|
||||
private JMSServerManager serverManager;
|
||||
|
||||
@Test
|
||||
public void testCreateDurableQueueUsingJMXAndRestartServer() throws Exception {
|
||||
String queueName = RandomUtil.randomString();
|
||||
String binding = RandomUtil.randomString();
|
||||
|
||||
ActiveMQTestBase.checkNoBinding(context, binding);
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer);
|
||||
control.createQueue(queueName, binding);
|
||||
|
||||
Object o = ActiveMQTestBase.checkBinding(context, binding);
|
||||
Assert.assertTrue(o instanceof Queue);
|
||||
Queue queue = (Queue) o;
|
||||
Assert.assertEquals(queueName, queue.getQueueName());
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
serverManager.stop();
|
||||
|
||||
ActiveMQTestBase.checkNoBinding(context, binding);
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
serverManager = createJMSServer();
|
||||
serverManager.start();
|
||||
|
||||
o = ActiveMQTestBase.checkBinding(context, binding);
|
||||
Assert.assertTrue(o instanceof Queue);
|
||||
queue = (Queue) o;
|
||||
Assert.assertEquals(queueName, queue.getQueueName());
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDurableQueueUsingJMSAndRestartServer() throws Exception {
|
||||
String queueName = RandomUtil.randomString();
|
||||
String binding = RandomUtil.randomString();
|
||||
|
||||
ActiveMQTestBase.checkNoBinding(context, binding);
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
TransportConfiguration config = new TransportConfiguration(InVMConnectorFactory.class.getName());
|
||||
Connection connection = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, config).createConnection();
|
||||
connection.start();
|
||||
Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
|
||||
QueueSession session = (QueueSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
QueueRequestor requestor = new QueueRequestor(session, managementQueue);
|
||||
Message message = session.createMessage();
|
||||
JMSManagementHelper.putOperationInvocation(message, "jms.server", "createQueue", queueName, binding);
|
||||
Message reply = requestor.request(message);
|
||||
Assert.assertTrue(JMSManagementHelper.hasOperationSucceeded(reply));
|
||||
connection.close();
|
||||
|
||||
Object o = ActiveMQTestBase.checkBinding(context, binding);
|
||||
Assert.assertTrue(o instanceof Queue);
|
||||
Queue queue = (Queue) o;
|
||||
Assert.assertEquals(queueName, queue.getQueueName());
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
serverManager.stop();
|
||||
|
||||
ActiveMQTestBase.checkNoBinding(context, binding);
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
|
||||
serverManager = createJMSServer();
|
||||
serverManager.start();
|
||||
|
||||
o = ActiveMQTestBase.checkBinding(context, binding);
|
||||
Assert.assertTrue(o instanceof Queue);
|
||||
queue = (Queue) o;
|
||||
Assert.assertEquals(queueName, queue.getQueueName());
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
serverManager = createJMSServer();
|
||||
serverManager.start();
|
||||
}
|
||||
|
||||
private JMSServerManager createJMSServer() throws Exception {
|
||||
Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true).setJournalType(JournalType.NIO);
|
||||
|
||||
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer));
|
||||
|
||||
context = new InVMNamingContext();
|
||||
|
||||
serverManager = new JMSServerManagerImpl(server);
|
||||
serverManager.setRegistry(new JndiBindingRegistry(context));
|
||||
return serverManager;
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,436 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
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.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueueConnectionFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JMSServerControlUsingJMSTest extends JMSServerControlTest {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private QueueConnection connection;
|
||||
|
||||
private QueueSession session;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
private static String[] toStringArray(final Object[] res) {
|
||||
String[] names = new String[res.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
names[i] = res[i].toString();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
// The JMS test won't support the server being restarted, hence we have to do a slight different test on that case
|
||||
@Override
|
||||
@Test
|
||||
public void testCreateConnectionFactory_CompleteList() throws Exception {
|
||||
JMSServerControl control = createManagementControl();
|
||||
control.createConnectionFactory("test", //name
|
||||
true, // ha
|
||||
false, // useDiscovery
|
||||
1, // cfType
|
||||
"invm", // connectorNames
|
||||
"tst", // jndiBindins
|
||||
"tst", // clientID
|
||||
1, // clientFailureCheckPeriod
|
||||
1, // connectionTTL
|
||||
1, // callTimeout
|
||||
1, // callFailoverTimeout
|
||||
1, // minLargeMessageSize
|
||||
true, // compressLargeMessages
|
||||
1, // consumerWindowSize
|
||||
1, // consumerMaxRate
|
||||
1, // confirmationWindowSize
|
||||
1, // ProducerWindowSize
|
||||
1, // producerMaxRate
|
||||
true, // blockOnACK
|
||||
true, // blockOnDurableSend
|
||||
true, // blockOnNonDurableSend
|
||||
true, // autoGroup
|
||||
true, // preACK
|
||||
ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, // loadBalancingClassName
|
||||
1, // transactionBatchSize
|
||||
1, // dupsOKBatchSize
|
||||
true, // useGlobalPools
|
||||
1, // scheduleThreadPoolSize
|
||||
1, // threadPoolMaxSize
|
||||
1, // retryInterval
|
||||
1, // retryIntervalMultiplier
|
||||
1, // maxRetryInterval
|
||||
1, // reconnectAttempts
|
||||
true, // failoverOnInitialConnection
|
||||
"tst"); // groupID
|
||||
|
||||
ActiveMQQueueConnectionFactory cf = (ActiveMQQueueConnectionFactory) context.lookup("tst");
|
||||
|
||||
Assert.assertEquals(true, cf.isHA());
|
||||
Assert.assertEquals("tst", cf.getClientID());
|
||||
Assert.assertEquals(1, cf.getClientFailureCheckPeriod());
|
||||
Assert.assertEquals(1, cf.getConnectionTTL());
|
||||
Assert.assertEquals(1, cf.getCallTimeout());
|
||||
Assert.assertEquals(1, cf.getCallFailoverTimeout());
|
||||
Assert.assertEquals(1, cf.getMinLargeMessageSize());
|
||||
Assert.assertEquals(true, cf.isCompressLargeMessage());
|
||||
Assert.assertEquals(1, cf.getConsumerWindowSize());
|
||||
Assert.assertEquals(1, cf.getConfirmationWindowSize());
|
||||
Assert.assertEquals(1, cf.getProducerWindowSize());
|
||||
Assert.assertEquals(1, cf.getProducerMaxRate());
|
||||
Assert.assertEquals(true, cf.isBlockOnAcknowledge());
|
||||
Assert.assertEquals(true, cf.isBlockOnDurableSend());
|
||||
Assert.assertEquals(true, cf.isBlockOnNonDurableSend());
|
||||
Assert.assertEquals(true, cf.isAutoGroup());
|
||||
Assert.assertEquals(true, cf.isPreAcknowledge());
|
||||
Assert.assertEquals(ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME, cf.getConnectionLoadBalancingPolicyClassName());
|
||||
Assert.assertEquals(1, cf.getTransactionBatchSize());
|
||||
Assert.assertEquals(1, cf.getDupsOKBatchSize());
|
||||
Assert.assertEquals(true, cf.isUseGlobalPools());
|
||||
Assert.assertEquals(1, cf.getScheduledThreadPoolMaxSize());
|
||||
Assert.assertEquals(1, cf.getThreadPoolMaxSize());
|
||||
Assert.assertEquals(1, cf.getRetryInterval());
|
||||
Assert.assertEquals(1.0, cf.getRetryIntervalMultiplier(), 0.000001);
|
||||
Assert.assertEquals(1, cf.getMaxRetryInterval());
|
||||
Assert.assertEquals(1, cf.getReconnectAttempts());
|
||||
Assert.assertEquals(true, cf.isFailoverOnInitialConnection());
|
||||
Assert.assertEquals("tst", cf.getGroupID());
|
||||
|
||||
}
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// JMSServerControlTest overrides --------------------------------
|
||||
@Override
|
||||
protected int getNumberOfConsumers() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(InVMConnectorFactory.class.getName()));
|
||||
connection = cf.createQueueConnection();
|
||||
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
connection.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JMSServerControl createManagementControl() throws Exception {
|
||||
ActiveMQQueue managementQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue("activemq.management");
|
||||
final JMSMessagingProxy proxy = new JMSMessagingProxy(session, managementQueue, ResourceNames.JMS_SERVER);
|
||||
|
||||
return new JMSServerControl() {
|
||||
|
||||
@Override
|
||||
public boolean closeConnectionsForAddress(final String ipAddress) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("closeConnectionsForAddress", ipAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConsumerConnectionsForAddress(final String address) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("closeConsumerConnectionsForAddress", address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConnectionsForUser(final String userName) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("closeConnectionsForUser", userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(final String name) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createQueue", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(String name, String jndiBindings, String selector) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createQueue", name, jndiBindings, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(String name,
|
||||
String jndiBindings,
|
||||
String selector,
|
||||
boolean durable) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createQueue", name, jndiBindings, selector, durable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createTopic(final String name) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createTopic", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyConnectionFactory(final String name) throws Exception {
|
||||
proxy.invokeOperation("destroyConnectionFactory", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyQueue(final String name) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("destroyQueue", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyQueue(String name, boolean removeConsumers) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("destroyQueue", name, removeConsumers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyTopic(final String name) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("destroyTopic", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyTopic(final String name, boolean removeConsumers) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("destroyTopic", name, removeConsumers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return (String) proxy.retrieveAttributeValue("version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return (Boolean) proxy.retrieveAttributeValue("started");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() {
|
||||
return JMSServerControlUsingJMSTest.toStringArray((Object[]) proxy.retrieveAttributeValue("queueNames"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTopicNames() {
|
||||
return JMSServerControlUsingJMSTest.toStringArray((Object[]) proxy.retrieveAttributeValue("topicNames"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getConnectionFactoryNames() {
|
||||
return JMSServerControlUsingJMSTest.toStringArray((Object[]) proxy.retrieveAttributeValue("connectionFactoryNames"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listConnectionIDs() throws Exception {
|
||||
return (String[]) proxy.invokeOperation("listConnectionIDs");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listConnectionsAsJSON() throws Exception {
|
||||
return (String) proxy.invokeOperation("listConnectionsAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listConsumersAsJSON(String connectionID) throws Exception {
|
||||
return (String) proxy.invokeOperation("listConsumersAsJSON", connectionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listRemoteAddresses() throws Exception {
|
||||
return (String[]) proxy.invokeOperation("listRemoteAddresses");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listRemoteAddresses(final String ipAddress) throws Exception {
|
||||
return (String[]) proxy.invokeOperation("listRemoteAddresses", ipAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listSessions(final String connectionID) throws Exception {
|
||||
return (String[]) proxy.invokeOperation("listSessions", connectionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createQueue(String name, String jndiBinding) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createQueue", name, jndiBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createTopic(String name, String jndiBinding) throws Exception {
|
||||
return (Boolean) proxy.invokeOperation("createTopic", name, jndiBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listTargetDestinations(String sessionID) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastSentMessageID(String sessionID, String address) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionCreationTime(String sessionID) throws Exception {
|
||||
return (String) proxy.invokeOperation("getSessionCreationTime", sessionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listSessionsAsJSON(String connectionID) throws Exception {
|
||||
return (String) proxy.invokeOperation("listSessionsAsJSON", connectionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listPreparedTransactionDetailsAsJSON() throws Exception {
|
||||
return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listNetworkTopology() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listPreparedTransactionDetailsAsHTML() throws Exception {
|
||||
return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsHTML");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String[] connectorNames,
|
||||
Object[] bindings) throws Exception {
|
||||
proxy.invokeOperation("createConnectionFactory", name, ha, useDiscovery, cfType, connectorNames, bindings);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String connectors,
|
||||
String jndiBindings) throws Exception {
|
||||
proxy.invokeOperation("createConnectionFactory", name, ha, useDiscovery, cfType, connectors, jndiBindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listAllConsumersAsJSON() throws Exception {
|
||||
return (String) proxy.invokeOperation("listAllConsumersAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String[] connectors,
|
||||
String[] jndiBindings,
|
||||
String clientID,
|
||||
long clientFailureCheckPeriod,
|
||||
long connectionTTL,
|
||||
long callTimeout,
|
||||
long callFailoverTimeout,
|
||||
int minLargeMessageSize,
|
||||
boolean compressLargeMessages,
|
||||
int consumerWindowSize,
|
||||
int consumerMaxRate,
|
||||
int confirmationWindowSize,
|
||||
int producerWindowSize,
|
||||
int producerMaxRate,
|
||||
boolean blockOnAcknowledge,
|
||||
boolean blockOnDurableSend,
|
||||
boolean blockOnNonDurableSend,
|
||||
boolean autoGroup,
|
||||
boolean preAcknowledge,
|
||||
String loadBalancingPolicyClassName,
|
||||
int transactionBatchSize,
|
||||
int dupsOKBatchSize,
|
||||
boolean useGlobalPools,
|
||||
int scheduledThreadPoolMaxSize,
|
||||
int threadPoolMaxSize,
|
||||
long retryInterval,
|
||||
double retryIntervalMultiplier,
|
||||
long maxRetryInterval,
|
||||
int reconnectAttempts,
|
||||
boolean failoverOnInitialConnection,
|
||||
String groupId) throws Exception {
|
||||
proxy.invokeOperation("createConnectionFactory", name, ha, useDiscovery, cfType, connectors, jndiBindings, clientID, clientFailureCheckPeriod, connectionTTL, callTimeout, callFailoverTimeout, minLargeMessageSize, compressLargeMessages, consumerWindowSize, consumerMaxRate, confirmationWindowSize, producerWindowSize, producerMaxRate, blockOnAcknowledge, blockOnDurableSend, blockOnNonDurableSend, autoGroup, preAcknowledge, loadBalancingPolicyClassName, transactionBatchSize, dupsOKBatchSize, useGlobalPools, scheduledThreadPoolMaxSize, threadPoolMaxSize, retryInterval, retryIntervalMultiplier, maxRetryInterval, reconnectAttempts, failoverOnInitialConnection, groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createConnectionFactory(String name,
|
||||
boolean ha,
|
||||
boolean useDiscovery,
|
||||
int cfType,
|
||||
String connectors,
|
||||
String jndiBindings,
|
||||
String clientID,
|
||||
long clientFailureCheckPeriod,
|
||||
long connectionTTL,
|
||||
long callTimeout,
|
||||
long callFailoverTimeout,
|
||||
int minLargeMessageSize,
|
||||
boolean compressLargeMessages,
|
||||
int consumerWindowSize,
|
||||
int consumerMaxRate,
|
||||
int confirmationWindowSize,
|
||||
int producerWindowSize,
|
||||
int producerMaxRate,
|
||||
boolean blockOnAcknowledge,
|
||||
boolean blockOnDurableSend,
|
||||
boolean blockOnNonDurableSend,
|
||||
boolean autoGroup,
|
||||
boolean preAcknowledge,
|
||||
String loadBalancingPolicyClassName,
|
||||
int transactionBatchSize,
|
||||
int dupsOKBatchSize,
|
||||
boolean useGlobalPools,
|
||||
int scheduledThreadPoolMaxSize,
|
||||
int threadPoolMaxSize,
|
||||
long retryInterval,
|
||||
double retryIntervalMultiplier,
|
||||
long maxRetryInterval,
|
||||
int reconnectAttempts,
|
||||
boolean failoverOnInitialConnection,
|
||||
String groupId) throws Exception {
|
||||
proxy.invokeOperation("createConnectionFactory", name, ha, useDiscovery, cfType, connectors, jndiBindings, clientID, clientFailureCheckPeriod, connectionTTL, callTimeout, callFailoverTimeout, minLargeMessageSize, compressLargeMessages, consumerWindowSize, consumerMaxRate, confirmationWindowSize, producerWindowSize, producerMaxRate, blockOnAcknowledge, blockOnDurableSend, blockOnNonDurableSend, autoGroup, preAcknowledge, loadBalancingPolicyClassName, transactionBatchSize, dupsOKBatchSize, useGlobalPools, scheduledThreadPoolMaxSize, threadPoolMaxSize, retryInterval, retryIntervalMultiplier, maxRetryInterval, reconnectAttempts, failoverOnInitialConnection, groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeConnectionWithClientID(String clientID) throws Exception {
|
||||
return (String) proxy.invokeOperation("closeConnectionWithClientID", clientID);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
|
@ -20,7 +20,8 @@ import javax.jms.Connection;
|
|||
import javax.jms.Session;
|
||||
import javax.jms.Topic;
|
||||
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.util.JMSClusteredTestBase;
|
||||
import org.junit.Test;
|
||||
|
@ -49,11 +50,13 @@ public class TopicControlClusterTest extends JMSClusteredTestBase {
|
|||
Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
session2.createDurableSubscriber(topic2, "sub2");
|
||||
|
||||
TopicControl topicControl1 = ManagementControlHelper.createTopicControl(topic1, mBeanServer1);
|
||||
TopicControl topicControl2 = ManagementControlHelper.createTopicControl(topic2, mBeanServer2);
|
||||
SimpleString add1 = new SimpleString(topic1.getTopicName());
|
||||
SimpleString add2 = new SimpleString(topic2.getTopicName());
|
||||
AddressControl topicControl1 = ManagementControlHelper.createAddressControl(add1, mBeanServer1);
|
||||
AddressControl topicControl2 = ManagementControlHelper.createAddressControl(add2, mBeanServer2);
|
||||
|
||||
assertEquals(2, topicControl1.getSubscriptionCount());
|
||||
assertEquals(1, topicControl2.getSubscriptionCount());
|
||||
assertEquals(2, topicControl1.getQueueNames().length);
|
||||
assertEquals(1, topicControl2.getQueueNames().length);
|
||||
} finally {
|
||||
conn1.close();
|
||||
conn2.close();
|
||||
|
|
|
@ -1,669 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.JMSContext;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.jms.TopicSubscriber;
|
||||
import javax.json.JsonArray;
|
||||
import javax.management.Notification;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.SubscriptionInfo;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.postoffice.Binding;
|
||||
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
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.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TopicControlTest extends ManagementTestBase {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl serverManager;
|
||||
|
||||
private String clientID;
|
||||
|
||||
private String subscriptionName;
|
||||
|
||||
protected ActiveMQTopic topic;
|
||||
|
||||
private String topicBinding = "/topic/" + RandomUtil.randomString();
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void testGetAttributes() throws Exception {
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(topic.getTopicName(), topicControl.getName());
|
||||
Assert.assertEquals(topic.getAddress(), topicControl.getAddress());
|
||||
Assert.assertEquals(topic.isTemporary(), topicControl.isTemporary());
|
||||
Object[] bindings = topicControl.getRegistryBindings();
|
||||
Assert.assertEquals(1, bindings.length);
|
||||
Assert.assertEquals(topicBinding, bindings[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXXXSubscriptionsCount() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
Assert.assertEquals(3, topicControl.getSubscriptionCount());
|
||||
Assert.assertEquals(1, topicControl.getNonDurableSubscriptionCount());
|
||||
Assert.assertEquals(2, topicControl.getDurableSubscriptionCount());
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXXXMessagesCount() throws Exception {
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "_2", subscriptionName + "2");
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(0, topicControl.getMessageCount());
|
||||
Assert.assertEquals(0, topicControl.getNonDurableMessageCount());
|
||||
Assert.assertEquals(0, topicControl.getDurableMessageCount());
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
waitForMessageCount(3 * 2, topicControl, 3000);
|
||||
waitForNonDurableMessageCount(1 * 2, topicControl, 3000);
|
||||
waitForDurableMessageCount(2 * 2, topicControl, 3000);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListXXXSubscriptionsCount() throws Exception {
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons = JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
TopicSubscriber subs1 = JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
TopicSubscriber subs2 = JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
Assert.assertEquals(3, topicControl.listAllSubscriptions().length);
|
||||
Assert.assertEquals(1, topicControl.listNonDurableSubscriptions().length);
|
||||
Assert.assertEquals(2, topicControl.listDurableSubscriptions().length);
|
||||
|
||||
String json = topicControl.listAllSubscriptionsAsJSON();
|
||||
System.out.println("Json: " + json);
|
||||
JsonArray jsonArray = JsonUtil.readJsonArray(json);
|
||||
|
||||
Assert.assertEquals(3, jsonArray.size());
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListXXXSubscriptionsAsJSON() throws Exception {
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
String jsonString = topicControl.listDurableSubscriptionsAsJSON();
|
||||
SubscriptionInfo[] infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(2, infos.length);
|
||||
List<String> expectedClientIds = Arrays.asList(clientID, clientID + "2");
|
||||
List<String> expectedSubscriptionNames = Arrays.asList(subscriptionName, subscriptionName + "2");
|
||||
|
||||
Assert.assertTrue(expectedClientIds.contains(infos[0].getClientID()));
|
||||
Assert.assertTrue(expectedSubscriptionNames.contains(infos[0].getName()));
|
||||
|
||||
Assert.assertTrue(expectedClientIds.contains(infos[1].getClientID()));
|
||||
Assert.assertTrue(expectedSubscriptionNames.contains(infos[1].getName()));
|
||||
|
||||
jsonString = topicControl.listNonDurableSubscriptionsAsJSON();
|
||||
infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(1, infos.length);
|
||||
Assert.assertNull(infos[0].getClientID());
|
||||
Assert.assertNull(infos[0].getName());
|
||||
|
||||
jsonString = topicControl.listAllSubscriptionsAsJSON();
|
||||
infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(3, infos.length);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListXXXSubscriptionsAsJSONJMS2() throws Exception {
|
||||
ConnectionFactory cf = JMSUtil.createFactory(InVMConnectorFactory.class.getName(), ActiveMQClient.DEFAULT_CONNECTION_TTL_INVM, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD_INVM);
|
||||
JMSContext jmsContext1 = cf.createContext();
|
||||
jmsContext1.createSharedDurableConsumer(topic, subscriptionName, null);
|
||||
JMSContext jmsContext2 = cf.createContext();
|
||||
jmsContext2.createSharedDurableConsumer(topic, subscriptionName + "2", null);
|
||||
JMSContext jmsContext3 = cf.createContext();
|
||||
jmsContext3.createConsumer(topic);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
String jsonString = topicControl.listDurableSubscriptionsAsJSON();
|
||||
SubscriptionInfo[] infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(2, infos.length);
|
||||
|
||||
Assert.assertNull(infos[0].getClientID());
|
||||
Assert.assertTrue(infos[0].getName().equals(subscriptionName));
|
||||
|
||||
Assert.assertNull(infos[1].getClientID());
|
||||
Assert.assertTrue(infos[1].getName().equals(subscriptionName + "2"));
|
||||
|
||||
jsonString = topicControl.listNonDurableSubscriptionsAsJSON();
|
||||
infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(1, infos.length);
|
||||
Assert.assertNull(infos[0].getClientID());
|
||||
Assert.assertNull(infos[0].getName());
|
||||
|
||||
jsonString = topicControl.listAllSubscriptionsAsJSON();
|
||||
infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(3, infos.length);
|
||||
|
||||
jmsContext1.close();
|
||||
jmsContext2.close();
|
||||
jmsContext3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSubscriptionsAsJSONWithHierarchicalTopics() throws Exception {
|
||||
// there are no entries in mappings and nameMap in postOffice.addressManager; something isn't creating them as expected
|
||||
serverManager.createTopic(false, "my.jms.#", "jms/all");
|
||||
serverManager.createTopic(false, "my.jms.A", "jms/A");
|
||||
ActiveMQTopic myTopic = (ActiveMQTopic) ActiveMQJMSClient.createTopic("my.jms.A");
|
||||
|
||||
TopicControl topicControl = ManagementControlHelper.createTopicControl(myTopic, mbeanServer);
|
||||
String jsonString = topicControl.listDurableSubscriptionsAsJSON();
|
||||
SubscriptionInfo[] infos = SubscriptionInfo.from(jsonString);
|
||||
Assert.assertEquals(1, infos.length);
|
||||
Assert.assertEquals("", infos[0].getClientID());
|
||||
Assert.assertEquals("", infos[0].getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForSubscription() throws Exception {
|
||||
String key = "key";
|
||||
long matchingValue = RandomUtil.randomLong();
|
||||
long unmatchingValue = matchingValue + 1;
|
||||
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, unmatchingValue);
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
|
||||
|
||||
for (Binding binding : server.getPostOffice().getBindingsForAddress(topic.getSimpleAddress()).getBindings()) {
|
||||
((LocalQueueBinding) binding).getQueue().flushExecutor();
|
||||
}
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(3, topicControl.getMessageCount());
|
||||
|
||||
Assert.assertEquals(2, topicControl.countMessagesForSubscription(clientID, subscriptionName, key + " =" +
|
||||
matchingValue));
|
||||
Assert.assertEquals(1, topicControl.countMessagesForSubscription(clientID, subscriptionName, key + " =" +
|
||||
unmatchingValue));
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForUnknownSubscription() throws Exception {
|
||||
String unknownSubscription = RandomUtil.randomString();
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
try {
|
||||
topicControl.countMessagesForSubscription(clientID, unknownSubscription, null);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForUnknownClientID() throws Exception {
|
||||
String unknownClientID = RandomUtil.randomString();
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
try {
|
||||
topicControl.countMessagesForSubscription(unknownClientID, subscriptionName, null);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropDurableSubscriptionWithExistingSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
Assert.assertEquals(1, topicControl.getDurableSubscriptionCount());
|
||||
|
||||
connection.close();
|
||||
|
||||
topicControl.dropDurableSubscription(clientID, subscriptionName);
|
||||
|
||||
Assert.assertEquals(0, topicControl.getDurableSubscriptionCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropDurableSubscriptionWithUnknownSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
Assert.assertEquals(1, topicControl.getDurableSubscriptionCount());
|
||||
|
||||
try {
|
||||
topicControl.dropDurableSubscription(clientID, "this subscription does not exist");
|
||||
Assert.fail("should throw an exception");
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, topicControl.getDurableSubscriptionCount());
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropAllSubscriptions() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
connection_1.setClientID(clientID);
|
||||
Session sess1 = connection_1.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
TopicSubscriber durableSubscriber_1 = sess1.createDurableSubscriber(topic, subscriptionName);
|
||||
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
connection_2.setClientID(clientID + "2");
|
||||
Session sess2 = connection_1.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
TopicSubscriber durableSubscriber_2 = sess2.createDurableSubscriber(topic, subscriptionName + "2");
|
||||
|
||||
connection_1.start();
|
||||
connection_2.start();
|
||||
|
||||
Session sess = connection_1.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
MessageProducer prod = sess.createProducer(topic);
|
||||
|
||||
TextMessage msg1 = sess.createTextMessage("tst1");
|
||||
prod.send(msg1);
|
||||
|
||||
Assert.assertNotNull(durableSubscriber_1.receive(5000));
|
||||
Assert.assertNotNull(durableSubscriber_2.receive(5000));
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(2, topicControl.getSubscriptionCount());
|
||||
topicControl.dropAllSubscriptions();
|
||||
|
||||
Assert.assertEquals(0, topicControl.getSubscriptionCount());
|
||||
|
||||
connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
connection_1.setClientID(clientID);
|
||||
sess = connection_1.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
prod = sess.createProducer(topic);
|
||||
TextMessage msg2 = sess.createTextMessage("tst2");
|
||||
prod.send(msg2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAllMessages() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_1, topic, clientID, subscriptionName);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
JMSUtil.sendMessages(topic, 3);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
waitForMessageCount(3 * 2, topicControl, 3000);
|
||||
|
||||
int removedCount = topicControl.removeMessages(null);
|
||||
Assert.assertEquals(3 * 2, removedCount);
|
||||
Assert.assertEquals(0, topicControl.getMessageCount());
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
JMSUtil.sendMessages(topic, 3);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
Map<String, Object>[] messages = topicControl.listMessagesForSubscription(ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, subscriptionName));
|
||||
Assert.assertEquals(3, messages.length);
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscriptionAsJSON() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
String[] ids = JMSUtil.sendMessages(topic, 3);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
String jsonString = topicControl.listMessagesForSubscriptionAsJSON(ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, subscriptionName));
|
||||
Assert.assertNotNull(jsonString);
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
Assert.assertEquals(3, array.size());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Assert.assertEquals(ids[i], array.getJsonObject(i).getString("JMSMessageID"));
|
||||
}
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscriptionWithUnknownClientID() throws Exception {
|
||||
String unknownClientID = RandomUtil.randomString();
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
try {
|
||||
topicControl.listMessagesForSubscription(ActiveMQDestination.createQueueNameForDurableSubscription(true, unknownClientID, subscriptionName));
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscriptionWithUnknownSubscription() throws Exception {
|
||||
String unknownSubscription = RandomUtil.randomString();
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
try {
|
||||
topicControl.listMessagesForSubscription(ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, unknownSubscription));
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessagesAdded() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(0, topicControl.getMessagesAdded());
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
waitForAddedMessageCount(3 * 2, topicControl, 3000);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessagesDelivering() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_1 = JMSUtil.createConsumer(connection_1, topic, Session.CLIENT_ACKNOWLEDGE);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_2 = JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName, Session.CLIENT_ACKNOWLEDGE);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_3 = JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2", Session.CLIENT_ACKNOWLEDGE);
|
||||
|
||||
TopicControl topicControl = createManagementControl();
|
||||
|
||||
Assert.assertEquals(0, topicControl.getDeliveringCount());
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
Assert.assertEquals(0, topicControl.getDeliveringCount());
|
||||
|
||||
connection_1.start();
|
||||
connection_2.start();
|
||||
connection_3.start();
|
||||
|
||||
Message msg_1 = null;
|
||||
Message msg_2 = null;
|
||||
Message msg_3 = null;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
msg_1 = cons_1.receive(5000);
|
||||
Assert.assertNotNull(msg_1);
|
||||
msg_2 = cons_2.receive(5000);
|
||||
Assert.assertNotNull(msg_2);
|
||||
msg_3 = cons_3.receive(5000);
|
||||
Assert.assertNotNull(msg_3);
|
||||
}
|
||||
|
||||
Assert.assertEquals(3 * 2, topicControl.getDeliveringCount());
|
||||
|
||||
msg_1.acknowledge();
|
||||
Assert.assertEquals(2 * 2, topicControl.getDeliveringCount());
|
||||
msg_2.acknowledge();
|
||||
Assert.assertEquals(1 * 2, topicControl.getDeliveringCount());
|
||||
msg_3.acknowledge();
|
||||
Assert.assertEquals(0, topicControl.getDeliveringCount());
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
//make sure notifications are always received no matter whether
|
||||
//a Topic is created via JMSServerControl or by JMSServerManager directly.
|
||||
@Test
|
||||
public void testCreateTopicNotification() throws Exception {
|
||||
JMSUtil.JMXListener listener = new JMSUtil.JMXListener();
|
||||
this.mbeanServer.addNotificationListener(ObjectNameBuilder.DEFAULT.getJMSServerObjectName(), listener, null, null);
|
||||
|
||||
List<String> connectors = new ArrayList<>();
|
||||
connectors.add("invm");
|
||||
|
||||
String testTopicName = "newTopic";
|
||||
serverManager.createTopic(true, testTopicName, testTopicName);
|
||||
|
||||
Notification notif = listener.getNotification();
|
||||
|
||||
Assert.assertEquals(JMSNotificationType.TOPIC_CREATED.toString(), notif.getType());
|
||||
Assert.assertEquals(testTopicName, notif.getMessage());
|
||||
|
||||
this.serverManager.destroyTopic(testTopicName);
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.TOPIC_DESTROYED.toString(), notif.getType());
|
||||
Assert.assertEquals(testTopicName, notif.getMessage());
|
||||
|
||||
JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer);
|
||||
|
||||
control.createTopic(testTopicName);
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.TOPIC_CREATED.toString(), notif.getType());
|
||||
Assert.assertEquals(testTopicName, notif.getMessage());
|
||||
|
||||
control.destroyTopic(testTopicName);
|
||||
|
||||
notif = listener.getNotification();
|
||||
Assert.assertEquals(JMSNotificationType.TOPIC_DESTROYED.toString(), notif.getType());
|
||||
Assert.assertEquals(testTopicName, notif.getMessage());
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
|
||||
server.start();
|
||||
|
||||
serverManager = new JMSServerManagerImpl(server);
|
||||
serverManager.start();
|
||||
serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
|
||||
serverManager.activated();
|
||||
|
||||
clientID = RandomUtil.randomString();
|
||||
subscriptionName = RandomUtil.randomString();
|
||||
|
||||
String topicName = RandomUtil.randomString();
|
||||
serverManager.createTopic(false, topicName, topicBinding);
|
||||
topic = (ActiveMQTopic) ActiveMQJMSClient.createTopic(topicName);
|
||||
}
|
||||
|
||||
protected TopicControl createManagementControl() throws Exception {
|
||||
return ManagementControlHelper.createTopicControl(topic, mbeanServer);
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
private void waitForMessageCount(long expected, TopicControl topicControl, long timeout) throws Exception {
|
||||
long timeToWait = System.currentTimeMillis() + timeout;
|
||||
|
||||
while (System.currentTimeMillis() < timeToWait) {
|
||||
if (expected == topicControl.getMessageCount()) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertEquals(expected, topicControl.getMessageCount());
|
||||
}
|
||||
|
||||
private void waitForNonDurableMessageCount(long expected, TopicControl topicControl, long timeout) throws Exception {
|
||||
long timeToWait = System.currentTimeMillis() + timeout;
|
||||
|
||||
while (System.currentTimeMillis() < timeToWait) {
|
||||
if (expected == topicControl.getNonDurableMessageCount()) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertEquals(expected, topicControl.getNonDurableMessageCount());
|
||||
}
|
||||
|
||||
private void waitForDurableMessageCount(long expected, TopicControl topicControl, long timeout) throws Exception {
|
||||
long timeToWait = System.currentTimeMillis() + timeout;
|
||||
|
||||
while (System.currentTimeMillis() < timeToWait) {
|
||||
if (expected == topicControl.getDurableMessageCount()) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertEquals(expected, topicControl.getDurableMessageCount());
|
||||
}
|
||||
|
||||
private void waitForAddedMessageCount(long expected, TopicControl topicControl, long timeout) throws Exception {
|
||||
long timeToWait = System.currentTimeMillis() + timeout;
|
||||
|
||||
while (System.currentTimeMillis() < timeToWait) {
|
||||
if (expected == topicControl.getMessagesAdded()) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertEquals(expected, topicControl.getMessagesAdded());
|
||||
}
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
|
@ -1,436 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.server.management;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.TopicSubscriber;
|
||||
|
||||
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.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
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.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
|
||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString;
|
||||
|
||||
public class TopicControlUsingJMSTest extends ManagementTestBase {
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private ActiveMQServer server;
|
||||
|
||||
private JMSServerManagerImpl serverManager;
|
||||
|
||||
private String clientID;
|
||||
|
||||
private String subscriptionName;
|
||||
|
||||
protected ActiveMQTopic topic;
|
||||
|
||||
protected JMSMessagingProxy proxy;
|
||||
|
||||
private QueueConnection connection;
|
||||
|
||||
private QueueSession session;
|
||||
|
||||
private final String topicBinding = "/topic/" + randomString();
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void testGetAttributes() throws Exception {
|
||||
Assert.assertEquals(topic.getTopicName(), proxy.retrieveAttributeValue("name"));
|
||||
Assert.assertEquals(topic.getAddress(), proxy.retrieveAttributeValue("address"));
|
||||
Assert.assertEquals(topic.isTemporary(), proxy.retrieveAttributeValue("temporary"));
|
||||
Object[] bindings = (Object[]) proxy.retrieveAttributeValue("" + "RegistryBindings");
|
||||
assertEquals(1, bindings.length);
|
||||
Assert.assertEquals(topicBinding, bindings[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXXXSubscriptionsCount() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
Assert.assertEquals(3, proxy.retrieveAttributeValue("subscriptionCount", Integer.class));
|
||||
Assert.assertEquals(1, proxy.retrieveAttributeValue("nonDurableSubscriptionCount", Integer.class));
|
||||
Assert.assertEquals(2, proxy.retrieveAttributeValue("durableSubscriptionCount", Integer.class));
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXXXMessagesCount() throws Exception {
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
Assert.assertEquals(0L, proxy.retrieveAttributeValue("messageCount", Long.class));
|
||||
Assert.assertEquals(0, proxy.retrieveAttributeValue("nonDurableMessageCount", Integer.class));
|
||||
Assert.assertEquals(0, proxy.retrieveAttributeValue("durableMessageCount", Integer.class));
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
waitForAttributeEqualsValue("messageCount", 3L * 2L, 3000, Long.class);
|
||||
waitForAttributeEqualsValue("nonDurableMessageCount", 1 * 2, 3000, Integer.class);
|
||||
waitForAttributeEqualsValue("durableMessageCount", 2 * 2, 3000, Integer.class);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListXXXSubscriptionsCount() throws Exception {
|
||||
// 1 non-durable subscriber, 2 durable subscribers
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
Assert.assertEquals(3, ((Object[]) proxy.invokeOperation("listAllSubscriptions")).length);
|
||||
Assert.assertEquals(1, ((Object[]) proxy.invokeOperation("listNonDurableSubscriptions")).length);
|
||||
Assert.assertEquals(2, ((Object[]) proxy.invokeOperation("listDurableSubscriptions")).length);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForSubscription() throws Exception {
|
||||
String key = "key";
|
||||
long matchingValue = RandomUtil.randomLong();
|
||||
long unmatchingValue = matchingValue + 1;
|
||||
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, unmatchingValue);
|
||||
JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
|
||||
|
||||
waitForAttributeEqualsValue("messageCount", 3L, 3000, Long.class);
|
||||
|
||||
Assert.assertEquals(2, proxy.invokeOperation(Integer.class, "countMessagesForSubscription", clientID, subscriptionName, key + " =" +
|
||||
matchingValue));
|
||||
Assert.assertEquals(1, proxy.invokeOperation(Integer.class, "countMessagesForSubscription", clientID, subscriptionName, key + " =" +
|
||||
unmatchingValue));
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForUnknownSubscription() throws Exception {
|
||||
String unknownSubscription = RandomUtil.randomString();
|
||||
|
||||
try {
|
||||
proxy.invokeOperation("countMessagesForSubscription", clientID, unknownSubscription, null);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountMessagesForUnknownClientID() throws Exception {
|
||||
String unknownClientID = RandomUtil.randomString();
|
||||
|
||||
try {
|
||||
proxy.invokeOperation("countMessagesForSubscription", unknownClientID, subscriptionName, null);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropDurableSubscriptionWithExistingSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
Assert.assertEquals(1, proxy.retrieveAttributeValue("durableSubscriptionCount", Integer.class));
|
||||
|
||||
connection.close();
|
||||
|
||||
proxy.invokeOperation("dropDurableSubscription", clientID, subscriptionName);
|
||||
|
||||
Assert.assertEquals(0, proxy.retrieveAttributeValue("durableSubscriptionCount", Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropDurableSubscriptionWithUnknownSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
Assert.assertEquals(1, proxy.retrieveAttributeValue("durableSubscriptionCount", Integer.class));
|
||||
|
||||
try {
|
||||
proxy.invokeOperation("dropDurableSubscription", clientID, "this subscription does not exist");
|
||||
Assert.fail("should throw an exception");
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, proxy.retrieveAttributeValue("durableSubscriptionCount", Integer.class));
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDropAllSubscriptions() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
TopicSubscriber durableSubscriber_1 = JMSUtil.createDurableSubscriber(connection_1, topic, clientID, subscriptionName);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
TopicSubscriber durableSubscriber_2 = JMSUtil.createDurableSubscriber(connection_2, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
Assert.assertEquals(2, proxy.retrieveAttributeValue("subscriptionCount", Integer.class));
|
||||
|
||||
durableSubscriber_1.close();
|
||||
durableSubscriber_2.close();
|
||||
|
||||
Assert.assertEquals(2, proxy.retrieveAttributeValue("subscriptionCount", Integer.class));
|
||||
proxy.invokeOperation("dropAllSubscriptions");
|
||||
|
||||
Assert.assertEquals(0, proxy.retrieveAttributeValue("subscriptionCount", Integer.class));
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAllMessages() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_1, topic, clientID, subscriptionName);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
JMSUtil.sendMessages(topic, 3);
|
||||
|
||||
waitForAttributeEqualsValue("messageCount", 3L * 2L, 3000, Long.class);
|
||||
|
||||
int removedCount = (Integer) proxy.invokeOperation(Integer.class, "removeMessages", "");
|
||||
Assert.assertEquals(3 * 2, removedCount);
|
||||
Assert.assertEquals(0L, proxy.retrieveAttributeValue("messageCount", Long.class));
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscription() throws Exception {
|
||||
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
|
||||
JMSUtil.createDurableSubscriber(connection, topic, clientID, subscriptionName);
|
||||
|
||||
JMSUtil.sendMessages(topic, 3);
|
||||
|
||||
Object[] data = (Object[]) proxy.invokeOperation("listMessagesForSubscription", ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, subscriptionName));
|
||||
Assert.assertEquals(3, data.length);
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscriptionWithUnknownClientID() throws Exception {
|
||||
String unknownClientID = RandomUtil.randomString();
|
||||
|
||||
try {
|
||||
proxy.invokeOperation("listMessagesForSubscription", ActiveMQDestination.createQueueNameForDurableSubscription(true, unknownClientID, subscriptionName));
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListMessagesForSubscriptionWithUnknownSubscription() throws Exception {
|
||||
String unknownSubscription = RandomUtil.randomString();
|
||||
|
||||
try {
|
||||
proxy.invokeOperation("listMessagesForSubscription", ActiveMQDestination.createQueueNameForDurableSubscription(true, clientID, unknownSubscription));
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessagesAdded() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createConsumer(connection_1, topic);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2");
|
||||
|
||||
assertEquals(0, proxy.retrieveAttributeValue("messagesAdded", Integer.class));
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
waitForAttributeEqualsValue("messagesAdded", 3L * 2L, 3000, Long.class);
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessagesDelivering() throws Exception {
|
||||
Connection connection_1 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_1 = JMSUtil.createConsumer(connection_1, topic, Session.CLIENT_ACKNOWLEDGE);
|
||||
Connection connection_2 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_2 = JMSUtil.createDurableSubscriber(connection_2, topic, clientID, subscriptionName, Session.CLIENT_ACKNOWLEDGE);
|
||||
Connection connection_3 = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
|
||||
MessageConsumer cons_3 = JMSUtil.createDurableSubscriber(connection_3, topic, clientID + "2", subscriptionName + "2", Session.CLIENT_ACKNOWLEDGE);
|
||||
|
||||
assertEquals(0, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
|
||||
JMSUtil.sendMessages(topic, 2);
|
||||
|
||||
assertEquals(0, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
|
||||
connection_1.start();
|
||||
connection_2.start();
|
||||
connection_3.start();
|
||||
|
||||
Message msg_1 = null;
|
||||
Message msg_2 = null;
|
||||
Message msg_3 = null;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
msg_1 = cons_1.receive(5000);
|
||||
assertNotNull(msg_1);
|
||||
msg_2 = cons_2.receive(5000);
|
||||
assertNotNull(msg_2);
|
||||
msg_3 = cons_3.receive(5000);
|
||||
assertNotNull(msg_3);
|
||||
}
|
||||
|
||||
assertEquals(3 * 2, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
|
||||
msg_1.acknowledge();
|
||||
assertEquals(2 * 2, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
msg_2.acknowledge();
|
||||
assertEquals(1 * 2, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
msg_3.acknowledge();
|
||||
assertEquals(0, proxy.retrieveAttributeValue("deliveringCount", Integer.class));
|
||||
|
||||
connection_1.close();
|
||||
connection_2.close();
|
||||
connection_3.close();
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, false));
|
||||
server.start();
|
||||
|
||||
serverManager = new JMSServerManagerImpl(server);
|
||||
serverManager.start();
|
||||
serverManager.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
|
||||
serverManager.activated();
|
||||
|
||||
clientID = RandomUtil.randomString();
|
||||
subscriptionName = RandomUtil.randomString();
|
||||
|
||||
String topicName = RandomUtil.randomString();
|
||||
serverManager.createTopic(false, topicName, topicBinding);
|
||||
topic = (ActiveMQTopic) ActiveMQJMSClient.createTopic(topicName);
|
||||
|
||||
ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(INVM_CONNECTOR_FACTORY));
|
||||
connection = cf.createQueueConnection();
|
||||
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
connection.start();
|
||||
|
||||
ActiveMQQueue managementQueue = (ActiveMQQueue) ActiveMQJMSClient.createQueue("activemq.management");
|
||||
proxy = new JMSMessagingProxy(session, managementQueue, topic.getTopicName());
|
||||
}
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
private void waitForAttributeEqualsValue(String attribute, Object expected, long timeout) throws Exception {
|
||||
waitForAttributeEqualsValue(attribute, expected, timeout, null);
|
||||
}
|
||||
|
||||
private void waitForAttributeEqualsValue(String attribute,
|
||||
Object expected,
|
||||
long timeout,
|
||||
Class desiredType) throws Exception {
|
||||
long timeToWait = System.currentTimeMillis() + timeout;
|
||||
Object actual = null;
|
||||
|
||||
while (System.currentTimeMillis() < timeToWait) {
|
||||
actual = proxy.retrieveAttributeValue(attribute, desiredType);
|
||||
if (expected.equals(actual)) {
|
||||
return;
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
Assert.assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
}
|
|
@ -38,7 +38,7 @@ public class AcceptorControlUsingCoreTest extends AcceptorControlTest {
|
|||
protected AcceptorControl createManagementControl(final String name) throws Exception {
|
||||
return new AcceptorControl() {
|
||||
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_ACCEPTOR + name);
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.ACCEPTOR + name);
|
||||
|
||||
@Override
|
||||
public String getFactoryClassName() {
|
||||
|
|
|
@ -594,12 +594,12 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address));
|
||||
assertEquals(0, serverControl.getDivertNames().length);
|
||||
|
||||
serverControl.createDivert(name.toString(), null, address, forwardingAddress, true, null, null);
|
||||
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -611,13 +611,13 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address));
|
||||
assertEquals(0, serverControl.getDivertNames().length);
|
||||
|
||||
serverControl.createDivert(name.toString(), routingName, address, forwardingAddress, true, null, null);
|
||||
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
|
||||
DivertControl divertControl = ManagementControlHelper.createDivertControl(name.toString(), mbeanServer);
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address));
|
||||
DivertControl divertControl = ManagementControlHelper.createDivertControl(name.toString(), address, mbeanServer);
|
||||
assertEquals(name.toString(), divertControl.getUniqueName());
|
||||
assertEquals(address, divertControl.getAddress());
|
||||
assertEquals(forwardingAddress, divertControl.getForwardingAddress());
|
||||
|
@ -658,7 +658,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
|
||||
serverControl.destroyDivert(name.toString());
|
||||
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
|
||||
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address));
|
||||
assertEquals(0, serverControl.getDivertNames().length);
|
||||
|
||||
// check that a message is no longer diverted
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_SERVER);
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.BROKER);
|
||||
|
||||
@Override
|
||||
public boolean isSharedStore() {
|
||||
|
@ -98,6 +98,16 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
proxy.invokeOperation("createQueue", address, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name, @Parameter(name = "routingType", desc = "the routing type of the address either 0 for multicast or 1 for anycast") int routingType, @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers, @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
|
||||
proxy.invokeOperation("createAddress", name, routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception {
|
||||
proxy.invokeOperation("deleteAddress", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQueue(final String address,
|
||||
final String name,
|
||||
|
@ -268,6 +278,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
return (String) proxy.retrieveAttributeValue("largeMessagesDirectory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeID() {
|
||||
return (String) proxy.retrieveAttributeValue("nodeID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagementAddress() {
|
||||
return (String) proxy.retrieveAttributeValue("managementAddress");
|
||||
|
@ -611,6 +626,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
proxy.invokeOperation("addAddressSettings", addressMatch, DLA, expiryAddress, expiryDelay, lastValueQueue, deliveryAttempts, maxSizeBytes, pageSizeBytes, pageMaxCacheSize, redeliveryDelay, redeliveryMultiplier, maxRedeliveryDelay, redistributionDelay, sendToDLAOnNoRoute, addressFullMessagePolicy, slowConsumerThreshold, slowConsumerCheckPeriod, slowConsumerPolicy, autoCreateJmsQueues, autoDeleteJmsQueues, autoCreateJmsTopics, autoDeleteJmsTopics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listNetworkTopology() throws Exception {
|
||||
return (String) proxy.invokeOperation("listNetworkTopology");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAddressSettings(String addressMatch) throws Exception {
|
||||
proxy.invokeOperation("removeAddressSettings", addressMatch);
|
||||
|
|
|
@ -176,7 +176,7 @@ public class AddressControlUsingCoreTest extends ManagementTestBase {
|
|||
}
|
||||
|
||||
protected CoreMessagingProxy createProxy(final SimpleString address) throws Exception {
|
||||
CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_ADDRESS + address);
|
||||
CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.ADDRESS + address);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public class BridgeControlUsingCoreTest extends ManagementTestBase {
|
|||
}
|
||||
|
||||
protected CoreMessagingProxy createProxy(final String name) throws Exception {
|
||||
CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_BRIDGE + name);
|
||||
CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.BRIDGE + name);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BroadcastGroupControlUsingCoreTest extends BroadcastGroupControlTes
|
|||
@Override
|
||||
protected BroadcastGroupControl createManagementControl(final String name) throws Exception {
|
||||
return new BroadcastGroupControl() {
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_BROADCAST_GROUP + name);
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.BROADCAST_GROUP + name);
|
||||
|
||||
@Override
|
||||
public long getBroadcastPeriod() {
|
||||
|
|
|
@ -45,9 +45,9 @@ public class DivertControlTest extends ManagementTestBase {
|
|||
|
||||
@Test
|
||||
public void testAttributes() throws Exception {
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(divertConfig.getName()));
|
||||
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(divertConfig.getName(), divertConfig.getAddress()));
|
||||
|
||||
DivertControl divertControl = createManagementControl(divertConfig.getName());
|
||||
DivertControl divertControl = createDivertManagementControl(divertConfig.getName(), divertConfig.getAddress());
|
||||
|
||||
Assert.assertEquals(divertConfig.getFilterString(), divertControl.getFilter());
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class DivertControlTest extends ManagementTestBase {
|
|||
server.start();
|
||||
}
|
||||
|
||||
protected DivertControl createManagementControl(final String name) throws Exception {
|
||||
return ManagementControlHelper.createDivertControl(name, mbeanServer);
|
||||
protected DivertControl createDivertManagementControl(final String name, final String address) throws Exception {
|
||||
return ManagementControlHelper.createDivertControl(name, address, mbeanServer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ public class DivertControlUsingCoreTest extends DivertControlTest {
|
|||
// DivertControlTest overrides --------------------------------
|
||||
|
||||
@Override
|
||||
protected DivertControl createManagementControl(final String name) throws Exception {
|
||||
protected DivertControl createDivertManagementControl(final String name, final String address) throws Exception {
|
||||
return new DivertControl() {
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_DIVERT + name);
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.DIVERT + name);
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.management;
|
||||
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.Topic;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
@ -32,10 +30,6 @@ import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl;
|
|||
import org.apache.activemq.artemis.api.core.management.DivertControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.ConnectionFactoryControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
|
||||
public class ManagementControlHelper {
|
||||
|
||||
|
@ -59,8 +53,8 @@ public class ManagementControlHelper {
|
|||
return (BridgeControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getBridgeObjectName(name), BridgeControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static DivertControl createDivertControl(final String name, final MBeanServer mbeanServer) throws Exception {
|
||||
return (DivertControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getDivertObjectName(name), DivertControl.class, mbeanServer);
|
||||
public static DivertControl createDivertControl(final String name, String address, final MBeanServer mbeanServer) throws Exception {
|
||||
return (DivertControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getDivertObjectName(name, address), DivertControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static ClusterConnectionControl createClusterConnectionControl(final String name,
|
||||
|
@ -83,29 +77,6 @@ public class ManagementControlHelper {
|
|||
return (AddressControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getAddressObjectName(address), AddressControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static JMSQueueControl createJMSQueueControl(final Queue queue,
|
||||
final MBeanServer mbeanServer) throws Exception {
|
||||
return ManagementControlHelper.createJMSQueueControl(queue.getQueueName(), mbeanServer);
|
||||
}
|
||||
|
||||
public static JMSQueueControl createJMSQueueControl(final String name,
|
||||
final MBeanServer mbeanServer) throws Exception {
|
||||
return (JMSQueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(name), JMSQueueControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static JMSServerControl createJMSServerControl(final MBeanServer mbeanServer) throws Exception {
|
||||
return (JMSServerControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getJMSServerObjectName(), JMSServerControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static ConnectionFactoryControl createConnectionFactoryControl(final String name,
|
||||
final MBeanServer mbeanServer) throws Exception {
|
||||
return (ConnectionFactoryControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getConnectionFactoryObjectName(name), ConnectionFactoryControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
public static TopicControl createTopicControl(final Topic topic, final MBeanServer mbeanServer) throws Exception {
|
||||
return (TopicControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topic.getTopicName()), TopicControl.class, mbeanServer);
|
||||
}
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
|||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
||||
import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl;
|
||||
import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager;
|
||||
|
@ -50,7 +51,7 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
|
|||
|
||||
// invoke attribute and operation on the server
|
||||
ServerMessage message = new ServerMessageImpl(1, 100);
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "createQueue", queue, address);
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "createQueue", queue, address);
|
||||
|
||||
ServerMessage reply = server.getManagementService().handleMessage(message);
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
|
|||
|
||||
// invoke attribute and operation on the server
|
||||
ServerMessage message = new ServerMessageImpl(1, 100);
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.CORE_SERVER, "thereIsNoSuchOperation");
|
||||
ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "thereIsNoSuchOperation");
|
||||
|
||||
ServerMessage reply = server.getManagementService().handleMessage(message);
|
||||
|
||||
|
@ -101,7 +102,7 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
|
|||
// invoke attribute and operation on the server
|
||||
ServerMessage message = new ServerMessageImpl(1, 100);
|
||||
|
||||
ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER, "started");
|
||||
ManagementHelper.putAttribute(message, ResourceNames.BROKER, "started");
|
||||
|
||||
ServerMessage reply = server.getManagementService().handleMessage(message);
|
||||
|
||||
|
@ -119,7 +120,7 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
|
|||
// invoke attribute and operation on the server
|
||||
ServerMessage message = new ServerMessageImpl(1, 100);
|
||||
|
||||
ManagementHelper.putAttribute(message, ResourceNames.CORE_SERVER, "attribute.Does.Not.Exist");
|
||||
ManagementHelper.putAttribute(message, ResourceNames.BROKER, "attribute.Does.Not.Exist");
|
||||
|
||||
ServerMessage reply = server.getManagementService().handleMessage(message);
|
||||
|
||||
|
@ -134,7 +135,7 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
|
|||
managementService.setStorageManager(new NullStorageManager());
|
||||
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
managementService.registerAddress(address);
|
||||
managementService.registerAddress(new AddressInfo(address));
|
||||
Queue queue = new FakeQueue(RandomUtil.randomSimpleString());
|
||||
managementService.registerQueue(queue, RandomUtil.randomSimpleString(), new FakeStorageManager());
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.activemq.artemis.api.core.client.ClientConsumer;
|
|||
import org.apache.activemq.artemis.api.core.client.ClientMessage;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -105,16 +104,6 @@ public abstract class ManagementTestBase extends ActiveMQTestBase {
|
|||
return queueControl;
|
||||
}
|
||||
|
||||
protected long getMessageCount(JMSQueueControl control) throws Exception {
|
||||
control.flushExecutor();
|
||||
return control.getMessageCount();
|
||||
}
|
||||
|
||||
protected long getMessagesAdded(JMSQueueControl control) throws Exception {
|
||||
control.flushExecutor();
|
||||
return control.getMessagesAdded();
|
||||
}
|
||||
|
||||
protected long getMessageCount(QueueControl control) throws Exception {
|
||||
control.flushExecutor();
|
||||
return control.getMessageCount();
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
package org.apache.activemq.artemis.tests.integration.management;
|
||||
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonValue;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||
|
@ -35,6 +39,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
|||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.apache.johnzon.core.JsonLongImpl;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -79,7 +84,16 @@ public class ManagementWithPagingServerTest extends ManagementTestBase {
|
|||
String result = queueControl.listMessagesAsJSON(null);
|
||||
|
||||
JsonArray array = JsonUtil.readJsonArray(result);
|
||||
|
||||
List<Long> longs = new ArrayList<>();
|
||||
for (JsonValue jsonValue : array) {
|
||||
JsonValue val = ((JsonObject) jsonValue).get("messageID");
|
||||
Long l = ((JsonLongImpl) val).longValue();
|
||||
if (longs.contains(l)) {
|
||||
System.out.println("ManagementWithPagingServerTest.testListMessagesAsJSON");
|
||||
}
|
||||
longs.add(l);
|
||||
System.out.println("jsonValue = " + jsonValue);
|
||||
}
|
||||
assertEquals(num, array.size());
|
||||
|
||||
//kick off receiver
|
||||
|
@ -235,6 +249,7 @@ public class ManagementWithPagingServerTest extends ManagementTestBase {
|
|||
|
||||
for (int i = 0; i < num; i++) {
|
||||
ClientMessage message = session1.createMessage(true);
|
||||
message.setPriority((byte) 1);
|
||||
ActiveMQBuffer buffer = message.getBodyBuffer();
|
||||
buffer.writeBytes(body);
|
||||
producer.send(message);
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ManagementWithStompTest extends ManagementTestBase {
|
|||
// retrieve the address of the queue
|
||||
frame = "\nSEND\n" + "destination:" + ActiveMQDefaultConfiguration.getDefaultManagementAddress() + "\n" +
|
||||
"reply-to:" + address + "\n" +
|
||||
"_AMQ_ResourceName:" + ResourceNames.CORE_QUEUE + queue + "\n" +
|
||||
"_AMQ_ResourceName:" + ResourceNames.QUEUE + queue + "\n" +
|
||||
"_AMQ_Attribute: Address\n\n" +
|
||||
Stomp.NULL;
|
||||
sendFrame(frame);
|
||||
|
@ -129,7 +129,7 @@ public class ManagementWithStompTest extends ManagementTestBase {
|
|||
// count number of message with filter "color = 'blue'"
|
||||
frame = "\nSEND\n" + "destination:" + ActiveMQDefaultConfiguration.getDefaultManagementAddress() + "\n" +
|
||||
"reply-to:" + address + "\n" +
|
||||
"_AMQ_ResourceName:" + ResourceNames.CORE_QUEUE + queue + "\n" +
|
||||
"_AMQ_ResourceName:" + ResourceNames.QUEUE + queue + "\n" +
|
||||
"_AMQ_OperationName: countMessages\n\n" +
|
||||
"[\"color = 'blue'\"]" +
|
||||
Stomp.NULL;
|
||||
|
|
|
@ -2108,7 +2108,7 @@ public class QueueControlTest extends ManagementTestBase {
|
|||
|
||||
QueueControl queueControl = createManagementControl(address, queue);
|
||||
|
||||
queueControl.sendMessage(new HashMap<String, String>(), Message.TEXT_TYPE, Base64.encodeBytes("theBody".getBytes()), "myID", true, "myUser", "myPassword");
|
||||
queueControl.sendMessage(new HashMap<String, String>(), Message.TEXT_TYPE, Base64.encodeBytes("theBody".getBytes()), true, "myUser", "myPassword");
|
||||
|
||||
Assert.assertEquals(1, getMessageCount(queueControl));
|
||||
|
||||
|
@ -2133,7 +2133,7 @@ public class QueueControlTest extends ManagementTestBase {
|
|||
|
||||
QueueControl queueControl = createManagementControl(address, queue);
|
||||
|
||||
queueControl.sendMessage(new HashMap<String, String>(), Message.TEXT_TYPE, null, "myID", true, "myUser", "myPassword");
|
||||
queueControl.sendMessage(new HashMap<String, String>(), Message.TEXT_TYPE, null, true, "myUser", "myPassword");
|
||||
|
||||
Assert.assertEquals(1, getMessageCount(queueControl));
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
|
|||
protected QueueControl createManagementControl(final SimpleString address,
|
||||
final SimpleString queue) throws Exception {
|
||||
return new QueueControl() {
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.CORE_QUEUE + queue);
|
||||
private final CoreMessagingProxy proxy = new CoreMessagingProxy(addServerLocator(createInVMNonHALocator()), ResourceNames.QUEUE + queue);
|
||||
|
||||
@Override
|
||||
public void flushExecutor() {
|
||||
|
@ -316,11 +316,10 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
|
|||
public String sendMessage(Map<String, String> headers,
|
||||
int type,
|
||||
String body,
|
||||
String userID,
|
||||
boolean durable,
|
||||
String user,
|
||||
String password) throws Exception {
|
||||
return (String) proxy.invokeOperation("sendMessage", headers, type, body, userID, durable, user, password);
|
||||
return (String) proxy.invokeOperation("sendMessage", headers, type, body, durable, user, password);
|
||||
}
|
||||
|
||||
public void setDeadLetterAddress(final String deadLetterAddress) throws Exception {
|
||||
|
@ -351,6 +350,17 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
|
|||
return (Boolean) proxy.invokeOperation("isPaused");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse() throws Exception {
|
||||
Map map = (Map) proxy.invokeOperation("browse");
|
||||
CompositeData[] compositeDatas = (CompositeData[]) map.get(CompositeData.class.getName());
|
||||
if (compositeDatas == null) {
|
||||
compositeDatas = new CompositeData[0];
|
||||
}
|
||||
return compositeDatas;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompositeData[] browse(String filter) throws Exception {
|
||||
Map map = (Map) proxy.invokeOperation("browse", filter);
|
||||
|
|
|
@ -75,7 +75,7 @@ public abstract class SecurityManagementTestBase extends ActiveMQTestBase {
|
|||
ClientRequestor requestor = new ClientRequestor(session, ActiveMQDefaultConfiguration.getDefaultManagementAddress());
|
||||
|
||||
ClientMessage mngmntMessage = session.createMessage(false);
|
||||
ManagementHelper.putAttribute(mngmntMessage, ResourceNames.CORE_SERVER, "started");
|
||||
ManagementHelper.putAttribute(mngmntMessage, ResourceNames.BROKER, "started");
|
||||
ClientMessage reply = requestor.request(mngmntMessage, 500);
|
||||
if (expectSuccess) {
|
||||
Assert.assertNotNull(reply);
|
||||
|
|
|
@ -26,7 +26,6 @@ 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.management.JMSServerControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
|
@ -36,7 +35,6 @@ import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfigurat
|
|||
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.integration.management.ManagementControlHelper;
|
||||
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.After;
|
||||
|
@ -143,10 +141,6 @@ public class OpenWireTestBase extends ActiveMQTestBase {
|
|||
jmsServer.createConnectionFactory(false, configuration, jndiBindings);
|
||||
}
|
||||
|
||||
protected JMSServerControl getJMSServerControl() throws Exception {
|
||||
return ManagementControlHelper.createJMSServerControl(mbeanServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
|
|
|
@ -36,7 +36,6 @@ import java.util.Set;
|
|||
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
|
@ -101,11 +100,6 @@ public class JMSTestBase extends ActiveMQTestBase {
|
|||
return createTopic(false, topicName);
|
||||
}
|
||||
|
||||
protected long getMessageCount(JMSQueueControl control) throws Exception {
|
||||
control.flushExecutor();
|
||||
return control.getMessageCount();
|
||||
}
|
||||
|
||||
protected long getMessageCount(QueueControl control) throws Exception {
|
||||
control.flushExecutor();
|
||||
return control.getMessageCount();
|
||||
|
|
|
@ -228,27 +228,6 @@ public abstract class ActiveMQServerTestCase {
|
|||
queue4 = (Queue) ic.lookup("/queue/Queue4");
|
||||
}
|
||||
|
||||
protected void undeployAdministeredObjects() throws Exception {
|
||||
removeAllMessages("Topic1", false);
|
||||
removeAllMessages("Topic2", false);
|
||||
removeAllMessages("Topic3", false);
|
||||
removeAllMessages("Queue1", true);
|
||||
removeAllMessages("Queue2", true);
|
||||
removeAllMessages("Queue3", true);
|
||||
removeAllMessages("Queue4", true);
|
||||
|
||||
destroyTopic("Topic1");
|
||||
destroyTopic("Topic2");
|
||||
destroyTopic("Topic3");
|
||||
destroyQueue("Queue1");
|
||||
destroyQueue("Queue2");
|
||||
destroyQueue("Queue3");
|
||||
destroyQueue("Queue4");
|
||||
|
||||
undeployConnectionFactory("ConnectionFactory");
|
||||
undeployConnectionFactory("CF_TOPIC");
|
||||
undeployConnectionFactory("CF_XA_TRUE");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static final void tearDownAllServers() {
|
||||
|
@ -362,7 +341,7 @@ public abstract class ActiveMQServerTestCase {
|
|||
}
|
||||
|
||||
protected void removeAllMessages(final String destName, final boolean isQueue) throws Exception {
|
||||
ActiveMQServerTestCase.servers.get(0).removeAllMessages(destName, isQueue);
|
||||
ActiveMQServerTestCase.servers.get(0).removeAllMessages(destName);
|
||||
}
|
||||
|
||||
protected boolean assertRemainingMessages(final int expected) throws Exception {
|
||||
|
|
|
@ -28,12 +28,14 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
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.core.client.ActiveMQClient;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
|
||||
import org.apache.activemq.artemis.api.jms.management.TopicControl;
|
||||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
|
@ -328,7 +330,7 @@ public class LocalTestServer implements Server, Runnable {
|
|||
|
||||
@Override
|
||||
public Long getMessageCountForQueue(final String queueName) throws Exception {
|
||||
JMSQueueControl queue = (JMSQueueControl) getActiveMQServer().getManagementService().getResource(queueName);
|
||||
QueueControl queue = (QueueControl) getActiveMQServer().getManagementService().getResource("queue." + queueName);
|
||||
if (queue != null) {
|
||||
queue.flushExecutor();
|
||||
return queue.getMessageCount();
|
||||
|
@ -338,25 +340,19 @@ public class LocalTestServer implements Server, Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeAllMessages(final String destination, final boolean isQueue) throws Exception {
|
||||
if (isQueue) {
|
||||
JMSQueueControl queue = (JMSQueueControl) getActiveMQServer().getManagementService().getResource(destination);
|
||||
queue.removeMessages(null);
|
||||
} else {
|
||||
TopicControl topic = (TopicControl) getActiveMQServer().getManagementService().getResource(destination);
|
||||
topic.removeMessages(null);
|
||||
}
|
||||
public void removeAllMessages(final String queueName) throws Exception {
|
||||
QueueControl queue = (QueueControl) getActiveMQServer().getManagementService().getResource(ResourceNames.QUEUE + queueName);
|
||||
queue.removeMessages(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listAllSubscribersForTopic(final String s) throws Exception {
|
||||
ObjectName objectName = ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(s);
|
||||
TopicControl topic = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), objectName, TopicControl.class, false);
|
||||
Object[] subInfos = topic.listAllSubscriptions();
|
||||
ObjectName objectName = ObjectNameBuilder.DEFAULT.getAddressObjectName(new SimpleString(s));
|
||||
AddressControl topic = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), objectName, AddressControl.class, false);
|
||||
Object[] subInfos = topic.getQueueNames();
|
||||
List<String> subs = new ArrayList<>();
|
||||
for (Object o : subInfos) {
|
||||
Object[] data = (Object[]) o;
|
||||
subs.add((String) data[2]);
|
||||
subs.add( ((String) o).split("\\.")[1]);
|
||||
}
|
||||
return subs;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public interface Server extends Remote {
|
|||
|
||||
InitialContext getInitialContext() throws Exception;
|
||||
|
||||
void removeAllMessages(String destination, boolean isQueue) throws Exception;
|
||||
void removeAllMessages(String destination) throws Exception;
|
||||
|
||||
Long getMessageCountForQueue(String queueName) throws Exception;
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
|||
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
|
||||
import org.junit.Assert;
|
||||
import org.objectweb.jtests.jms.admin.Admin;
|
||||
|
||||
/**
|
||||
|
@ -120,8 +120,7 @@ public class AbstractAdmin implements Admin {
|
|||
public void createQueue(final String name) {
|
||||
Boolean result;
|
||||
try {
|
||||
result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createQueue", name, name);
|
||||
Assert.assertEquals(true, result.booleanValue());
|
||||
invokeSyncOperation(ResourceNames.BROKER, "createQueue", name, name);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -131,8 +130,7 @@ public class AbstractAdmin implements Admin {
|
|||
public void deleteQueue(final String name) {
|
||||
Boolean result;
|
||||
try {
|
||||
result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyQueue", name);
|
||||
Assert.assertEquals(true, result.booleanValue());
|
||||
invokeSyncOperation(ResourceNames.BROKER, "destroyQueue", name);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -152,8 +150,7 @@ public class AbstractAdmin implements Admin {
|
|||
public void createTopic(final String name) {
|
||||
Boolean result;
|
||||
try {
|
||||
result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createTopic", name, name);
|
||||
Assert.assertEquals(true, result.booleanValue());
|
||||
invokeSyncOperation(ResourceNames.BROKER, "createAddress", name, (int)AddressInfo.RoutingType.MULTICAST.getType(), false, -1);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -163,8 +160,7 @@ public class AbstractAdmin implements Admin {
|
|||
public void deleteTopic(final String name) {
|
||||
Boolean result;
|
||||
try {
|
||||
result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyTopic", name);
|
||||
Assert.assertEquals(true, result.booleanValue());
|
||||
invokeSyncOperation(ResourceNames.BROKER, "deleteAddress", name);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import javax.naming.InitialContext;
|
|||
import javax.naming.NamingException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||
import org.apache.activemq.artemis.common.AbstractAdmin;
|
||||
import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
|
||||
|
||||
|
@ -57,20 +56,10 @@ public class ActiveMQCoreAdmin extends AbstractAdmin {
|
|||
|
||||
@Override
|
||||
public void createConnectionFactory(final String name) {
|
||||
createConnection(name, 0);
|
||||
jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=CF");
|
||||
|
||||
}
|
||||
|
||||
private void createConnection(final String name, final int cfType) {
|
||||
try {
|
||||
invokeSyncOperation(ResourceNames.JMS_SERVER, "createConnectionFactory", name, false, false, cfType, "netty", name);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createContext() throws NamingException {
|
||||
return new InitialContext(jndiProps);
|
||||
|
@ -84,7 +73,6 @@ public class ActiveMQCoreAdmin extends AbstractAdmin {
|
|||
|
||||
@Override
|
||||
public void createQueueConnectionFactory(final String name) {
|
||||
createConnection(name, 1);
|
||||
jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=QUEUE_CF");
|
||||
}
|
||||
|
||||
|
@ -96,18 +84,12 @@ public class ActiveMQCoreAdmin extends AbstractAdmin {
|
|||
|
||||
@Override
|
||||
public void createTopicConnectionFactory(final String name) {
|
||||
createConnection(name, 2);
|
||||
jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=TOPIC_CF");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConnectionFactory(final String name) {
|
||||
try {
|
||||
invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name);
|
||||
jndiProps.remove("connectionFactory." + name);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
jndiProps.remove("connectionFactory." + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,11 +44,12 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
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;
|
||||
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.api.jms.management.JMSQueueControl;
|
||||
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;
|
||||
|
@ -468,8 +469,8 @@ public class JMSBridgeImplTest extends ActiveMQTestBase {
|
|||
}
|
||||
|
||||
sourceConn.close();
|
||||
|
||||
JMSQueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(JMSBridgeImplTest.SOURCE), JMSQueueControl.class, false);
|
||||
SimpleString add = new SimpleString(JMSBridgeImplTest.SOURCE);
|
||||
QueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getQueueObjectName(add, add), QueueControl.class, false);
|
||||
assertNotEquals(jmsQueueControl.getDeliveringCount(), numMessages);
|
||||
|
||||
bridge.stop();
|
||||
|
|
Loading…
Reference in New Issue