ARTEMIS-2910: reuse routing type calculated in initialisation for fixed-address producers

This commit is contained in:
Robbie Gemmell 2020-09-22 11:34:05 +01:00 committed by Clebert Suconic
parent 8ecd48fb93
commit 6a4e79fd06
2 changed files with 17 additions and 9 deletions

View File

@ -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();
}

View File

@ -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);