http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSClient.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSClient.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSClient.java new file mode 100644 index 0000000..4ae9ed5 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSClient.java @@ -0,0 +1,234 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms; + +import javax.jms.Queue; +import javax.jms.Topic; + +import org.apache.activemq6.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq6.api.core.TransportConfiguration; +import org.apache.activemq6.jms.client.HornetQConnectionFactory; +import org.apache.activemq6.jms.client.HornetQDestination; +import org.apache.activemq6.jms.client.HornetQJMSConnectionFactory; +import org.apache.activemq6.jms.client.HornetQQueueConnectionFactory; +import org.apache.activemq6.jms.client.HornetQTopicConnectionFactory; +import org.apache.activemq6.jms.client.HornetQXAConnectionFactory; +import org.apache.activemq6.jms.client.HornetQXAQueueConnectionFactory; +import org.apache.activemq6.jms.client.HornetQXATopicConnectionFactory; + +/** + * A utility class for creating HornetQ client-side JMS managed resources. + * + * @author <a href="mailto:[email protected]">Andy Taylor</a> + */ +public class HornetQJMSClient +{ + + /** + * Creates a HornetQConnectionFactory that receives cluster topology updates from the cluster as + * servers leave or join and new backups are appointed or removed. + * <p> + * The discoveryAddress and discoveryPort parameters in this method are used to listen for UDP + * broadcasts which contain connection information for members of the cluster. The broadcasted + * connection information is simply used to make an initial connection to the cluster, once that + * connection is made, up to date cluster topology information is downloaded and automatically + * updated whenever the cluster topology changes. If the topology includes backup servers that + * information is also propagated to the client so that it can know which server to failover onto + * in case of live server failure. + * @param discoveryAddress The UDP group address to listen for updates + * @param discoveryPort the UDP port to listen for updates + * @return the HornetQConnectionFactory + */ + public static HornetQConnectionFactory createConnectionFactoryWithHA(final DiscoveryGroupConfiguration groupConfiguration, JMSFactoryType jmsFactoryType) + { + HornetQConnectionFactory factory = null; + if (jmsFactoryType.equals(JMSFactoryType.CF)) + { + factory = new HornetQJMSConnectionFactory(true, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) + { + factory = new HornetQQueueConnectionFactory(true, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) + { + factory = new HornetQTopicConnectionFactory(true, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) + { + factory = new HornetQXAConnectionFactory(true, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) + { + factory = new HornetQXAQueueConnectionFactory(true, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) + { + factory = new HornetQXATopicConnectionFactory(true, groupConfiguration); + } + + return factory; + } + + /** + * Create a HornetQConnectionFactory which creates session factories from a set of live servers, no HA backup information is propagated to the client + * + * The UDP address and port are used to listen for live servers in the cluster + * + * @param discoveryAddress The UDP group address to listen for updates + * @param discoveryPort the UDP port to listen for updates + * @return the HornetQConnectionFactory + */ + public static HornetQConnectionFactory createConnectionFactoryWithoutHA(final DiscoveryGroupConfiguration groupConfiguration, JMSFactoryType jmsFactoryType) + { + HornetQConnectionFactory factory = null; + if (jmsFactoryType.equals(JMSFactoryType.CF)) + { + factory = new HornetQJMSConnectionFactory(false, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) + { + factory = new HornetQQueueConnectionFactory(false, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) + { + factory = new HornetQTopicConnectionFactory(false, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) + { + factory = new HornetQXAConnectionFactory(false, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) + { + factory = new HornetQXAQueueConnectionFactory(false, groupConfiguration); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) + { + factory = new HornetQXATopicConnectionFactory(false, groupConfiguration); + } + + return factory; + } + + /** + * Create a HornetQConnectionFactory which will receive cluster topology updates from the cluster + * as servers leave or join and new backups are appointed or removed. + * <p> + * The initial list of servers supplied in this method is simply to make an initial connection to + * the cluster, once that connection is made, up to date cluster topology information is + * downloaded and automatically updated whenever the cluster topology changes. If the topology + * includes backup servers that information is also propagated to the client so that it can know + * which server to failover onto in case of live server failure. + * @param initialServers The initial set of servers used to make a connection to the cluster. + * Each one is tried in turn until a successful connection is made. Once a connection + * is made, the cluster topology is downloaded and the rest of the list is ignored. + * @return the HornetQConnectionFactory + */ + public static HornetQConnectionFactory createConnectionFactoryWithHA(JMSFactoryType jmsFactoryType, final TransportConfiguration... initialServers) + { + HornetQConnectionFactory factory = null; + if (jmsFactoryType.equals(JMSFactoryType.CF)) + { + factory = new HornetQJMSConnectionFactory(true, initialServers); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) + { + factory = new HornetQQueueConnectionFactory(true, initialServers); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) + { + factory = new HornetQTopicConnectionFactory(true, initialServers); + } + else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) + { + factory = new HornetQXAConnectionFactory(true, initialServers); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) + { + factory = new HornetQXAQueueConnectionFactory(true, initialServers); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) + { + factory = new HornetQXATopicConnectionFactory(true, initialServers); + } + + return factory; + } + + /** + * Create a HornetQConnectionFactory which creates session factories using a static list of + * transportConfigurations. + * <p> + * The HornetQConnectionFactory is not updated automatically as the cluster topology changes, and + * no HA backup information is propagated to the client + * @param transportConfigurations + * @return the HornetQConnectionFactory + */ + public static HornetQConnectionFactory createConnectionFactoryWithoutHA(JMSFactoryType jmsFactoryType, final TransportConfiguration... transportConfigurations) + { + HornetQConnectionFactory factory = null; + if (jmsFactoryType.equals(JMSFactoryType.CF)) + { + factory = new HornetQJMSConnectionFactory(false, transportConfigurations); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_CF)) + { + factory = new HornetQQueueConnectionFactory(false, transportConfigurations); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_CF)) + { + factory = new HornetQTopicConnectionFactory(false, transportConfigurations); + } + else if (jmsFactoryType.equals(JMSFactoryType.XA_CF)) + { + factory = new HornetQXAConnectionFactory(false, transportConfigurations); + } + else if (jmsFactoryType.equals(JMSFactoryType.QUEUE_XA_CF)) + { + factory = new HornetQXAQueueConnectionFactory(false, transportConfigurations); + } + else if (jmsFactoryType.equals(JMSFactoryType.TOPIC_XA_CF)) + { + factory = new HornetQXATopicConnectionFactory(false, transportConfigurations); + } + + return factory; + } + + /** + * Creates a client-side representation of a JMS Topic. + * + * @param name the name of the topic + * @return The Topic + */ + public static Topic createTopic(final String name) + { + return HornetQDestination.createTopic(name); + } + + /** + * Creates a client-side representation of a JMS Queue. + * + * @param name the name of the queue + * @return The Queue + */ + public static Queue createQueue(final String name) + { + return HornetQDestination.createQueue(name); + } + + private HornetQJMSClient() + { + // Utility class + } +}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSConstants.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSConstants.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSConstants.java new file mode 100644 index 0000000..f3ecb43 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/HornetQJMSConstants.java @@ -0,0 +1,38 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms; + +/** + * Constants for HornetQ for property keys used for HornetQ specific extensions to JMS. + * + * @author Tim Fox + * + * + */ +public class HornetQJMSConstants +{ + public static final String JMS_HORNETQ_INPUT_STREAM = "JMS_HQ_InputStream"; + + public static final String JMS_HORNETQ_OUTPUT_STREAM = "JMS_HQ_OutputStream"; + + public static final String JMS_HORNETQ_SAVE_STREAM = "JMS_HQ_SaveStream"; + + public static final String JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST = "HQ_BRIDGE_MSG_ID_LIST"; + + public static final int PRE_ACKNOWLEDGE = 100; + + public static final int INDIVIDUAL_ACKNOWLEDGE = 101; + + public static final String JMS_HORNETQ_ENABLE_BYTE_ARRAY_JMS_CORRELATION_ID_PROPERTY_NAME = + "hq.jms.support-bytes-id"; +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/JMSFactoryType.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/JMSFactoryType.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/JMSFactoryType.java new file mode 100644 index 0000000..b435e52 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/JMSFactoryType.java @@ -0,0 +1,83 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms; + +/** + * A JMSFactoryType + * + * @author howard + * + * + */ +// XXX no javadocs +public enum JMSFactoryType +{ + CF, QUEUE_CF, TOPIC_CF, XA_CF, QUEUE_XA_CF, TOPIC_XA_CF; + + public int intValue() + { + int val = 0; + switch (this) + { + case CF: + val = 0; + break; + case QUEUE_CF: + val = 1; + break; + case TOPIC_CF: + val = 2; + break; + case XA_CF: + val = 3; + break; + case QUEUE_XA_CF: + val = 4; + break; + case TOPIC_XA_CF: + val = 5; + break; + } + return val; + } + + public static JMSFactoryType valueOf(int val) + { + JMSFactoryType type; + switch (val) + { + case 0: + type = CF; + break; + case 1: + type = QUEUE_CF; + break; + case 2: + type = TOPIC_CF; + break; + case 3: + type = XA_CF; + break; + case 4: + type = QUEUE_XA_CF; + break; + case 5: + type = TOPIC_XA_CF; + break; + default: + type = XA_CF; + break; + } + return type; + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/ConnectionFactoryControl.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/ConnectionFactoryControl.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/ConnectionFactoryControl.java new file mode 100644 index 0000000..416fb70 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/ConnectionFactoryControl.java @@ -0,0 +1,389 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import org.apache.activemq6.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq6.api.core.TransportConfiguration; +import org.apache.activemq6.api.core.management.Operation; +import org.apache.activemq6.api.core.management.Parameter; + +/** + * A ConnectionFactoryControl is used to manage a JMS ConnectionFactory. <br> + * HornetQ JMS ConnectionFactory uses an underlying ClientSessionFactory to connect to HornetQ + * servers. Please refer to the ClientSessionFactory for a detailed description. + * + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + * @author <a href="mailto:[email protected]">Tim Fox</a> + * @see ServerLocator + * @see ClientSessionFactory + */ +public interface ConnectionFactoryControl +{ + /** + * Returns the configuration name of this connection factory. + */ + String getName(); + + /** + * Returns the JNDI bindings associated to this connection factory. + */ + String[] getJNDIBindings(); + + /** + * 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 ServerLocator#isCompressLargeMessage() + */ + boolean isCompressLargeMessages(); + + void setCompressLargeMessages(boolean compress); + + /** + * @see ServerLocator#getClientFailureCheckPeriod() + */ + long getClientFailureCheckPeriod(); + + /** + * @see ServerLocator#setClientFailureCheckPeriod + */ + void setClientFailureCheckPeriod(long clientFailureCheckPeriod); + + /** + * @see ServerLocator#getCallTimeout() + */ + long getCallTimeout(); + + /** + * @see ServerLocator#setCallTimeout(long) + */ + void setCallTimeout(long callTimeout); + + /** + * @see ServerLocator#getCallFailoverTimeout() + */ + long getCallFailoverTimeout(); + + /** + * @see ServerLocator#setCallFailoverTimeout(long) + */ + + void setCallFailoverTimeout(long callTimeout); + + /** + * Returns the batch size (in bytes) between acknowledgements when using DUPS_OK_ACKNOWLEDGE + * mode. + * + * @see ServerLocator#getAckBatchSize() + * @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE + */ + int getDupsOKBatchSize(); + + /** + * @see ServerLocator#setAckBatchSize(int) + */ + void setDupsOKBatchSize(int dupsOKBatchSize); + + /** + * @see ServerLocator#getConsumerMaxRate() + */ + int getConsumerMaxRate(); + + /** + * @see ServerLocator#setConsumerMaxRate(int) + */ + void setConsumerMaxRate(int consumerMaxRate); + + /** + * @see ServerLocator#getConsumerWindowSize() + */ + int getConsumerWindowSize(); + + /** + * @see ServerLocator#setConfirmationWindowSize(int) + */ + void setConsumerWindowSize(int consumerWindowSize); + + /** + * @see ServerLocator#getProducerMaxRate() + */ + int getProducerMaxRate(); + + /** + * @see ServerLocator#setProducerMaxRate(int) + */ + void setProducerMaxRate(int producerMaxRate); + + /** + * @see ServerLocator#getConfirmationWindowSize() + */ + int getConfirmationWindowSize(); + + /** + * @see ServerLocator#setConfirmationWindowSize(int) + */ + void setConfirmationWindowSize(int confirmationWindowSize); + + /** + * @see ServerLocator#isBlockOnAcknowledge() + */ + boolean isBlockOnAcknowledge(); + + /** + * @see ServerLocator#setBlockOnAcknowledge(boolean) + */ + void setBlockOnAcknowledge(boolean blockOnAcknowledge); + + /** + * @see ServerLocator#isBlockOnDurableSend() + */ + boolean isBlockOnDurableSend(); + + /** + * @see ServerLocator#setBlockOnDurableSend(boolean) + */ + void setBlockOnDurableSend(boolean blockOnDurableSend); + + /** + * @see ServerLocator#isBlockOnNonDurableSend() + */ + boolean isBlockOnNonDurableSend(); + + /** + * @see ServerLocator#setBlockOnNonDurableSend(boolean) + */ + void setBlockOnNonDurableSend(boolean blockOnNonDurableSend); + + /** + * @see ServerLocator#isPreAcknowledge() + */ + boolean isPreAcknowledge(); + + /** + * @see ServerLocator#setPreAcknowledge(boolean) + */ + void setPreAcknowledge(boolean preAcknowledge); + + + /** + * @see ServerLocator#getConnectionTTL() + */ + long getConnectionTTL(); + + /** + * @see ServerLocator#setConnectionTTL(long) + */ + void setConnectionTTL(long connectionTTL); + + /** + * Returns the batch size (in bytes) between acknowledgements when using a transacted session. + * + * @see ServerLocator#getAckBatchSize() + */ + int getTransactionBatchSize(); + + /** + * @see ServerLocator#setAckBatchSize(int) + */ + void setTransactionBatchSize(int transactionBatchSize); + + /** + * @see ServerLocator#getMinLargeMessageSize() + */ + int getMinLargeMessageSize(); + + /** + * @see ServerLocator#setMinLargeMessageSize(int) + */ + void setMinLargeMessageSize(int minLargeMessageSize); + + /** + * @see ServerLocator#isAutoGroup() + */ + boolean isAutoGroup(); + + /** + * @see ServerLocator#setAutoGroup(boolean) + */ + void setAutoGroup(boolean autoGroup); + + /** + * @see ServerLocator#getRetryInterval() + */ + long getRetryInterval(); + + /** + * @see ServerLocator#setRetryInterval(long) + */ + void setRetryInterval(long retryInterval); + + /** + * @see ServerLocator#getRetryIntervalMultiplier() + */ + double getRetryIntervalMultiplier(); + + /** + * @see ServerLocator#setRetryIntervalMultiplier(double) + */ + void setRetryIntervalMultiplier(double retryIntervalMultiplier); + + /** + * @see ServerLocator#getReconnectAttempts() + */ + int getReconnectAttempts(); + + /** + * @see ServerLocator#setReconnectAttempts(int) + */ + void setReconnectAttempts(int reconnectAttempts); + + /** + * @see ServerLocator#isFailoverOnInitialConnection() + */ + boolean isFailoverOnInitialConnection(); + + /** + * @see ServerLocator#setFailoverOnInitialConnection(boolean) + */ + void setFailoverOnInitialConnection(boolean failoverOnInitialConnection); + + + /** + * @see org.apache.activemq6.api.core.client.ServerLocator#getProducerWindowSize() + */ + int getProducerWindowSize(); + + /** + * @see ServerLocator#setProducerWindowSize(int) + */ + void setProducerWindowSize(int producerWindowSize); + + /** + * @see ServerLocator#isCacheLargeMessagesClient() + */ + boolean isCacheLargeMessagesClient(); + + /** + * @see ServerLocator#setCacheLargeMessagesClient(boolean) + */ + void setCacheLargeMessagesClient(boolean cacheLargeMessagesClient); + + /** + * @see ServerLocator#getMaxRetryInterval() + */ + long getMaxRetryInterval(); + + /** + * @see ServerLocator#setMaxRetryInterval(long) + */ + void setMaxRetryInterval(long retryInterval); + + /** + * @see ServerLocator#getScheduledThreadPoolMaxSize() + */ + int getScheduledThreadPoolMaxSize(); + + /** + * @see ServerLocator#setScheduledThreadPoolMaxSize(int) + */ + void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize); + + /** + * @see ServerLocator#getThreadPoolMaxSize() + */ + int getThreadPoolMaxSize(); + + /** + * @see ServerLocator#setThreadPoolMaxSize(int) + */ + void setThreadPoolMaxSize(int threadPoolMaxSize); + + /** + * @see ServerLocator#getGroupID() + */ + String getGroupID(); + + /** + * @see ServerLocator#setGroupID(String) + */ + void setGroupID(String groupID); + + /** + * @see ServerLocator#getInitialMessagePacketSize() + */ + int getInitialMessagePacketSize(); + + /** + * @see ServerLocator#isUseGlobalPools() + */ + boolean isUseGlobalPools(); + + /** + * @see ServerLocator#setUseGlobalPools(boolean) + */ + void setUseGlobalPools(boolean useGlobalPools); + + /** + * @see ServerLocator#getConnectionLoadBalancingPolicyClassName() + */ + String getConnectionLoadBalancingPolicyClassName(); + + /** + * @see ServerLocator#setConnectionLoadBalancingPolicyClassName(String) + */ + void setConnectionLoadBalancingPolicyClassName(String connectionLoadBalancingPolicyClassName); + + /** + * @see ClientSessionFactory#getStaticConnectors() + */ + TransportConfiguration[] getStaticConnectors(); + + /** + * get the discovery group configuration + */ + DiscoveryGroupConfiguration getDiscoveryGroupConfiguration(); + + /** + * Add the JNDI binding to this destination + */ + @Operation(desc = "Adds the factory to another JNDI binding") + void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; + + /** + * Remove a JNDI binding + */ + @Operation(desc = "Remove an existing JNDI binding") + void removeJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception; +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/DestinationControl.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/DestinationControl.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/DestinationControl.java new file mode 100644 index 0000000..8cf2a96 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/DestinationControl.java @@ -0,0 +1,71 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import javax.management.MBeanOperationInfo; + +import org.apache.activemq6.api.core.management.Operation; +import org.apache.activemq6.api.core.management.Parameter; + +/** + * A DestinationControl is used to manage a JMS Destination. + * + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + */ +public interface DestinationControl +{ + // Attributes ---------------------------------------------------- + + /** + * Returns the name of this destination. + */ + String getName(); + + /** + * Returns the HornetQ address corresponding to this destination. + */ + String getAddress(); + + /** + * Returns whether this destination is temporary. + */ + boolean isTemporary(); + + /** + * Returns 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. + */ + int getDeliveringCount(); + + /** + * Returns 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; + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConnectionInfo.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConnectionInfo.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConnectionInfo.java new file mode 100644 index 0000000..fdec725 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConnectionInfo.java @@ -0,0 +1,102 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import org.apache.activemq6.utils.json.JSONArray; +import org.apache.activemq6.utils.json.JSONObject; + +/** + * A JMSConnectionInfo + * + * @author jmesnil + * + * + */ +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 = new JSONArray(jsonString); + JMSConnectionInfo[] infos = new JMSConnectionInfo[array.length()]; + for (int i = 0; i < array.length(); i++) + { + JSONObject obj = array.getJSONObject(i); + String cid = obj.isNull("clientID") ? null : obj.getString("clientID"); + String uname = obj.isNull("principal") ? null : obj.getString("principal"); + + JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), + obj.getString("clientAddress"), + obj.getLong("creationTime"), + 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; + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConsumerInfo.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConsumerInfo.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConsumerInfo.java new file mode 100644 index 0000000..7d629e8 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSConsumerInfo.java @@ -0,0 +1,134 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import org.apache.activemq6.utils.json.JSONArray; +import org.apache.activemq6.utils.json.JSONObject; + +/** + * Helper class to create Java Objects from the + * JSON serialization returned by {@link JMSServerControl#listConsumersAsJSON(String)} and related methods. + * + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + */ +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 = new JSONArray(jsonString); + JMSConsumerInfo[] infos = new JMSConsumerInfo[array.length()]; + for (int i = 0; i < array.length(); i++) + { + JSONObject sub = array.getJSONObject(i); + JMSConsumerInfo info = new JMSConsumerInfo(sub.getString("consumerID"), + sub.getString("connectionID"), + sub.getString("destinationName"), + sub.getString("destinationType"), + sub.getBoolean("browseOnly"), + sub.getLong("creationTime"), + sub.getBoolean("durable"), + sub.optString("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; + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSManagementHelper.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSManagementHelper.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSManagementHelper.java new file mode 100644 index 0000000..f65875a --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSManagementHelper.java @@ -0,0 +1,168 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import javax.jms.JMSException; +import javax.jms.Message; + +import org.apache.activemq6.api.core.management.ManagementHelper; +import org.apache.activemq6.jms.client.HornetQMessage; + +/** + * Helper class to use JMS messages to manage HornetQ server resources. + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + * @author <a href="mailto:[email protected]">Tim Fox</a> + */ +public class JMSManagementHelper +{ + private static org.apache.activemq6.api.core.Message getCoreMessage(final Message jmsMessage) + { + if (jmsMessage instanceof HornetQMessage == false) + { + throw new IllegalArgumentException("Cannot send a non HornetQ message as a management message " + jmsMessage.getClass() + .getName()); + } + + return ((HornetQMessage)jmsMessage).getCoreMessage(); + } + + /** + * Stores a resource attribute in a JMS message to retrieve the value from the server resource. + * + * @param message JMS message + * @param resourceName the name of the resource + * @param attribute the name of the attribute + * @throws JMSException if an exception occurs while putting the information in the message + * + * @see org.apache.activemq6.api.core.management.ResourceNames + */ + public static void putAttribute(final Message message, final String resourceName, final String attribute) throws JMSException + { + ManagementHelper.putAttribute(JMSManagementHelper.getCoreMessage(message), resourceName, attribute); + } + + /** + * Stores a operation invocation in a JMS message to invoke the corresponding operation the value from the server resource. + * + * @param message JMS message + * @param resourceName the name of the resource + * @param operationName the name of the operation to invoke on the resource + * @throws JMSException if an exception occurs while putting the information in the message + * + * @see org.apache.activemq6.api.core.management.ResourceNames + */ + public static void putOperationInvocation(final Message message, + final String resourceName, + final String operationName) throws JMSException + { + try + { + ManagementHelper.putOperationInvocation(JMSManagementHelper.getCoreMessage(message), + resourceName, + operationName); + } + catch (Exception e) + { + throw JMSManagementHelper.convertFromException(e); + } + } + + private static JMSException convertFromException(final Exception e) + { + JMSException jmse = new JMSException(e.getMessage()); + + jmse.initCause(e); + + return jmse; + } + + /** + * Stores a operation invocation in a JMS message to invoke the corresponding operation the value from the server resource. + * + * @param message JMS message + * @param resourceName the name of the server resource + * @param operationName the name of the operation to invoke on the server resource + * @param parameters the parameters to use to invoke the server resource + * @throws JMSException if an exception occurs while putting the information in the message + * + * @see org.apache.activemq6.api.core.management.ResourceNames + */ + public static void putOperationInvocation(final Message message, + final String resourceName, + final String operationName, + final Object... parameters) throws JMSException + { + try + { + ManagementHelper.putOperationInvocation(JMSManagementHelper.getCoreMessage(message), + resourceName, + operationName, + parameters); + } + catch (Exception e) + { + throw JMSManagementHelper.convertFromException(e); + } + } + + /** + * Returns whether the JMS message corresponds to the result of a management operation invocation. + */ + public static boolean isOperationResult(final Message message) throws JMSException + { + return ManagementHelper.isOperationResult(JMSManagementHelper.getCoreMessage(message)); + } + + /** + * Returns whether the JMS message corresponds to the result of a management attribute value. + */ + public static boolean isAttributesResult(final Message message) throws JMSException + { + return ManagementHelper.isAttributesResult(JMSManagementHelper.getCoreMessage(message)); + } + + /** + * Returns whether the invocation of the management operation on the server resource succeeded. + */ + public static boolean hasOperationSucceeded(final Message message) throws JMSException + { + return ManagementHelper.hasOperationSucceeded(JMSManagementHelper.getCoreMessage(message)); + } + + /** + * Returns the result of an operation invocation or an attribute value. + * <br> + * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. + * and the result will be a String corresponding to the server exception. + */ + public static Object[] getResults(final Message message) throws Exception + { + return ManagementHelper.getResults(JMSManagementHelper.getCoreMessage(message)); + } + + /** + * Returns the result of an operation invocation or an attribute value. + * <br> + * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. + * and the result will be a String corresponding to the server exception. + */ + public static Object getResult(final Message message) throws Exception + { + return ManagementHelper.getResult(JMSManagementHelper.getCoreMessage(message)); + } + + private JMSManagementHelper() + { + // Utility class + } +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSQueueControl.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSQueueControl.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSQueueControl.java new file mode 100644 index 0000000..c617250 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSQueueControl.java @@ -0,0 +1,288 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import java.util.Map; + +import javax.management.MBeanOperationInfo; + +import org.apache.activemq6.api.core.management.Operation; +import org.apache.activemq6.api.core.management.Parameter; + +/** + * A JMSQueueControl is used to manage a JMS queue. + * + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + */ +public interface JMSQueueControl extends DestinationControl +{ + // Attributes ---------------------------------------------------- + + /** + * Returns the expiry address associated to this queue. + */ + String getExpiryAddress(); + + /** + * Sets the expiry address associated to this queue to the specified expiryAddress. + * @deprecated: it's non persisted. Use the proper address settings + */ + @Deprecated + void setExpiryAddress(@Parameter(name = "expiryAddress", desc = "Expiry address of the queue") String expiryAddress) throws Exception; + + /** + * Returns the dead-letter address associated to this queue. + */ + String getDeadLetterAddress(); + + /** + * Sets the dead-letter address associated to this queue to the specified deadLetterAddress. + * @deprecated: it's non persisted. Use the proper address settings + */ + @Deprecated + void setDeadLetterAddress(@Parameter(name = "deadLetterAddress", desc = "Dead-letter address of the queue") String deadLetterAddress) throws Exception; + + /** + * Returns the number of scheduled messages in this queue. + */ + long getScheduledCount(); + + /** + * Returns the number of consumers consuming messages from this queue. + */ + int getConsumerCount(); + + /** + * returns the selector for the queue + */ + String getSelector(); + + // Operations ---------------------------------------------------- + + /** + * Returns the JNDI bindings associated to this connection factory. + */ + @Operation(desc = "Returns the list of JNDI bindings associated") + String[] getJNDIBindings(); + + /** + * Add the JNDI binding to this destination + */ + @Operation(desc = "Adds the queue to another JNDI binding") + void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) 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 + */ + @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; + + /** + * 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; + + /** + * 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; + + /** + * Returns whether the queue is paused. + */ + @Operation(desc = "Returns true if the queue is paused.", impact = MBeanOperationInfo.INFO) + 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; + + @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 + * @throws Exception + */ + void flushExecutor(); + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSServerControl.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSServerControl.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSServerControl.java new file mode 100644 index 0000000..ca6f621 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSServerControl.java @@ -0,0 +1,367 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import javax.management.MBeanOperationInfo; + +import org.apache.activemq6.api.core.management.Operation; +import org.apache.activemq6.api.core.management.Parameter; + +/** + * A JMSSserverControl is used to manage HornetQ JMS server. + * + * @author <a href="mailto:[email protected]">Jeff Mesnil</a> + * @author <a href="mailto:[email protected]">Tim Fox</a> + */ +public interface JMSServerControl +{ + // Attributes ---------------------------------------------------- + + /** + * Returns whether this server is started. + */ + boolean isStarted(); + + /** + * Returns this server's version + */ + String getVersion(); + + /** + * Returns the names of the JMS topics available on this server. + */ + String[] getTopicNames(); + + /** + * Returns the names of the JMS queues available on this server. + */ + String[] getQueueNames(); + + /** + * Returns the names of the JMS connection factories available on this server. + */ + String[] getConnectionFactoryNames(); + + // 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.activemq6.spi.core.remoting.ConnectorFactory} to connect to the live servers + * and {@code liveConnectorTransportParams} are Map<String, Object> for the corresponding {@link org.apache.activemq6.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 HornetQ address", impact = MBeanOperationInfo.INFO) + boolean closeConsumerConnectionsForAddress(@Parameter(desc = "a HornetQ 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 to 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 to 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; + + /** + * 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; +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/23e8edd9/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSSessionInfo.java ---------------------------------------------------------------------- diff --git a/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSSessionInfo.java b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSSessionInfo.java new file mode 100644 index 0000000..bc7fac3 --- /dev/null +++ b/activemq6-jms-client/src/main/java/org/apache/activemq6/api/jms/management/JMSSessionInfo.java @@ -0,0 +1,62 @@ +/* + * Copyright 2005-2014 Red Hat, Inc. + * Red Hat 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.activemq6.api.jms.management; + +import org.apache.activemq6.utils.json.JSONArray; +import org.apache.activemq6.utils.json.JSONException; +import org.apache.activemq6.utils.json.JSONObject; + +/** + * A JMSSessionInfo + * + * @author howard + * + * + */ +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) throws JSONException + { + JSONArray array = new JSONArray(jsonString); + JMSSessionInfo[] infos = new JMSSessionInfo[array.length()]; + for (int i = 0; i < array.length(); i++) + { + JSONObject obj = array.getJSONObject(i); + + JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"), + obj.getLong("creationTime")); + infos[i] = info; + } + return infos; + } + + public String getSessionID() + { + return sessionID; + } + + public long getCreationTime() + { + return creationTime; + } +}
