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

Add in support for Quorum queues #65

Open
wants to merge 2 commits 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
Binary file modified docs/images/amqp-consumer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/amqp-publisher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/main/java/com/zeroclue/jmeter/protocol/amqp/AMQPSampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract class AMQPSampler extends AbstractSampler implements ThreadListe
private static final String QUEUE_REDECLARE = "AMQPSampler.Redeclare";
private static final String QUEUE_EXCLUSIVE = "AMQPSampler.QueueExclusive";
private static final String QUEUE_AUTO_DELETE = "AMQPSampler.QueueAutoDelete";
private static final String QUEUE_QUORUM = "AMQPSampler.QueueQuorum";

public static final String[] EXCHANGE_TYPES = new String[] {
"direct",
Expand All @@ -74,6 +75,7 @@ public abstract class AMQPSampler extends AbstractSampler implements ThreadListe
public static final boolean DEFAULT_QUEUE_AUTO_DELETE = false;
public static final boolean DEFAULT_QUEUE_REDECLARE = false;
public static final boolean DEFAULT_QUEUE_EXCLUSIVE = false;
public static final boolean DEFAULT_QUEUE_QUORUM = false;

public static final String DEFAULT_MSG_TTL = "";
public static final String DEFAULT_MSG_EXPIRES = "";
Expand Down Expand Up @@ -170,6 +172,10 @@ protected boolean configureQueue(Channel channel) throws IOException, NoSuchAlgo
private Map<String, Object> getQueueArguments() {
Map<String, Object> arguments = new HashMap<>();

if (queueQuorum()) {
arguments.put("x-queue-type", "quorum");
}

if (getMessageTTL() != null && !getMessageTTL().isEmpty()) {
arguments.put("x-message-ttl", getMessageTTLAsInt());
}
Expand Down Expand Up @@ -467,6 +473,25 @@ public boolean queueAutoDelete() {
return getPropertyAsBoolean(QUEUE_AUTO_DELETE);
}

/**
* @return whether the queue should be of type quorum
*/
public String getQueueQuorum() {
return getPropertyAsString(QUEUE_QUORUM);
}

public void setQueueQuorum(String content) {
setProperty(QUEUE_QUORUM, content);
}

public void setQueueQuorum(Boolean value) {
setProperty(QUEUE_QUORUM, value.toString());
}

public boolean queueQuorum() {
return getPropertyAsBoolean(QUEUE_QUORUM);
}

/**
* @return the whether the queue should be redeclared
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public abstract class AMQPSamplerGui extends AbstractSamplerGui {
protected final JCheckBox queueRedeclare = new JCheckBox("Redeclare", AMQPSampler.DEFAULT_QUEUE_REDECLARE);
protected final JCheckBox queueExclusive = new JCheckBox("Exclusive", AMQPSampler.DEFAULT_QUEUE_EXCLUSIVE);
protected final JCheckBox queueAutoDelete = new JCheckBox("Auto Delete", AMQPSampler.DEFAULT_QUEUE_AUTO_DELETE);
protected final JCheckBox queueQuorum = new JCheckBox("Quorum", AMQPSampler.DEFAULT_QUEUE_QUORUM);

protected JLabeledTextField virtualHost = new JLabeledTextField("Virtual Host");
protected JLabeledTextField host = new JLabeledTextField(" Host");
Expand Down Expand Up @@ -91,6 +92,7 @@ public void configure(TestElement element) {
queueRedeclare.setSelected(sampler.getQueueRedeclare());
queueAutoDelete.setSelected(sampler.queueAutoDelete());
queueExclusive.setSelected(sampler.queueExclusive());
queueQuorum.setSelected(sampler.queueQuorum());

virtualHost.setText(sampler.getVirtualHost());
host.setText(sampler.getHost());
Expand Down Expand Up @@ -127,6 +129,7 @@ public void clearGui() {
queueRedeclare.setSelected(AMQPSampler.DEFAULT_QUEUE_REDECLARE);
queueAutoDelete.setSelected(AMQPSampler.DEFAULT_QUEUE_AUTO_DELETE);
queueExclusive.setSelected(AMQPSampler.DEFAULT_QUEUE_EXCLUSIVE);
queueQuorum.setSelected(AMQPSampler.DEFAULT_QUEUE_QUORUM);

virtualHost.setText(AMQPSampler.DEFAULT_VIRTUAL_HOST);
host.setText(AMQPSampler.DEFAULT_HOSTNAME);
Expand Down Expand Up @@ -165,6 +168,7 @@ public void modifyTestElement(TestElement element) {
sampler.setQueueRedeclare(queueRedeclare.isSelected());
sampler.setQueueAutoDelete(queueAutoDelete.isSelected());
sampler.setQueueExclusive(queueExclusive.isSelected());
sampler.setQueueQuorum(queueQuorum.isSelected());

sampler.setVirtualHost(virtualHost.getText());
sampler.setHost(host.getText());
Expand Down Expand Up @@ -286,6 +290,10 @@ private Component makeCommonPanel() {
gridBagConstraints.gridy = 3;
queueSettings.add(queueExclusive, gridBagConstraints);

gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
queueSettings.add(queueQuorum, gridBagConstraints);

gridBagConstraintsCommon.gridx = 0;
gridBagConstraintsCommon.gridy = 0;

Expand Down