Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMQ-9596] Add priority and disableMessageTimestamp to the producer command #1326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -64,6 +66,8 @@ public void run() {
producer = session.createProducer(destination);
producer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
producer.setTimeToLive(msgTTL);
producer.setPriority(priority);
producer.setDisableMessageTimestamp(disableMessageTimestamp);
initPayLoad();
running = true;

Expand Down Expand Up @@ -306,4 +310,12 @@ public synchronized void resumeProducer(){
public void resetCounters(){
this.sentCount.set(0);
}

public void setMessagePriority(int priority) {
this.priority = priority;
}

public void setDisableMessageTimestamp(boolean disableMessageTimestamp) {
this.disableMessageTimestamp = disableMessageTimestamp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -82,6 +84,8 @@ protected void runTask(List<String> tokens) throws Exception {
producer.setMsgGroupID(msgGroupID);
producer.setTextMessageSize(textMessageSize);
producer.setFinished(active);
producer.setMessagePriority(priority);
producer.setDisableMessageTimestamp(disableMessageTimestamp);
producer.start();
}

Expand Down Expand Up @@ -213,6 +217,14 @@ public void setMessage(String message) {
this.message = message;
}

public void setMessagePriority(int priority) {
this.priority = priority;
}

public void setDisableMessageTimestamp(boolean disableMessageTimestamp) {
this.disableMessageTimestamp = disableMessageTimestamp;
}

@Override
protected void printHelp() {
printHelpFromFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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