Skip to content

Commit

Permalink
0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Wierenga committed Oct 30, 2020
1 parent 11c916f commit 2f91131
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ organization := "com.antonwierenga"

name := "activemq-cli"

version := "0.7.0"
version := "0.9.0"

scalaVersion := "2.11.6"

Expand Down
10 changes: 9 additions & 1 deletion src/main/scala/activemq/cli/ActiveMQCLI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ class ActiveMQCLI extends CommandMarker {

object ActiveMQCLI extends App {

lazy val ReleaseNotes = Map("v0.7.0" List(
lazy val ReleaseNotes = Map("v0.9.0" List(
"Updated shell command 'list-queues': new option --exclude-filter",
"Updated shell command 'purge-all-queues': new option --exclude-filter",
"Updated shell command 'remove-all-queues': new option --exclude-filter"
), "v0.8.1" List(
"Improved speed when using multiple jmxurls"
), "v0.8.0" List(
"Add support for multiple jmxurls"
), "v0.7.0" List(
"Updated shell command 'send-message': new option --type",
"Fixed shell command 'send-message': set JMSType header when sending messages from file",
"Increased width used in XML formatting"
Expand Down
23 changes: 18 additions & 5 deletions src/main/scala/activemq/cli/command/QueueCommands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ class QueueCommands extends Commands {
def removeAllQueues(
@CliOption(key = Array("force"), specifiedDefaultValue = "yes", mandatory = false, help = "No prompt") force: String,
@CliOption(key = Array("filter"), mandatory = false, help = "The query") filter: String,
@CliOption(key = Array("exclude-filter"), mandatory = false, help = "Only queues with a name that does not contain the value specified by exclude-filter are listed") excludeFilter: String, //scalastyle:ignore
@CliOption(key = Array("dry-run"), specifiedDefaultValue = "yes", mandatory = false, help = "Dry run") dryRun: String,
@CliOption(key = Array("pending"), mandatory = false, help = "Only queues that meet the pending filter are listed") pending: String,
@CliOption(key = Array("enqueued"), mandatory = false, help = "Only queues that meet the enqueued filter are listed") enqueued: String,
@CliOption(key = Array("dequeued"), mandatory = false, help = "Only queues that meet the dequeued filter are listed") dequeued: String,
@CliOption(key = Array("consumers"), mandatory = false, help = "Only queues that meet the consumers filter are listed") consumers: String
): String = {
withFilteredQueues("removed", force, filter, dryRun, pending, enqueued, dequeued, consumers,
withFilteredQueues("removed", force, filter, excludeFilter, dryRun, pending, enqueued, dequeued, consumers,
(queueViewMBean: QueueViewMBean, brokerViewMBean: BrokerViewMBean, dryRun: Boolean, pending: String, enqueued: String, dequeued: String,
consumers: String) {
brokerViewMBean.removeQueue(queueViewMBean.getName)
Expand All @@ -114,13 +115,14 @@ class QueueCommands extends Commands {
def purgeAllQueues(
@CliOption(key = Array("force"), specifiedDefaultValue = "yes", mandatory = false, help = "No prompt") force: String,
@CliOption(key = Array("filter"), mandatory = false, help = "The query") filter: String,
@CliOption(key = Array("exclude-filter"), mandatory = false, help = "Only queues with a name that does not contain the value specified by exclude-filter are listed") excludeFilter: String, //scalastyle:ignore
@CliOption(key = Array("dry-run"), specifiedDefaultValue = "yes", mandatory = false, help = "Dry run") dryRun: String,
@CliOption(key = Array("pending"), mandatory = false, help = "Only queues that meet the pending filter are listed") pending: String,
@CliOption(key = Array("enqueued"), mandatory = false, help = "Only queues that meet the enqueued filter are listed") enqueued: String,
@CliOption(key = Array("dequeued"), mandatory = false, help = "Only queues that meet the dequeued filter are listed") dequeued: String,
@CliOption(key = Array("consumers"), mandatory = false, help = "Only queues that meet the consumers filter are listed") consumers: String
): String = {
withFilteredQueues("purged", force, filter, dryRun, pending, enqueued, dequeued, consumers,
withFilteredQueues("purged", force, filter, excludeFilter, dryRun, pending, enqueued, dequeued, consumers,
(queueViewMBean: QueueViewMBean, brokerViewMBean: BrokerViewMBean, dryRun: Boolean, pending: String, enqueued: String, dequeued: String,
consumers: String) {
queueViewMBean.purge()
Expand All @@ -130,6 +132,7 @@ class QueueCommands extends Commands {
@CliCommand(value = Array("list-queues"), help = "Displays queues")
def listQueues( //scalastyle:ignore
@CliOption(key = Array("filter"), mandatory = false, help = "Only queues with a name that contains the value specified by filter are listed") filter: String, //scalastyle:ignore
@CliOption(key = Array("exclude-filter"), mandatory = false, help = "Only queues with a name that does not contain the value specified by exclude-filter are listed") excludeFilter: String, //scalastyle:ignore
@CliOption(key = Array("pending"), mandatory = false, help = "Only queues that meet the pending filter are listed") pending: String,
@CliOption(key = Array("enqueued"), mandatory = false, help = "Only queues that meet the enqueued filter are listed") enqueued: String,
@CliOption(key = Array("dequeued"), mandatory = false, help = "Only queues that meet the dequeued filter are listed") dequeued: String,
Expand All @@ -145,8 +148,13 @@ class QueueCommands extends Commands {
val consumersCount = parseFilterParameter(consumers, "consumers")

val queueViewMBeans = brokerViewMBean.getQueues.filter(objectName
if (filter) {
if (filter && excludeFilter) {
getDestinationKeyProperty(objectName).toLowerCase.contains(Option(filter).getOrElse("").toLowerCase) &&
!getDestinationKeyProperty(objectName).toLowerCase.contains(Option(excludeFilter).getOrElse("").toLowerCase)
} else if (filter && !excludeFilter) {
getDestinationKeyProperty(objectName).toLowerCase.contains(Option(filter).getOrElse("").toLowerCase)
} else if (excludeFilter) {
!getDestinationKeyProperty(objectName).toLowerCase.contains(Option(excludeFilter).getOrElse("").toLowerCase)
} else {
true
}).par.map({ objectName
Expand Down Expand Up @@ -177,7 +185,7 @@ class QueueCommands extends Commands {
})
}

def withFilteredQueues(action: String, force: String, filter: String, dryRun: Boolean, pending: String, enqueued: String, dequeued: String, //scalastyle:ignore
def withFilteredQueues(action: String, force: String, filter: String, excludeFilter: String, dryRun: Boolean, pending: String, enqueued: String, dequeued: String, //scalastyle:ignore
consumers: String, callback: (QueueViewMBean, BrokerViewMBean, Boolean, String, String, String, String) Unit): String = {
withBroker((brokerViewMBean: BrokerViewMBean, mBeanServerConnection: MBeanServerConnection) {

Expand All @@ -188,8 +196,13 @@ class QueueCommands extends Commands {

if (!dryRun) confirm(force)
val rows = brokerViewMBean.getQueues.filter(objectName
if (filter) {
if (filter && excludeFilter) {
getDestinationKeyProperty(objectName).toLowerCase.contains(Option(filter).getOrElse("").toLowerCase) &&
!getDestinationKeyProperty(objectName).toLowerCase.contains(Option(excludeFilter).getOrElse("").toLowerCase)
} else if (filter && !excludeFilter) {
getDestinationKeyProperty(objectName).toLowerCase.contains(Option(filter).getOrElse("").toLowerCase)
} else if (excludeFilter) {
!getDestinationKeyProperty(objectName).toLowerCase.contains(Option(excludeFilter).getOrElse("").toLowerCase)
} else {
true
}).par.map({ objectName
Expand Down

0 comments on commit 2f91131

Please sign in to comment.