ARTEMIS-3482 Removing non used methods and some reorg on message methods

This commit is contained in:
Clebert Suconic 2021-09-14 21:34:56 -04:00 committed by clebertsuconic
parent 6ec4ab6766
commit c3b403a980
9 changed files with 7 additions and 78 deletions

View File

@ -29,6 +29,11 @@ import org.apache.activemq.artemis.core.message.impl.CoreMessage;
*/ */
public interface ICoreMessage extends Message { public interface ICoreMessage extends Message {
/** The buffer will belong to this message, until release is called. */
Message setBuffer(ByteBuf buffer);
ByteBuf getBuffer();
LargeBodyReader getLargeBodyReader() throws ActiveMQException; LargeBodyReader getLargeBodyReader() throws ActiveMQException;
int getHeadersAndPropertiesEncodeSize(); int getHeadersAndPropertiesEncodeSize();

View File

@ -298,11 +298,6 @@ public interface Message {
Message setReplyTo(SimpleString address); Message setReplyTo(SimpleString address);
/** The buffer will belong to this message, until release is called. */
Message setBuffer(ByteBuf buffer);
ByteBuf getBuffer();
/** It will generate a new instance of the message encode, being a deep copy, new properties, new everything */ /** It will generate a new instance of the message encode, being a deep copy, new properties, new everything */
Message copy(); Message copy();
@ -462,14 +457,6 @@ public interface Message {
void reloadPersistence(ActiveMQBuffer record, CoreMessageObjectPools pools); void reloadPersistence(ActiveMQBuffer record, CoreMessageObjectPools pools);
default void releaseBuffer() {
ByteBuf buffer = getBuffer();
if (buffer != null) {
buffer.release();
}
setBuffer(null);
}
default void reencode() { default void reencode() {
// only valid probably on AMQP // only valid probably on AMQP
} }

View File

@ -130,12 +130,10 @@ public class MessageInternalImpl implements MessageInternal {
* *
* @param buffer * @param buffer
*/ */
@Override
public Message setBuffer(ByteBuf buffer) { public Message setBuffer(ByteBuf buffer) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public ByteBuf getBuffer() { public ByteBuf getBuffer() {
return message.getBuffer(); return message.getBuffer();
} }

View File

@ -103,8 +103,6 @@ public class AMQPLargeMessage extends AMQPMessage implements LargeServerMessage
*/ */
private Boolean fileDurable; private Boolean fileDurable;
private volatile AmqpReadableBuffer parsingData;
private StorageManager storageManager; private StorageManager storageManager;
/** this is used to parse the initial packets from the buffer */ /** this is used to parse the initial packets from the buffer */
@ -306,11 +304,7 @@ public class AMQPLargeMessage extends AMQPMessage implements LargeServerMessage
@Override @Override
public ReadableBuffer getData() { public ReadableBuffer getData() {
if (parsingData == null) { throw new UnsupportedOperationException("Method not supported with Large Messages");
throw new RuntimeException("AMQP Large Message is not open");
}
return parsingData;
} }
public void parseHeader(ReadableBuffer buffer) { public void parseHeader(ReadableBuffer buffer) {
@ -406,11 +400,6 @@ public class AMQPLargeMessage extends AMQPMessage implements LargeServerMessage
} }
} }
@Override
public ReadableBuffer getSendBuffer(int deliveryCount, MessageReference reference) {
return getData().rewind();
}
@Override @Override
public Message toMessage() { public Message toMessage() {
return this; return this;

View File

@ -26,7 +26,6 @@ import java.util.Set;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator; import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.Unpooled;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException; import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
@ -812,26 +811,6 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache.
modified = true; modified = true;
} }
@Override
public final ByteBuf getBuffer() {
if (getData() == null) {
return null;
} else {
if (getData() instanceof NettyReadable) {
return ((NettyReadable) getData()).getByteBuf();
} else {
return Unpooled.wrappedBuffer(getData().byteBuffer());
}
}
}
@Override
public final AMQPMessage setBuffer(ByteBuf buffer) {
// If this is ever called we would be in a highly unfortunate state
//this.data = null;
return this;
}
@Override @Override
public abstract int getEncodeSize(); public abstract int getEncodeSize();

View File

@ -258,7 +258,7 @@ public class MQTTRetainMessageManagerTest {
final LinkedListIterator<MessageReference> browserIterator = queue.browserIterator(); final LinkedListIterator<MessageReference> browserIterator = queue.browserIterator();
browserIterator.forEachRemaining(messageReference -> { browserIterator.forEachRemaining(messageReference -> {
final Message message = messageReference.getMessage(); final Message message = messageReference.getMessage();
final String body = message.getBuffer().toString(StandardCharsets.UTF_8); final String body = message.toCore().getBuffer().toString(StandardCharsets.UTF_8);
log.infof("[MQTT][%s][%s][%s]", retainAddress, message, body); log.infof("[MQTT][%s][%s][%s]", retainAddress, message, body);
}); });
} }

View File

@ -68,21 +68,11 @@ public class OpenwireMessage implements Message {
return null; return null;
} }
@Override
public Message setBuffer(ByteBuf buffer) {
return null;
}
@Override @Override
public int getDurableCount() { public int getDurableCount() {
return 0; return 0;
} }
@Override
public ByteBuf getBuffer() {
return null;
}
@Override @Override
public Message copy() { public Message copy() {
return null; return null;

View File

@ -431,15 +431,6 @@ public class ScheduledDeliveryHandlerTest extends Assert {
return null; return null;
} }
@Override
public Message setBuffer(ByteBuf buffer) {
return null;
}
@Override
public ByteBuf getBuffer() {
return null;
}
@Override @Override
public Message setAddress(String address) { public Message setAddress(String address) {
return null; return null;

View File

@ -500,16 +500,6 @@ public class AcknowledgeTest extends ActiveMQTestBase {
return null; return null;
} }
@Override
public Message setBuffer(ByteBuf buffer) {
return null;
}
@Override
public ByteBuf getBuffer() {
return null;
}
@Override @Override
public Message setAddress(String address) { public Message setAddress(String address) {
return null; return null;