Add priority and disableMessageTimestamp to the producer command of activemq CLI

This commit is contained in:
Ken Liao 2024-10-19 16:06:21 -07:00
parent 4ff78ddab9
commit eecf7b6ead
3 changed files with 27 additions and 1 deletions

View File

@ -40,6 +40,8 @@ public class ProducerThread extends Thread {
long msgTTL = 0L;
String msgGroupID=null;
int transactionBatchSize;
int priority = 4;
boolean disableMessageTimestamp = false;
int transactions = 0;
AtomicInteger sentCount = new AtomicInteger(0);
@ -64,6 +66,8 @@ public class ProducerThread extends Thread {
producer = session.createProducer(destination);
producer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
producer.setTimeToLive(msgTTL);
producer.setPriority(priority);
producer.setDisableMessageTimestamp(disableMessageTimestamp);
initPayLoad();
running = true;
@ -306,4 +310,12 @@ public class ProducerThread extends Thread {
public void resetCounters(){
this.sentCount.set(0);
}
public void setMessagePriority(int priority) {
this.priority = priority;
}
public void setDisableMessageTimestamp(boolean disableMessageTimestamp) {
this.disableMessageTimestamp = disableMessageTimestamp;
}
}

View File

@ -45,6 +45,8 @@ public class ProducerCommand extends AbstractCommand {
String msgGroupID=null;
int transactionBatchSize;
private int parallelThreads = 1;
int priority = 4; // Default priority
boolean disableMessageTimestamp = false;
@Override
protected void runTask(List<String> tokens) throws Exception {
@ -82,6 +84,8 @@ public class ProducerCommand extends AbstractCommand {
producer.setMsgGroupID(msgGroupID);
producer.setTextMessageSize(textMessageSize);
producer.setFinished(active);
producer.setMessagePriority(priority);
producer.setDisableMessageTimestamp(disableMessageTimestamp);
producer.start();
}
@ -213,6 +217,14 @@ public class ProducerCommand extends AbstractCommand {
this.message = message;
}
public void setMessagePriority(int priority) {
this.priority = priority;
}
public void setDisableMessageTimestamp(boolean disableMessageTimestamp) {
this.disableMessageTimestamp = disableMessageTimestamp;
}
@Override
protected void printHelp() {
printHelpFromFile();

View File

@ -15,4 +15,6 @@ Options :
[--textMessageSize N] - size in bytes of a TextMessage, a Lorem ipsum demo TextMessage is used
[--message ..] - a text string to use as the message body
[--payloadUrl URL] - a url pointing to a document to use as the message body
[--msgGroupID ..] - JMS message group identifier
[--msgGroupID ..] - JMS message group identifier
[--messagePriority N] - The message priority. Default is 4
[--disableMessageTimestamp true|false] - Whether or not to disable timestamp on message, default false