diff --git a/README.md b/README.md index 0f7b5b1..4056d23 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ usage: java -jar a--with-dependencies.jar [-A] [-a] [-b ] -A,--amqp Set protocol to AMQP. Defaults to OpenWire -a,--artemis-core Set protocol to ActiveMQ Artemis Core. Defaults to OpenWire + -B use value for given Boolean property. Can + be used several times. -b,--broker URL to broker. defaults to: tcp://localhost:61616 -C,--copy-queue Copy all messages from this to target. diff --git a/src/main/java/co/nordlander/a/A.java b/src/main/java/co/nordlander/a/A.java index 06943a1..6da88d6 100755 --- a/src/main/java/co/nordlander/a/A.java +++ b/src/main/java/co/nordlander/a/A.java @@ -41,7 +41,6 @@ import javax.script.ScriptException; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.MessageTransformer; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; @@ -133,6 +132,7 @@ public void output(Object... args) { public static final String CMD_RESTORE_DUMP = "X"; public static final String CMD_WRITE_DUMP = "x"; public static final String CMD_JMS_TYPE = "y"; + public static final String CMD_SET_BOOLEAN_HEADER = "B"; // Various constants public static final long SLEEP_TIME_BETWEEN_FILE_CHECK = 1000L; @@ -593,6 +593,7 @@ protected void putData(final String data, final CommandLine cmdLine) throws IOEx Properties props = cmdLine.getOptionProperties(CMD_SET_HEADER); Properties intProps = cmdLine.getOptionProperties(CMD_SET_INT_HEADER); Properties longProps = cmdLine.getOptionProperties(CMD_SET_LONG_HEADER); + Properties booleanProps = cmdLine.getOptionProperties(CMD_SET_BOOLEAN_HEADER); String type = cmdLine.getOptionValue(CMD_TYPE, DEFAULT_TYPE); String encoding = cmdLine.getOptionValue(CMD_ENCODING, Charset @@ -625,6 +626,10 @@ protected void putData(final String data, final CommandLine cmdLine) throws IOEx outMsg.setLongProperty((String) p.getKey(), Long.parseLong((String)p.getValue())); } + for (Entry p : booleanProps.entrySet()) { + outMsg.setBooleanProperty((String) p.getKey(), Boolean.parseBoolean((String)p.getValue())); + } + if (cmdLine.hasOption("r")) { outMsg.setJMSReplyTo(createDestination(cmdLine.getOptionValue("r"))); } @@ -1129,6 +1134,17 @@ protected Options createOptions() { opts.addOption(longProperty); + @SuppressWarnings("static-access") + Option booleanProperty = OptionBuilder + .withArgName("property=value") + .hasArgs(2) + .withValueSeparator() + .withDescription( + "use value for given Boolean property. Can be used several times.") + .create(CMD_SET_BOOLEAN_HEADER); + + opts.addOption(booleanProperty); + @SuppressWarnings("static-access") Option intProperty = OptionBuilder .withArgName("property=value")