ARTEMIS-1045 Performance improvements on AMQP
This commit is contained in:
parent
861c231551
commit
291a4719b6
|
@ -72,6 +72,7 @@ public class AMQPMessage extends RefCountMessage {
|
|||
private DeliveryAnnotations _deliveryAnnotations;
|
||||
private MessageAnnotations _messageAnnotations;
|
||||
private Properties _properties;
|
||||
private int appLocation = -1;
|
||||
private ApplicationProperties applicationProperties;
|
||||
private long scheduledTime = -1;
|
||||
private String connectionID;
|
||||
|
@ -148,6 +149,20 @@ public class AMQPMessage extends RefCountMessage {
|
|||
|
||||
private ApplicationProperties getApplicationProperties() {
|
||||
parseHeaders();
|
||||
|
||||
if (applicationProperties == null && appLocation >= 0) {
|
||||
ByteBuffer buffer = getBuffer().nioBuffer();
|
||||
buffer.position(appLocation);
|
||||
TLSEncode.getDecoder().setByteBuffer(buffer);
|
||||
Object section = TLSEncode.getDecoder().readObject();
|
||||
if (section instanceof ApplicationProperties) {
|
||||
this.applicationProperties = (ApplicationProperties) section;
|
||||
}
|
||||
this.appLocation = -1;
|
||||
TLSEncode.getDecoder().setByteBuffer(null);
|
||||
|
||||
}
|
||||
|
||||
return applicationProperties;
|
||||
}
|
||||
|
||||
|
@ -161,6 +176,7 @@ public class AMQPMessage extends RefCountMessage {
|
|||
parsedHeaders = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.apache.activemq.artemis.api.core.Message setConnectionID(String connectionID) {
|
||||
this.connectionID = connectionID;
|
||||
|
@ -172,7 +188,6 @@ public class AMQPMessage extends RefCountMessage {
|
|||
return connectionID;
|
||||
}
|
||||
|
||||
|
||||
public MessageAnnotations getMessageAnnotations() {
|
||||
parseHeaders();
|
||||
return _messageAnnotations;
|
||||
|
@ -202,7 +217,6 @@ public class AMQPMessage extends RefCountMessage {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void setSymbol(String symbol, Object value) {
|
||||
setSymbol(Symbol.getSymbol(symbol), value);
|
||||
}
|
||||
|
@ -231,11 +245,9 @@ public class AMQPMessage extends RefCountMessage {
|
|||
return null;
|
||||
} */
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SimpleString getGroupID() {
|
||||
parseHeaders();
|
||||
|
@ -247,7 +259,6 @@ public class AMQPMessage extends RefCountMessage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getScheduledDeliveryTime() {
|
||||
|
||||
|
@ -339,15 +350,19 @@ public class AMQPMessage extends RefCountMessage {
|
|||
this.expiration = _properties.getAbsoluteExpiryTime().getTime();
|
||||
}
|
||||
|
||||
if (buffer.hasRemaining()) {
|
||||
section = (Section) decoder.readObject();
|
||||
} else {
|
||||
// We don't read the next section on purpose, as we will parse ApplicationProperties
|
||||
// lazily
|
||||
section = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (section instanceof ApplicationProperties) {
|
||||
applicationProperties = (ApplicationProperties) section;
|
||||
} else {
|
||||
if (buffer.hasRemaining()) {
|
||||
this.appLocation = buffer.position();
|
||||
} else {
|
||||
this.appLocation = -1;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
decoder.setByteBuffer(null);
|
||||
|
@ -446,13 +461,11 @@ public class AMQPMessage extends RefCountMessage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getDuplicateProperty() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public org.apache.activemq.artemis.api.core.Message setDurable(boolean durable) {
|
||||
return null;
|
||||
|
@ -842,8 +855,7 @@ public class AMQPMessage extends RefCountMessage {
|
|||
@Override
|
||||
public int getMemoryEstimate() {
|
||||
if (memoryEstimate == -1) {
|
||||
memoryEstimate = memoryOffset +
|
||||
(data != null ? data.capacity() : 0);
|
||||
memoryEstimate = memoryOffset + (data != null ? data.capacity() : 0);
|
||||
}
|
||||
|
||||
return memoryEstimate;
|
||||
|
@ -858,7 +870,6 @@ public class AMQPMessage extends RefCountMessage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SimpleString getReplyTo() {
|
||||
if (getProperties() != null) {
|
||||
|
@ -877,7 +888,6 @@ public class AMQPMessage extends RefCountMessage {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getPersistSize() {
|
||||
checkBuffer();
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFound
|
|||
import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException;
|
||||
import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle;
|
||||
import org.apache.activemq.artemis.protocol.amqp.proton.transaction.ProtonTransactionImpl;
|
||||
import org.apache.activemq.artemis.protocol.amqp.util.CreditsSemaphore;
|
||||
import org.apache.activemq.artemis.reader.MessageUtil;
|
||||
import org.apache.activemq.artemis.selector.filter.FilterException;
|
||||
import org.apache.activemq.artemis.selector.impl.SelectorParser;
|
||||
|
@ -89,7 +88,6 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
|
|||
private boolean multicast;
|
||||
//todo get this from somewhere
|
||||
private RoutingType defaultRoutingType = RoutingType.ANYCAST;
|
||||
protected CreditsSemaphore creditsSemaphore = new CreditsSemaphore(0);
|
||||
private RoutingType routingTypeToUse = defaultRoutingType;
|
||||
private boolean shared = false;
|
||||
private boolean global = false;
|
||||
|
@ -110,7 +108,6 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
|
|||
|
||||
@Override
|
||||
public void onFlow(int currentCredits, boolean drain) {
|
||||
this.creditsSemaphore.setCredits(currentCredits);
|
||||
sessionSPI.onFlowConsumer(brokerConsumer, currentCredits, drain);
|
||||
}
|
||||
|
||||
|
@ -590,16 +587,6 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!creditsSemaphore.tryAcquire()) {
|
||||
try {
|
||||
creditsSemaphore.acquire();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
// nothing to be done here.. we just keep going
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// presettle means we can settle the message on the dealer side before we send it, i.e.
|
||||
// for browsers
|
||||
boolean preSettle = sender.getRemoteSenderSettleMode() == SenderSettleMode.SETTLED;
|
||||
|
|
Loading…
Reference in New Issue