Package org.wso2.carbon.andes.admin
Class AndesAdminService
java.lang.Object
org.wso2.carbon.core.AbstractAdmin
org.wso2.carbon.andes.admin.AndesAdminService
public class AndesAdminService
extends org.wso2.carbon.core.AbstractAdmin
Provides all the andes admin services that is available through the UI(JSP).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA comparator class to order queues.classA comparator class to order subscriptions. -
Field Summary
Fields inherited from class org.wso2.carbon.core.AbstractAdmin
axisConfig, configurationContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQueueAndAssignPermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) Add a queue with the given name and assign permissionsMessage[]browseQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) Browse the given queue name by start index and max messages countbooleanCheck if current user has add permission.booleanCheck if current user has browse messages in dlc permission.booleanCheck if current user has browse permission.booleanCheck if current user has delete messages in dlc permission.booleanCheck if current user has delete permission.booleancheckCurrentUserHasPublishPermission(String queueName) Check if current user is has publish permission for a queue.booleanCheck if current user has purge permission.booleanEvaluate current logged in user has close subscription permission for queue subscriptions .booleanCheck if current user has reroute messages in dlc permission.booleanCheck if current user has restore messages in dlc permission.booleanEvaluate current logged in user has close subscription permission for topic subscriptions.booleancheckUserHasAddQueuePermission(String username) Check if given user has add permission.booleanCheck if given user has browse messages in dlc permission.booleancheckUserHasBrowseQueuePermission(String username) Check if given user has browse permission.booleanCheck if given user has delete messages in dlc permission.booleancheckUserHasDeleteQueuePermission(String username) Check if given user has delete permission.booleancheckUserHasPublishPermission(String queueName, String userName) Check if a user has publishing permission for a queue.booleancheckUserHasPurgeQueuePermission(String username) Check if given user has purge permission.booleanCheck if given user has reroute messages in dlc permission.booleanCheck if given user has restore messages in dlc permission.voidcloseSubscription(boolean isDurable, String subscriptionID, String subscribedQueueOrTopicName, String protocolType, String destinationType, String subscriberQueueName) Close subscription defined by subscription ID forciblyvoiddeleteMessagesFromDeadLetterQueue(long[] messageIDs, String destinationQueueName) Delete messages from the Dead Letter Queue and delete their content.voiddeleteQueue(String queueName) Deletes a queue.voiddeleteTopicFromRegistry(String topicName, String subscriptionId) Delete topic related resources from registryvoidInvoke MBean operations and dump status of all messages.Queue[]Gets all queues.Gets all subscriptions.Retrieve the DLC queue for the domaingetFilteredSubscriptions(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId, int pageNumber, int subscriptionCountPerPage) Retrieve subscriptions matching to the given search criteria.longgetMessageCount(String destinationName, String msgPattern) Gets the message count for a queue Suppressing 'UnusedDeclaration' as it is called by webserviceintgetMessageCountForSubscriber(String subscriptionID, boolean durable, String protocolType, String destinationType) Gets the number of messages remaining for a subscriber.Message[]getMessageMetadataInDeadLetterChannel(String targetQueue, long startMessageId, int pageLimit) Returns a paginated list of message metadata destined for the inputQueueName but currently living in the Dead Letter Channel.Message[]getMessagesInDLCForQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) Gets the number of messages in DLC fora given queue name by start index and max messages countGet a list of names of durable queues created in the brokerlonggetNumberOfMessagesInDLCForQueue(String queueName) Gets the number of messages in DLC belonging to a specific queue.longgetPendingMessageCount(String queueName) Get the pending message count for the specified subscriptiongetQueueByName(String queueName) Retrieve anQueuewith the number of messages remaining in the database by passing a queue namegetQueueRolePermission(String queueName) Get all permission of the given queue namegetSubscriptions(String isDurable, String isActive, String protocolType, String destinationType) Retrieve subscriptions matching the given criteria.longgetTotalMessagesInQueue(String queueName) Total messages in the given queueintgetTotalSubscriptionCountForSearchResult(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId) Returns the total subscription count relevant to a particular search criteria.String[]Get roles of the current logged user If user has admin role, then all available roles will be returnvoidpurgeMessagesOfQueue(String queueName) Deletes all messages from a queue.rerouteAllMessagesFromDeadLetterChannelForQueue(String sourceQueue, String targetQueue, int internalBatchSize) Move messages destined for the input sourceQueue into a different targetQueue.longrerouteSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String newDestinationQueueName, String destinationQueueName) Restore messages from the Dead Letter Queue to another queue in the same tenant.longrestoreSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String destinationQueueName) Restore messages from the Dead Letter Queue to their original queues.booleansendMessage(String queueName, String jmsType, String jmsCorrelationID, int numberOfMessages, String message, int deliveryMode, int priority, long expireTime) Send messages to given queuevoidupdatePermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) Update the permission of the given queue nameMethods inherited from class org.wso2.carbon.core.AbstractAdmin
getAxisConfig, getConfigContext, getConfigSystemRegistry, getConfigUserRegistry, getGovernanceRegistry, getGovernanceSystemRegistry, getGovernanceUserRegistry, getHttpSession, getLocalRepo, getRegistry, getTenantDomain, getUsername, getUserRealm, setConfigurationContext, setPermissionUpdateTimestamp
-
Constructor Details
-
AndesAdminService
public AndesAdminService()
-
-
Method Details
-
getQueueByName
Retrieve anQueuewith the number of messages remaining in the database by passing a queue name- Parameters:
queueName- name of the queue- Returns:
- org.wso2.carbon.andes.admin.internal.Queue if the queue exists, null if it doesn't exists
- Throws:
BrokerManagerAdminException
-
getDLCQueue
Retrieve the DLC queue for the domain- Returns:
Queuewith the number of messages in the dlc- Throws:
BrokerManagerAdminException
-
getAllQueues
Gets all queues. Suppressing 'MismatchedQueryAndUpdateOfCollection' as 'allQueues' is used to sort and to convert to an array.- Returns:
- An array of queues.
- Throws:
BrokerManagerAdminException
-
getNamesOfAllDurableQueues
Get a list of names of durable queues created in the broker- Returns:
- a set of queue names
- Throws:
BrokerManagerAdminException- on error while retrieving information
-
getMessageCount
public long getMessageCount(String destinationName, String msgPattern) throws BrokerManagerAdminException Gets the message count for a queue Suppressing 'UnusedDeclaration' as it is called by webservice- Parameters:
destinationName- Destination name.msgPattern- Value should be either 'queue' or 'topic'.- Returns:
- Message count.
- Throws:
BrokerManagerAdminException
-
deleteQueue
Deletes a queue.- Parameters:
queueName- Queue name.- Throws:
BrokerManagerAdminException
-
deleteTopicFromRegistry
public void deleteTopicFromRegistry(String topicName, String subscriptionId) throws BrokerManagerAdminException Delete topic related resources from registry- Parameters:
topicName- Topic NamesubscriptionId- Subscription ID- Throws:
BrokerManagerAdminException
-
restoreSelectedMessagesFromDeadLetterChannel
public long restoreSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String destinationQueueName) throws BrokerManagerAdminException Restore messages from the Dead Letter Queue to their original queues.- Parameters:
messageIDs- Browser Message Id / External Message Id list.destinationQueueName- Dead Letter Queue name for the respective tenant.- Returns:
- unavailable message count
- Throws:
BrokerManagerAdminException
-
rerouteSelectedMessagesFromDeadLetterChannel
public long rerouteSelectedMessagesFromDeadLetterChannel(long[] messageIDs, String newDestinationQueueName, String destinationQueueName) throws BrokerManagerAdminException Restore messages from the Dead Letter Queue to another queue in the same tenant.- Parameters:
messageIDs- Browser Message Id / External Message Id list.newDestinationQueueName- The new destination queue for the messages in the same tenant.destinationQueueName- Dead Letter Queue name for the respective tenant.- Returns:
- unavailable message count
- Throws:
BrokerManagerAdminException
-
deleteMessagesFromDeadLetterQueue
public void deleteMessagesFromDeadLetterQueue(long[] messageIDs, String destinationQueueName) throws BrokerManagerAdminException Delete messages from the Dead Letter Queue and delete their content.- Parameters:
messageIDs- Browser Message Id / External Message Id list to be deleted.destinationQueueName- Dead Letter Queue name for the respective tenant.- Throws:
BrokerManagerAdminException
-
purgeMessagesOfQueue
Deletes all messages from a queue.- Parameters:
queueName- Queue name.- Throws:
BrokerManagerAdminException
-
closeSubscription
public void closeSubscription(boolean isDurable, String subscriptionID, String subscribedQueueOrTopicName, String protocolType, String destinationType, String subscriberQueueName) throws BrokerManagerAdminException Close subscription defined by subscription ID forcibly- Parameters:
isDurable- is subscriber durable or notsubscriptionID- ID of the subscriptionsubscribedQueueOrTopicName- queue / topic name of the subscribed destinationprotocolType- The protocol type of the subscriptions to closedestinationType- The destination type of the subscriptions to closesubscriberQueueName- The bind queue of the subscriber- Throws:
BrokerManagerAdminException
-
getAllSubscriptions
Gets all subscriptions. Suppressing 'MismatchedQueryAndUpdateOfCollection' as 'allSubscriptions' is used to convert to an array.- Returns:
- An array of
Subscription. - Throws:
BrokerManagerAdminException
-
getSubscriptions
public Subscription[] getSubscriptions(String isDurable, String isActive, String protocolType, String destinationType) throws BrokerManagerAdminException Retrieve subscriptions matching the given criteria.- Parameters:
isDurable- Are the subscriptions to be retrieved durable (true/false)isActive- Are the subscriptions to be retrieved active (true/false/*, * meaning any)protocolType- The protocol type of the subscriptions to be retrieveddestinationType- The destination type of the subscriptions to be retrieved- Returns:
- The list of subscriptions matching the given criteria
- Throws:
BrokerManagerAdminException
-
getFilteredSubscriptions
public Subscription[] getFilteredSubscriptions(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId, int pageNumber, int subscriptionCountPerPage) throws BrokerManagerAdminException Retrieve subscriptions matching to the given search criteria.- Parameters:
isDurable- are the subscriptions to be retrieve durable (true/ false)isActive- are the subscriptions to be retrieved active (true/false)protocolType- the protocol type of the subscriptions to be retrieveddestinationType- the destination type of the subscriptions to be retrievedfilteredNamePattern- queue or topic name pattern to search the subscriptions ("" for all)isFilteredNameByExactMatch- exactly match the name or notidentifierPattern- identifier pattern to search the subscriptions ("" for all)isIdentifierPatternByExactMatch- exactly match the identifier or notownNodeId- node Id of the node which own the subscriptionspageNumber- page number in the pagination tablesubscriptionCountPerPage- number of subscriptions to be shown in the UI per page- Returns:
- a list of subscriptions which match to the search criteria
- Throws:
BrokerManagerAdminException- throws when an error occurs
-
getTotalSubscriptionCountForSearchResult
public int getTotalSubscriptionCountForSearchResult(boolean isDurable, boolean isActive, String protocolType, String destinationType, String filteredNamePattern, boolean isFilteredNameByExactMatch, String identifierPattern, boolean isIdentifierPatternByExactMatch, String ownNodeId) throws BrokerManagerAdminException Returns the total subscription count relevant to a particular search criteria.- Parameters:
isDurable- are the subscriptions to be retrieve durable (true/ false)isActive- are the subscriptions to be retrieved active (true/false)protocolType- the protocol type of the subscriptions to be retrieveddestinationType- the destination type of the subscriptions to be retrievedfilteredNamePattern- queue or topic name pattern to search the subscriptions ("" for all)isFilteredNameByExactMatch- exactly match the name or notidentifierPattern- identifier pattern to search the subscriptions ("" for all)isIdentifierPatternByExactMatch- exactly match the identifier or notownNodeId- node Id of the node which own the subscriptions- Returns:
- total subscription count matching to the given criteria
- Throws:
BrokerManagerAdminException- hrows when an error occurs
-
getNumberOfMessagesInDLCForQueue
Gets the number of messages in DLC belonging to a specific queue.- Parameters:
queueName- The name of the queue.- Returns:
- The number of messages.
- Throws:
BrokerManagerAdminException
-
getMessagesInDLCForQueue
public Message[] getMessagesInDLCForQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) throws BrokerManagerAdminException Gets the number of messages in DLC fora given queue name by start index and max messages count- Parameters:
queueName- Name of the queuenextMessageIdToRead- Start point of the queue message id to start readingmaxMsgCount- Maximum messages from start index- Returns:
- Array of
Message - Throws:
BrokerManagerAdminException
-
updatePermission
public void updatePermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) throws BrokerManagerAdminException Update the permission of the given queue name- Parameters:
queueName- Name of the queuequeueRolePermissionsDTO- AQueueRolePermission- Throws:
BrokerManagerAdminException
-
addQueueAndAssignPermission
public void addQueueAndAssignPermission(String queueName, QueueRolePermission[] queueRolePermissionsDTO) throws BrokerManagerAdminException Add a queue with the given name and assign permissions- Parameters:
queueName- Name of the queuequeueRolePermissionsDTO- AQueueRolePermission- Throws:
BrokerManagerAdminException
-
getUserRoles
Get roles of the current logged user If user has admin role, then all available roles will be return- Returns:
- Array of user roles.
- Throws:
BrokerManagerAdminException
-
getQueueRolePermission
public QueueRolePermission[] getQueueRolePermission(String queueName) throws BrokerManagerAdminException Get all permission of the given queue name- Parameters:
queueName- Name of the queue- Returns:
- Array of
QueueRolePermission - Throws:
BrokerManagerAdminException
-
browseQueue
public Message[] browseQueue(String queueName, long nextMessageIdToRead, int maxMsgCount) throws BrokerManagerAdminException Browse the given queue name by start index and max messages count- Parameters:
queueName- Name of the queuenextMessageIdToRead- Start point of the queue message id to start readingmaxMsgCount- Maximum messages from start index- Returns:
- Array of
Message - Throws:
BrokerManagerAdminException
-
getTotalMessagesInQueue
Total messages in the given queue- Parameters:
queueName- Name of the queue- Returns:
- Total count of the messages
- Throws:
BrokerManagerAdminException
-
sendMessage
public boolean sendMessage(String queueName, String jmsType, String jmsCorrelationID, int numberOfMessages, String message, int deliveryMode, int priority, long expireTime) throws BrokerManagerAdminException Send messages to given queue- Parameters:
queueName- Name of the queuejmsType- JMS TypejmsCorrelationID- JMS Correlation IdnumberOfMessages- Number of timesmessage- Message contentdeliveryMode- Delivery modepriority- Message priorityexpireTime- Message expire time- Returns:
- true if send message successful and false otherwise
- Throws:
BrokerManagerAdminException
-
getMessageCountForSubscriber
public int getMessageCountForSubscriber(String subscriptionID, boolean durable, String protocolType, String destinationType) throws BrokerManagerAdminException Gets the number of messages remaining for a subscriber.- Parameters:
subscriptionID- The subscription ID.durable- Whether the subscription is durable or not.protocolType- The protocol type which the subscription belongs todestinationType- The destination type which the subscription belongs to- Returns:
- The number of remaining messages.
- Throws:
BrokerManagerAdminException
-
getPendingMessageCount
Get the pending message count for the specified subscription- Parameters:
queueName- queue name for which the pending message cound need to be calculated- Returns:
- The pending message count for that subscription
- Throws:
BrokerManagerAdminException
-
dumpMessageStatus
Invoke MBean operations and dump status of all messages. The file will be created inside [MB_HOME]/repository/logs- Throws:
BrokerManagerAdminException- on an issue creating/writing to file
-
checkCurrentUserHasPublishPermission
public boolean checkCurrentUserHasPublishPermission(String queueName) throws BrokerManagerAdminException Check if current user is has publish permission for a queue. Suppressing "unused" warning as this is an API.- Parameters:
queueName- The name of the queue- Returns:
- true if current user has publishing permissions, false otherwise.
- Throws:
BrokerManagerAdminException
-
checkUserHasPublishPermission
public boolean checkUserHasPublishPermission(String queueName, String userName) throws BrokerManagerAdminException Check if a user has publishing permission for a queue.- Parameters:
queueName- The name of the queueuserName- The username of the user- Returns:
- true if current user has publishing permissions, false otherwise.
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasAddQueuePermission
Check if current user has add permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasAddQueuePermission
Check if given user has add permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasBrowseQueuePermission
Check if current user has browse permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasBrowseQueuePermission
public boolean checkUserHasBrowseQueuePermission(String username) throws BrokerManagerAdminException Check if given user has browse permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasDeleteQueuePermission
Check if current user has delete permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasDeleteQueuePermission
public boolean checkUserHasDeleteQueuePermission(String username) throws BrokerManagerAdminException Check if given user has delete permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasPurgeQueuePermission
Check if current user has purge permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasPurgeQueuePermission
Check if given user has purge permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasBrowseMessagesInDLCPermission
public boolean checkCurrentUserHasBrowseMessagesInDLCPermission() throws BrokerManagerAdminExceptionCheck if current user has browse messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasBrowseMessagesInDLCPermission
public boolean checkUserHasBrowseMessagesInDLCPermission(String username) throws BrokerManagerAdminException Check if given user has browse messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasDeleteMessagesInDLCPermission
public boolean checkCurrentUserHasDeleteMessagesInDLCPermission() throws BrokerManagerAdminExceptionCheck if current user has delete messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasDeleteMessagesInDLCPermission
public boolean checkUserHasDeleteMessagesInDLCPermission(String username) throws BrokerManagerAdminException Check if given user has delete messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasRestoreMessagesInDLCPermission
public boolean checkCurrentUserHasRestoreMessagesInDLCPermission() throws BrokerManagerAdminExceptionCheck if current user has restore messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasRestoreMessagesInDLCPermission
public boolean checkUserHasRestoreMessagesInDLCPermission(String username) throws BrokerManagerAdminException Check if given user has restore messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasRerouteMessagesInDLCPermission
public boolean checkCurrentUserHasRerouteMessagesInDLCPermission() throws BrokerManagerAdminExceptionCheck if current user has reroute messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkUserHasRerouteMessagesInDLCPermission
public boolean checkUserHasRerouteMessagesInDLCPermission(String username) throws BrokerManagerAdminException Check if given user has reroute messages in dlc permission. This is global level permission. Usage of service is to control UI action.- Parameters:
username- username- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasQueueSubscriptionClosePermission
public boolean checkCurrentUserHasQueueSubscriptionClosePermission() throws BrokerManagerAdminExceptionEvaluate current logged in user has close subscription permission for queue subscriptions . This service mainly used to restrict UI control for un-authorize users- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException
-
checkCurrentUserHasTopicSubscriptionClosePermission
public boolean checkCurrentUserHasTopicSubscriptionClosePermission() throws BrokerManagerAdminExceptionEvaluate current logged in user has close subscription permission for topic subscriptions. This service mainly used to restrict UI control for un-authorize users- Returns:
- true/false based on permission
- Throws:
BrokerManagerAdminException- on an issue checking permission
-
getMessageMetadataInDeadLetterChannel
public Message[] getMessageMetadataInDeadLetterChannel(String targetQueue, long startMessageId, int pageLimit) throws BrokerManagerAdminException Returns a paginated list of message metadata destined for the inputQueueName but currently living in the Dead Letter Channel.- Parameters:
targetQueue- Name of the destination queuestartMessageId- Start point of the queue message id to start readingpageLimit- Maximum messages required in a single response- Returns:
- Array of
Message - Throws:
BrokerManagerAdminException- if an error occurs while invoking the MBean to fetch messages.
-
rerouteAllMessagesFromDeadLetterChannelForQueue
public String rerouteAllMessagesFromDeadLetterChannelForQueue(String sourceQueue, String targetQueue, int internalBatchSize) throws BrokerManagerAdminException Move messages destined for the input sourceQueue into a different targetQueue. If the sourceQueue is DLCQueue, all messages in the DLC will be restored to the targetQueue.- Parameters:
sourceQueue- Name of the source queuetargetQueue- Name of the target queue.internalBatchSize- even with this method, the MB server will internally read messages in DLC in batches, and simulate each batch as a new message list to the targetQueue. internalBatchSize controls the number of messages processed in a single batch internally.- Returns:
- String message containing the number of messages that were restored.
- Throws:
BrokerManagerAdminException
-