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

Added dynamic priority support for jms similar to amqp #2915

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 @@ -137,6 +137,7 @@ private Uni<? extends Message<?>> send(JmsResourceHolder<JMSProducer> resourceHo
Destination dest = metadata.getDestination();
int deliveryMode = metadata.getDeliveryMode();
String type = metadata.getType();
final Integer priority = metadata.getPriority();
JmsProperties properties = metadata.getProperties();
if (correlationId != null) {
outgoing.setJMSCorrelationID(correlationId);
Expand All @@ -156,6 +157,9 @@ private Uni<? extends Message<?>> send(JmsResourceHolder<JMSProducer> resourceHo
if (type != null) {
outgoing.setJMSType(type);
}
if (priority != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this set the priority on the outgoing message?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first thought too, but using outgoing.setJMSPriority(priority); is not working. Could this be a mapping problem with the jakarta.jms.Message outgoing?

Setting it directly on the sender did work for me (resourceHolder.getClient().setPriority(priority))

resourceHolder.getClient().setPriority(priority);
}

if (properties != null) {
if (!(properties instanceof JmsPropertiesBuilder.OutgoingJmsProperties)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class OutgoingJmsMessageMetadata implements JmsMessageMetadata {
private final Destination destination;
private final int deliveryMode;
private final String type;
private final Integer priority;
private final JmsProperties properties;

public OutgoingJmsMessageMetadata(String correlationId, Destination replyTo, Destination destination,
Expand All @@ -18,6 +19,18 @@ public OutgoingJmsMessageMetadata(String correlationId, Destination replyTo, Des
this.destination = destination;
this.deliveryMode = deliveryMode;
this.type = type;
this.priority = null;
this.properties = properties;
}

public OutgoingJmsMessageMetadata(final String correlationId, final Destination replyTo, final Destination destination,
final int deliveryMode, final String type, final Integer priority, final JmsProperties properties) {
this.correlationId = correlationId;
this.replyTo = replyTo;
this.destination = destination;
this.deliveryMode = deliveryMode;
this.type = type;
this.priority = priority;
this.properties = properties;
}

Expand Down Expand Up @@ -46,6 +59,10 @@ public String getType() {
return type;
}

public Integer getPriority() {
return priority;
}

@Override
public JmsProperties getProperties() {
return properties;
Expand All @@ -61,6 +78,7 @@ public static final class OutgoingJmsMessageMetadataBuilder {
private Destination destination;
private int deliveryMode = -1;
private String type;
private Integer priority;
private JmsProperties properties;

public OutgoingJmsMessageMetadataBuilder withCorrelationId(String correlationId) {
Expand Down Expand Up @@ -88,13 +106,19 @@ public OutgoingJmsMessageMetadataBuilder withType(String type) {
return this;
}

public OutgoingJmsMessageMetadataBuilder withPriority(final Integer priority) {
this.priority = priority;
return this;
}

public OutgoingJmsMessageMetadataBuilder withProperties(JmsProperties properties) {
this.properties = properties;
return this;
}

public OutgoingJmsMessageMetadata build() {
return new OutgoingJmsMessageMetadata(correlationId, replyTo, destination, deliveryMode, type, properties);
return new OutgoingJmsMessageMetadata(correlationId, replyTo, destination, deliveryMode, type, priority,
properties);
}
}
}