Skip to content

Commit

Permalink
#281 - first addition of activemq durable subscription management
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanb committed May 10, 2013
1 parent a8df031 commit c9955b5
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
@@ -0,0 +1,5 @@
<form class="form-horizontal" ng-controller="ActiveMQ.DurableSubscriberController">
<div class="row-fluid">
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>
</form>
9 changes: 8 additions & 1 deletion hawtio-web/src/main/webapp/app/activemq/js/activemqPlugin.ts
Expand Up @@ -10,7 +10,8 @@ module ActiveMQ {
when('/activemq/createTopic', {templateUrl: 'app/activemq/html/createTopic.html'}).
when('/activemq/deleteQueue', {templateUrl: 'app/activemq/html/deleteQueue.html'}).
when('/activemq/deleteTopic', {templateUrl: 'app/activemq/html/deleteTopic.html'}).
when('/activemq/sendMessage', {templateUrl: 'app/camel/html/sendMessage.html'})
when('/activemq/sendMessage', {templateUrl: 'app/camel/html/sendMessage.html'}).
when('/activemq/durableSubscribers', {templateUrl: 'app/activemq/html/durableSubscribers.html'})
}).
run(($location:ng.ILocationService, workspace:Workspace, viewRegistry) => {

Expand Down Expand Up @@ -122,6 +123,12 @@ module ActiveMQ {
isValid: (workspace:Workspace) => isQueue(workspace),
href: () => "#/activemq/deleteQueue"
});
workspace.subLevelTabs.push({
content: '<i class="icon-list"></i> Durable Subscribers',
title: "Manage durable subscribers",
isValid: (workspace:Workspace) => isBroker(workspace),
href: () => "#/activemq/durableSubscribers"
});

function postProcessTree(tree) {
var activemq = tree.get("org.apache.activemq");
Expand Down
96 changes: 96 additions & 0 deletions hawtio-web/src/main/webapp/app/activemq/js/durableSubscriber.ts
@@ -0,0 +1,96 @@
module ActiveMQ {
export function DurableSubscriberController($scope, workspace:Workspace, jolokia) {

$scope.refresh = loadTable;

$scope.durableSubscribers = [];

$scope.tempData = [];

$scope.gridOptions = {
selectedItems: [],
data: 'durableSubscribers',
displayFooter: false,
showFilter: false,
showColumnMenu: true,
enableColumnResize: true,
enableColumnReordering: true,
filterOptions: {
filterText: ''
},
selectWithCheckboxOnly: true,
showSelectionCheckbox: true,
maintainColumnRatios: false,
columnDefs: [
{
field: 'clientId',
displayName: 'Client ID',
width: '45%'
},
{
field: 'consumerId',
displayName: 'Consumer ID',
width: '45%'
},
{
field: 'status',
displayName: 'Status',
width: '10%'
}
]
};

$scope.$watch('workspace.selection', function () {
if (workspace.moveIfViewInvalid()) return;

// lets defer execution as we may not have the selection just yet
setTimeout(loadTable, 50);
});

function loadTable() {
var mbean = getBrokerMBean(jolokia);
if (mbean) {
$scope.durableSubscribers = []
jolokia.request({type: "read", mbean: mbean, attribute: ["DurableTopicSubscribers"]}, onSuccess( (response) => populateTable(response, "DurableTopicSubscribers", "Active")));
jolokia.request({type: "read", mbean: mbean, attribute: ["InactiveDurableTopicSubscribers"]}, onSuccess( (response) => populateTable(response, "InactiveDurableTopicSubscribers", "Offline")));
}
}

function populateTable(response, attr, status) {
var data = response.value;
$scope.durableSubscribers.push.apply($scope.durableSubscribers, data[attr].map(o => {
var objectName = o["objectName"];
var entries = Core.objectNameProperties(objectName);
entries["_id"] = objectName;
entries["status"] = status;
return entries;
}));

Core.$apply($scope);
}

function getBrokerMBean(jolokia) {
var mbean = null;
var selection = workspace.selection;
if (selection && isBroker(workspace) && selection.objectName) {
return selection.objectName;
}
var folderNames = selection.folderNames;
//if (selection && jolokia && folderNames && folderNames.length > 1) {
var parent = selection ? selection.parent : null;
if (selection && parent && jolokia && folderNames && folderNames.length > 1) {
mbean = parent.objectName;

// we might be a destination, so lets try one more parent
if (!mbean && parent) {
mbean = parent.parent.objectName;
}
if (!mbean) {
mbean = "" + folderNames[0] + ":BrokerName=" + folderNames[1] + ",Type=Broker";
}
}
return mbean;
}

}
}

0 comments on commit c9955b5

Please sign in to comment.