This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 6a4e79f ARTEMIS-2910: reuse routing type calculated in initialisation for fixed-address
producers
new d7ba252 This closes #3270
6a4e79f is described below
commit 6a4e79fd06facb7ebbcec8c5d6c52e7c043ff276
Author: Robbie Gemmell <robbie@apache.org>
AuthorDate: Tue Sep 22 11:34:05 2020 +0100
ARTEMIS-2910: reuse routing type calculated in initialisation for fixed-address producers
---
.../artemis/protocol/amqp/broker/AMQPSessionCallback.java | 11 ++++++-----
.../protocol/amqp/proton/ProtonServerReceiverContext.java | 15 +++++++++++----
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
index 25cb4ab..141137b 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
@@ -466,9 +466,11 @@ public class AMQPSessionCallback implements SessionCallback {
RoutingType routingType = null;
if (address != null) {
+ // Fixed-address producer
message.setAddress(address);
+ routingType = context.getDefRoutingType();
} else {
- // Anonymous relay must set a To value
+ // Anonymous-relay producer, message must carry a To value
address = message.getAddressSimpleString();
if (address == null) {
// Errors are not currently handled as required by AMQP 1.0 anonterm-v1.0
@@ -477,13 +479,12 @@ public class AMQPSessionCallback implements SessionCallback {
}
routingType = message.getRoutingType();
+ if (routingType == null) {
+ routingType = context.getRoutingType(receiver, address);
+ }
}
//here check queue-autocreation
- if (routingType == null) {
- routingType = context.getRoutingType(receiver, address);
- }
-
if (!checkAddressAndAutocreateIfPossible(address, routingType)) {
throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.addressDoesntExist();
}
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
index b82067d..06e30d9 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
@@ -179,6 +179,8 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
private final int minLargeMessageSize;
+ private RoutingType defRoutingType;
+
public ProtonServerReceiverContext(AMQPSessionCallback sessionSPI,
AMQPConnectionContext connection,
AMQPSessionContext protonSession,
@@ -229,8 +231,6 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
// We don't currently support SECOND so enforce that the answer is anlways FIRST
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
- RoutingType defRoutingType;
-
if (target != null) {
if (target.getDynamic()) {
// if dynamic we have to create the node (queue) and set the address on the target,
the node is temporary and
@@ -252,9 +252,12 @@ public class ProtonServerReceiverContext extends ProtonInitializable
implements
// the target will have an address unless the remote is requesting an anonymous
// relay in which case the address in the incoming message's to field will be
// matched on receive of the message.
- address = SimpleString.toSimpleString(target.getAddress());
+ String targetAddress = target.getAddress();
+ if (targetAddress != null && !targetAddress.isEmpty()) {
+ address = SimpleString.toSimpleString(targetAddress);
+ }
- if (address != null && !address.isEmpty()) {
+ if (address != null) {
defRoutingType = getRoutingType(target.getCapabilities(), address);
try {
if (!sessionSPI.checkAddressAndAutocreateIfPossible(address, defRoutingType))
{
@@ -320,6 +323,10 @@ public class ProtonServerReceiverContext extends ProtonInitializable
implements
flow();
}
+ public RoutingType getDefRoutingType() {
+ return defRoutingType;
+ }
+
public RoutingType getRoutingType(Receiver receiver, SimpleString address) {
org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target)
receiver.getRemoteTarget();
return target != null ? getRoutingType(target.getCapabilities(), address) : getRoutingType((Symbol[])
null, address);
|