You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/03/02 15:05:35 UTC

[01/29] activemq-artemis git commit: NO-JIRA Passing the logger manager on spawned VMs through the testsuite [Forced Update!]

Repository: activemq-artemis
Updated Branches:
  refs/heads/artemis-1009 52635b09a -> 9d3260b90 (forced update)


NO-JIRA Passing the logger manager on spawned VMs through the testsuite


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/61e10fe6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/61e10fe6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/61e10fe6

Branch: refs/heads/artemis-1009
Commit: 61e10fe65a560ebf740a620c69a5cbbdf938a2bc
Parents: 6f496e7
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Mar 2 09:52:56 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:04:28 2017 -0500

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61e10fe6/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
index 703c848..1ed0e73 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
@@ -101,6 +101,10 @@ public final class SpawnedVMSupport {
          }
       }
 
+      // The logs will be huge if you don't set this
+      commandList.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
+      commandList.add("-Dlogging.configuration=file:../config/logging.properties");
+
       commandList.add("-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir", "./tmp"));
       commandList.add("-Djava.library.path=" + System.getProperty("java.library.path", "./native/bin"));
 


[16/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
index 548b62c..b997d80 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
@@ -17,10 +17,12 @@
 
 package org.apache.activemq.artemis.core.protocol.mqtt;
 
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 
@@ -43,11 +45,11 @@ public class MQTTSessionCallback implements SessionCallback {
 
    @Override
    public int sendMessage(MessageReference reference,
-                          ServerMessage message,
+                          Message message,
                           ServerConsumer consumer,
                           int deliveryCount) {
       try {
-         session.getMqttPublishManager().sendMessage(message, consumer, deliveryCount);
+         session.getMqttPublishManager().sendMessage((CoreMessage)message, consumer, deliveryCount);
       } catch (Exception e) {
          log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
       }
@@ -70,7 +72,7 @@ public class MQTTSessionCallback implements SessionCallback {
 
    @Override
    public int sendLargeMessage(MessageReference reference,
-                               ServerMessage message,
+                               Message message,
                                ServerConsumer consumer,
                                long bodySize,
                                int deliveryCount) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
index 7bc6b84..6891497 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
@@ -28,8 +28,7 @@ import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.config.WildcardConfiguration;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 
 /**
  * A Utility Class for creating Server Side objects and converting MQTT concepts to/from Artemis.
@@ -93,13 +92,13 @@ public class MQTTUtil {
       return MQTT_RETAIN_ADDRESS_PREFIX + MQTT_WILDCARD.convert(filter, wildcardConfiguration);
    }
 
-   private static ServerMessage createServerMessage(MQTTSession session,
+   private static Message createServerMessage(MQTTSession session,
                                                     SimpleString address,
                                                     boolean retain,
                                                     int qos) {
       long id = session.getServer().getStorageManager().generateID();
 
-      ServerMessageImpl message = new ServerMessageImpl(id, DEFAULT_SERVER_MESSAGE_BUFFER_SIZE);
+      CoreMessage message = new CoreMessage(id, DEFAULT_SERVER_MESSAGE_BUFFER_SIZE);
       message.setAddress(address);
       message.putBooleanProperty(new SimpleString(MQTT_MESSAGE_RETAIN_KEY), retain);
       message.putIntProperty(new SimpleString(MQTT_QOS_LEVEL_KEY), qos);
@@ -107,21 +106,21 @@ public class MQTTUtil {
       return message;
    }
 
-   public static ServerMessage createServerMessageFromByteBuf(MQTTSession session,
+   public static Message createServerMessageFromByteBuf(MQTTSession session,
                                                               String topic,
                                                               boolean retain,
                                                               int qos,
                                                               ByteBuf payload) {
       String coreAddress = convertMQTTAddressFilterToCore(topic, session.getWildcardConfiguration());
-      ServerMessage message = createServerMessage(session, new SimpleString(coreAddress), retain, qos);
+      Message message = createServerMessage(session, new SimpleString(coreAddress), retain, qos);
 
       // FIXME does this involve a copy?
       message.getBodyBuffer().writeBytes(new ChannelBufferWrapper(payload), payload.readableBytes());
       return message;
    }
 
-   public static ServerMessage createPubRelMessage(MQTTSession session, SimpleString address, int messageId) {
-      ServerMessage message = createServerMessage(session, address, false, 1);
+   public static Message createPubRelMessage(MQTTSession session, SimpleString address, int messageId) {
+      Message message = createServerMessage(session, address, false, 1);
       message.putIntProperty(new SimpleString(MQTTUtil.MQTT_MESSAGE_ID_KEY), messageId);
       message.putIntProperty(new SimpleString(MQTTUtil.MQTT_MESSAGE_TYPE_KEY), MqttMessageType.PUBREL.value());
       return message;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
index 9b27b81..550a63a 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
@@ -36,11 +36,10 @@ import java.util.zip.InflaterOutputStream;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer;
 import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil;
 import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.reader.MessageUtil;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
 import org.apache.activemq.artemis.utils.DataConstants;
@@ -102,16 +101,16 @@ public class OpenWireMessageConverter implements MessageConverter {
    }
 
    @Override
-   public Object outbound(ServerMessage message, int deliveryCount) {
+   public Object outbound(org.apache.activemq.artemis.api.core.Message message, int deliveryCount) {
       // TODO: implement this
       return null;
    }
 
    @Override
-   public ServerMessage inbound(Object message) throws Exception {
+   public org.apache.activemq.artemis.api.core.Message inbound(Object message) throws Exception {
 
       Message messageSend = (Message) message;
-      ServerMessageImpl coreMessage = new ServerMessageImpl(-1, messageSend.getSize());
+      CoreMessage coreMessage = new CoreMessage(-1, messageSend.getSize());
 
       String type = messageSend.getType();
       if (type != null) {
@@ -157,7 +156,7 @@ public class OpenWireMessageConverter implements MessageConverter {
                mdataIn.close();
                TypedProperties props = new TypedProperties();
                loadMapIntoProperties(props, map);
-               props.encode(body);
+               props.encode(body.byteBuf());
                break;
             case org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE:
                if (messageCompressed) {
@@ -415,8 +414,9 @@ public class OpenWireMessageConverter implements MessageConverter {
    }
 
    public static MessageDispatch createMessageDispatch(MessageReference reference,
-                                                       ServerMessage message,
+                                                       org.apache.activemq.artemis.api.core.Message message,
                                                        AMQConsumer consumer) throws IOException, JMSException {
+      // TODO-now: use new Encode here
       ActiveMQMessage amqMessage = toAMQMessage(reference, message, consumer.getMarshaller(), consumer.getOpenwireDestination());
 
       //we can use core message id for sequenceId
@@ -433,7 +433,7 @@ public class OpenWireMessageConverter implements MessageConverter {
    }
 
    private static ActiveMQMessage toAMQMessage(MessageReference reference,
-                                               ServerMessage coreMessage,
+                                               org.apache.activemq.artemis.api.core.Message coreMessage,
                                                WireFormat marshaller,
                                                ActiveMQDestination actualDestination) throws IOException {
       ActiveMQMessage amqMsg = null;
@@ -476,7 +476,7 @@ public class OpenWireMessageConverter implements MessageConverter {
       }
       amqMsg.setBrokerInTime(brokerInTime);
 
-      ActiveMQBuffer buffer = coreMessage.getBodyBufferDuplicate();
+      ActiveMQBuffer buffer = coreMessage.getReadOnlyBodyBuffer();
       Boolean compressProp = (Boolean) coreMessage.getObjectProperty(AMQ_MSG_COMPRESSED);
       boolean isCompressed = compressProp == null ? false : compressProp.booleanValue();
       amqMsg.setCompressed(isCompressed);
@@ -503,7 +503,7 @@ public class OpenWireMessageConverter implements MessageConverter {
                TypedProperties mapData = new TypedProperties();
                //it could be a null map
                if (buffer.readableBytes() > 0) {
-                  mapData.decode(buffer);
+                  mapData.decode(buffer.byteBuf());
                   Map<String, Object> map = mapData.getMap();
                   ByteArrayOutputStream out = new ByteArrayOutputStream(mapData.getEncodeSize());
                   OutputStream os = out;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
index f471a2a..6f83c2d 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.advisory.AdvisorySupport;
 import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl;
 import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
@@ -35,7 +36,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
@@ -208,7 +208,7 @@ public class AMQConsumer {
 
    }
 
-   public int handleDeliver(MessageReference reference, ServerMessage message, int deliveryCount) {
+   public int handleDeliver(MessageReference reference, Message message, int deliveryCount) {
       MessageDispatch dispatch;
       try {
          if (messagePullHandler != null && !messagePullHandler.checkForcedConsumer(message)) {
@@ -394,7 +394,7 @@ public class AMQConsumer {
          }
       }
 
-      public boolean checkForcedConsumer(ServerMessage message) {
+      public boolean checkForcedConsumer(Message message) {
          if (message.containsProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE)) {
             if (next >= 0) {
                if (timeout <= 0) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index 79004ae..1b7ed43 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -36,7 +36,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.reader.MessageUtil;
@@ -231,7 +230,7 @@ public class AMQSession implements SessionCallback {
 
    @Override
    public int sendMessage(MessageReference reference,
-                          ServerMessage message,
+                          org.apache.activemq.artemis.api.core.Message message,
                           ServerConsumer consumer,
                           int deliveryCount) {
       AMQConsumer theConsumer = (AMQConsumer) consumer.getProtocolData();
@@ -240,7 +239,7 @@ public class AMQSession implements SessionCallback {
 
    @Override
    public int sendLargeMessage(MessageReference reference,
-                               ServerMessage message,
+                               org.apache.activemq.artemis.api.core.Message message,
                                ServerConsumer consumerID,
                                long bodySize,
                                int deliveryCount) {
@@ -296,7 +295,7 @@ public class AMQSession implements SessionCallback {
          actualDestinations = new ActiveMQDestination[]{destination};
       }
 
-      ServerMessage originalCoreMsg = getConverter().inbound(messageSend);
+      org.apache.activemq.artemis.api.core.Message originalCoreMsg = getConverter().inbound(messageSend);
 
       if (connection.isNoLocal()) {
          //Note: advisory messages are dealt with in
@@ -324,7 +323,7 @@ public class AMQSession implements SessionCallback {
       for (int i = 0; i < actualDestinations.length; i++) {
          ActiveMQDestination dest = actualDestinations[i];
          SimpleString address = new SimpleString(dest.getPhysicalName());
-         ServerMessage coreMsg = originalCoreMsg.copy();
+         org.apache.activemq.artemis.api.core.Message coreMsg = originalCoreMsg.copy();
          coreMsg.setAddress(address);
 
          if (actualDestinations[i].isQueue()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
index 5355c63..2686907 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
@@ -18,8 +18,9 @@ package org.apache.activemq.artemis.core.protocol.openwire.util;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.config.WildcardConfiguration;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
@@ -53,8 +54,8 @@ public class OpenWireUtil {
     * set on publish/send so a divert or wildcard may mean thats its different to the destination subscribed to by the
     * consumer
     */
-   public static ActiveMQDestination toAMQAddress(ServerMessage message, ActiveMQDestination actualDestination) {
-      String address = message.getAddress().toString();
+   public static ActiveMQDestination toAMQAddress(Message message, ActiveMQDestination actualDestination) {
+      String address = message.getAddress();
       String strippedAddress = address;//.replace(JMS_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TEMP_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TOPIC_ADDRESS_PREFIX, "").replace(JMS_TEMP_TOPIC_ADDRESS_PREFIX, "");
       if (actualDestination.isQueue()) {
          return new ActiveMQQueue(strippedAddress);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java
index 861c524..d377abd 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/ActiveMQStompProtocolMessageBundle.java
@@ -16,7 +16,6 @@
  */
 package org.apache.activemq.artemis.core.protocol.stomp;
 
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.jboss.logging.Messages;
 import org.jboss.logging.annotations.Cause;
 import org.jboss.logging.annotations.Message;
@@ -71,7 +70,7 @@ public interface ActiveMQStompProtocolMessageBundle {
    ActiveMQStompException invalidConnection();
 
    @Message(id = 339011, value = "Error sending message {0}", format = Message.Format.MESSAGE_FORMAT)
-   ActiveMQStompException errorSendMessage(ServerMessageImpl message, @Cause Exception e);
+   ActiveMQStompException errorSendMessage(org.apache.activemq.artemis.api.core.Message message, @Cause Exception e);
 
    @Message(id = 339012, value = "Error beginning a transaction {0}", format = Message.Format.MESSAGE_FORMAT)
    ActiveMQStompException errorBeginTx(String txID, @Cause Exception e);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index c004a0e..c64c1ea 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -30,18 +30,18 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.stomp.v10.StompFrameHandlerV10;
 import org.apache.activemq.artemis.core.protocol.stomp.v12.StompFrameHandlerV12;
 import org.apache.activemq.artemis.core.remoting.CloseListener;
 import org.apache.activemq.artemis.core.remoting.FailureListener;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
@@ -569,7 +569,7 @@ public final class StompConnection implements RemotingConnection {
       return valid;
    }
 
-   public ServerMessageImpl createServerMessage() {
+   public CoreMessage createServerMessage() {
       return manager.createServerMessage();
    }
 
@@ -598,7 +598,7 @@ public final class StompConnection implements RemotingConnection {
       }
    }
 
-   protected void sendServerMessage(ServerMessageImpl message, String txID) throws ActiveMQStompException {
+   protected void sendServerMessage(Message message, String txID) throws ActiveMQStompException {
       StompSession stompSession = getSession(txID);
 
       if (stompSession.isNoLocal()) {
@@ -611,7 +611,7 @@ public final class StompConnection implements RemotingConnection {
          if (minLargeMessageSize == -1 || (message.getBodyBuffer().writerIndex() < minLargeMessageSize)) {
             stompSession.sendInternal(message, false);
          } else {
-            stompSession.sendInternalLarge(message, false);
+            stompSession.sendInternalLarge((CoreMessage)message, false);
          }
       } catch (Exception e) {
          throw BUNDLE.errorSendMessage(message, e).setHandler(frameHandler);
@@ -726,7 +726,7 @@ public final class StompConnection implements RemotingConnection {
       return SERVER_NAME;
    }
 
-   public StompFrame createStompMessage(ServerMessage serverMessage,
+   public StompFrame createStompMessage(Message serverMessage,
                                         StompSubscription subscription,
                                         int deliveryCount) throws Exception {
       return frameHandler.createMessageFrame(serverMessage, subscription, deliveryCount);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
index 54339a4..2be0be4 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompProtocolManager.java
@@ -33,12 +33,12 @@ import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.core.io.IOCallback;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnection;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.ServerSession;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.spi.core.protocol.AbstractProtocolManager;
 import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
@@ -345,8 +345,8 @@ public class StompProtocolManager extends AbstractProtocolManager<StompFrame, St
       return validated;
    }
 
-   public ServerMessageImpl createServerMessage() {
-      return new ServerMessageImpl(server.getStorageManager().generateID(), 512);
+   public CoreMessage createServerMessage() {
+      return new CoreMessage(server.getStorageManager().generateID(), 512);
    }
 
    public void commitTransaction(StompConnection connection, String txID) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
index 1e103e9..d2d42b7 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
@@ -28,20 +28,18 @@ import java.util.zip.Inflater;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
@@ -127,11 +125,13 @@ public class StompSession implements SessionCallback {
 
    @Override
    public int sendMessage(MessageReference ref,
-                          ServerMessage serverMessage,
+                          Message serverMessage,
                           final ServerConsumer consumer,
                           int deliveryCount) {
+
+      //TODO-now: fix encoders
       LargeServerMessageImpl largeMessage = null;
-      ServerMessage newServerMessage = serverMessage;
+      Message newServerMessage = serverMessage;
       try {
          StompSubscription subscription = subscriptions.get(consumer.getID());
          StompFrame frame = null;
@@ -139,20 +139,23 @@ public class StompSession implements SessionCallback {
             newServerMessage = serverMessage.copy();
 
             largeMessage = (LargeServerMessageImpl) serverMessage;
-            BodyEncoder encoder = largeMessage.getBodyEncoder();
+            LargeBodyEncoder encoder = largeMessage.getBodyEncoder();
             encoder.open();
             int bodySize = (int) encoder.getLargeBodySize();
 
+            // TODO-now: Convert large mesasge body into the stomp message
             //large message doesn't have a body.
-            ((ServerMessageImpl) newServerMessage).createBody(bodySize);
-            encoder.encode(newServerMessage.getBodyBuffer(), bodySize);
-            encoder.close();
+            // ((Message) newServerMessage).createBody(bodySize);
+//            encoder.encode(((ServerMessage)newServerMessage).getBodyBuffer(), bodySize);
+//            encoder.close();
+
+            throw new RuntimeException("Large message body won't work with stomp now");
          }
 
          if (serverMessage.getBooleanProperty(Message.HDR_LARGE_COMPRESSED)) {
             //decompress
             ActiveMQBuffer qbuff = newServerMessage.getBodyBuffer();
-            int bytesToRead = qbuff.writerIndex() - MessageImpl.BODY_OFFSET;
+            int bytesToRead = qbuff.writerIndex() - CoreMessage.BODY_OFFSET;
             Inflater inflater = new Inflater();
             inflater.setInput(ByteUtil.getActiveArray(qbuff.readBytes(bytesToRead).toByteBuffer()));
 
@@ -219,7 +222,7 @@ public class StompSession implements SessionCallback {
 
    @Override
    public int sendLargeMessage(MessageReference ref,
-                               ServerMessage msg,
+                               Message msg,
                                ServerConsumer consumer,
                                long bodySize,
                                int deliveryCount) {
@@ -370,11 +373,11 @@ public class StompSession implements SessionCallback {
       this.noLocal = noLocal;
    }
 
-   public void sendInternal(ServerMessageImpl message, boolean direct) throws Exception {
+   public void sendInternal(Message message, boolean direct) throws Exception {
       session.send(message, direct);
    }
 
-   public void sendInternalLarge(ServerMessageImpl message, boolean direct) throws Exception {
+   public void sendInternalLarge(CoreMessage message, boolean direct) throws Exception {
       int headerSize = message.getHeadersAndPropertiesEncodeSize();
       if (headerSize >= connection.getMinLargeMessageSize()) {
          throw BUNDLE.headerTooBig();
@@ -384,7 +387,7 @@ public class StompSession implements SessionCallback {
       long id = storageManager.generateID();
       LargeServerMessage largeMessage = storageManager.createLargeMessage(id, message);
 
-      byte[] bytes = new byte[message.getBodyBuffer().writerIndex() - MessageImpl.BODY_OFFSET];
+      byte[] bytes = new byte[message.getBodyBuffer().writerIndex() - CoreMessage.BODY_OFFSET];
       message.getBodyBuffer().readBytes(bytes);
 
       largeMessage.addBytes(bytes);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java
index affab84..7db9d82 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompUtils.java
@@ -24,8 +24,6 @@ import java.util.Set;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.reader.MessageUtil;
 
 public class StompUtils {
@@ -37,7 +35,7 @@ public class StompUtils {
 
    // Static --------------------------------------------------------
 
-   public static void copyStandardHeadersFromFrameToMessage(StompFrame frame, ServerMessageImpl msg) throws Exception {
+   public static void copyStandardHeadersFromFrameToMessage(StompFrame frame, Message msg) throws Exception {
       Map<String, String> headers = new HashMap<>(frame.getHeadersMap());
 
       String priority = headers.remove(Stomp.Headers.Send.PRIORITY);
@@ -79,7 +77,7 @@ public class StompUtils {
       }
    }
 
-   public static void copyStandardHeadersFromMessageToFrame(MessageInternal message,
+   public static void copyStandardHeadersFromMessageToFrame(Message message,
                                                             StompFrame command,
                                                             int deliveryCount) throws Exception {
       command.addHeader(Stomp.Headers.Message.MESSAGE_ID, String.valueOf(message.getMessageID()));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java
index f91ba82..8d13613 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/VersionedStompFrameHandler.java
@@ -21,15 +21,13 @@ import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.stomp.Stomp.Headers;
 import org.apache.activemq.artemis.core.protocol.stomp.v10.StompFrameHandlerV10;
 import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11;
 import org.apache.activemq.artemis.core.protocol.stomp.v12.StompFrameHandlerV12;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.utils.DataConstants;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 
@@ -180,7 +178,7 @@ public abstract class VersionedStompFrameHandler {
 
          long timestamp = System.currentTimeMillis();
 
-         ServerMessageImpl message = connection.createServerMessage();
+         CoreMessage message = connection.createServerMessage();
          if (routingType != null) {
             message.putByteProperty(Message.HDR_ROUTING_TYPE, routingType.getType());
          }
@@ -289,7 +287,7 @@ public abstract class VersionedStompFrameHandler {
       return response;
    }
 
-   public StompFrame createMessageFrame(ServerMessage serverMessage,
+   public StompFrame createMessageFrame(Message serverMessage,
                                         StompSubscription subscription,
                                         int deliveryCount) throws Exception {
       StompFrame frame = createStompFrame(Stomp.Responses.MESSAGE);
@@ -298,11 +296,12 @@ public abstract class VersionedStompFrameHandler {
          frame.addHeader(Stomp.Headers.Message.SUBSCRIPTION, subscription.getID());
       }
 
-      ActiveMQBuffer buffer = serverMessage.getBodyBufferDuplicate();
+      // TODO-now fix encoders
+      ActiveMQBuffer buffer = serverMessage.getReadOnlyBodyBuffer();
 
-      int bodyPos = serverMessage.getEndOfBodyPosition() == -1 ? buffer.writerIndex() : serverMessage.getEndOfBodyPosition();
+      int bodyPos = ((CoreMessage)serverMessage).getEndOfBodyPosition() == -1 ? buffer.writerIndex() : ((CoreMessage)serverMessage).getEndOfBodyPosition();
 
-      buffer.readerIndex(MessageImpl.BUFFER_HEADER_SPACE + DataConstants.SIZE_INT);
+      buffer.readerIndex(CoreMessage.BUFFER_HEADER_SPACE + DataConstants.SIZE_INT);
 
       int size = bodyPos - buffer.readerIndex();
 
@@ -321,7 +320,7 @@ public abstract class VersionedStompFrameHandler {
       }
       frame.setByteBody(data);
 
-      StompUtils.copyStandardHeadersFromMessageToFrame(serverMessage, frame, deliveryCount);
+      StompUtils.copyStandardHeadersFromMessageToFrame((serverMessage), frame, deliveryCount);
 
       return frame;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java
index 6b211d2..b14605d 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameHandlerV12.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.core.protocol.stomp.v12;
 
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompException;
 import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
 import org.apache.activemq.artemis.core.protocol.stomp.StompConnection;
@@ -27,7 +28,6 @@ import org.apache.activemq.artemis.core.protocol.stomp.StompSubscription;
 import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11;
 import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameV11;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 
 import static org.apache.activemq.artemis.core.protocol.stomp.ActiveMQStompProtocolMessageBundle.BUNDLE;
@@ -48,7 +48,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 {
    }
 
    @Override
-   public StompFrame createMessageFrame(ServerMessage serverMessage,
+   public StompFrame createMessageFrame(Message serverMessage,
                                         StompSubscription subscription,
                                         int deliveryCount) throws Exception {
       StompFrame frame = super.createMessageFrame(serverMessage, subscription, deliveryCount);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index 7881470..30d6668 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -750,10 +750,6 @@ public interface Configuration {
 
    Configuration setLogJournalWriteRate(boolean rate);
 
-   int getJournalPerfBlastPages();
-
-   Configuration setJournalPerfBlastPages(int pages);
-
    long getServerDumpInterval();
 
    Configuration setServerDumpInterval(long interval);
@@ -766,10 +762,6 @@ public interface Configuration {
 
    Configuration setMemoryMeasureInterval(long memoryMeasureInterval);
 
-   boolean isRunSyncSpeedTest();
-
-   Configuration setRunSyncSpeedTest(boolean run);
-
    // Paging Properties --------------------------------------------------------------------
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index f4eda91..329f654 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -193,10 +193,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
 
    protected boolean logJournalWriteRate = ActiveMQDefaultConfiguration.isDefaultJournalLogWriteRate();
 
-   protected int journalPerfBlastPages = ActiveMQDefaultConfiguration.getDefaultJournalPerfBlastPages();
-
-   protected boolean runSyncSpeedTest = ActiveMQDefaultConfiguration.isDefaultRunSyncSpeedTest();
-
    private WildcardConfiguration wildcardConfiguration = new WildcardConfiguration();
 
    private boolean messageCounterEnabled = ActiveMQDefaultConfiguration.isDefaultMessageCounterEnabled();
@@ -854,28 +850,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
    }
 
    @Override
-   public int getJournalPerfBlastPages() {
-      return journalPerfBlastPages;
-   }
-
-   @Override
-   public ConfigurationImpl setJournalPerfBlastPages(final int journalPerfBlastPages) {
-      this.journalPerfBlastPages = journalPerfBlastPages;
-      return this;
-   }
-
-   @Override
-   public boolean isRunSyncSpeedTest() {
-      return runSyncSpeedTest;
-   }
-
-   @Override
-   public ConfigurationImpl setRunSyncSpeedTest(final boolean run) {
-      runSyncSpeedTest = run;
-      return this;
-   }
-
-   @Override
    public boolean isCreateBindingsDir() {
       return createBindingsDir;
    }
@@ -1556,7 +1530,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
       result = prime * result + journalMaxIO_AIO;
       result = prime * result + journalMaxIO_NIO;
       result = prime * result + journalMinFiles;
-      result = prime * result + journalPerfBlastPages;
       result = prime * result + (journalSyncNonTransactional ? 1231 : 1237);
       result = prime * result + (journalSyncTransactional ? 1231 : 1237);
       result = prime * result + ((journalType == null) ? 0 : journalType.hashCode());
@@ -1580,7 +1553,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
       result = prime * result + (persistIDCache ? 1231 : 1237);
       result = prime * result + (persistenceEnabled ? 1231 : 1237);
       result = prime * result + ((queueConfigurations == null) ? 0 : queueConfigurations.hashCode());
-      result = prime * result + (runSyncSpeedTest ? 1231 : 1237);
       result = prime * result + scheduledThreadPoolMaxSize;
       result = prime * result + (securityEnabled ? 1231 : 1237);
       result = prime * result + (populateValidatedUser ? 1231 : 1237);
@@ -1723,8 +1695,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
          return false;
       if (journalMinFiles != other.journalMinFiles)
          return false;
-      if (journalPerfBlastPages != other.journalPerfBlastPages)
-         return false;
       if (journalSyncNonTransactional != other.journalSyncNonTransactional)
          return false;
       if (journalSyncTransactional != other.journalSyncTransactional)
@@ -1793,8 +1763,6 @@ public class ConfigurationImpl implements Configuration, Serializable {
             return false;
       } else if (!queueConfigurations.equals(other.queueConfigurations))
          return false;
-      if (runSyncSpeedTest != other.runSyncSpeedTest)
-         return false;
       if (scheduledThreadPoolMaxSize != other.scheduledThreadPoolMaxSize)
          return false;
       if (securityEnabled != other.securityEnabled)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index cea0598..4055b5c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -548,10 +548,6 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
 
       config.setLogJournalWriteRate(getBoolean(e, "log-journal-write-rate", ActiveMQDefaultConfiguration.isDefaultJournalLogWriteRate()));
 
-      config.setJournalPerfBlastPages(getInteger(e, "perf-blast-pages", ActiveMQDefaultConfiguration.getDefaultJournalPerfBlastPages(), Validators.MINUS_ONE_OR_GT_ZERO));
-
-      config.setRunSyncSpeedTest(getBoolean(e, "run-sync-speed-test", config.isRunSyncSpeedTest()));
-
       if (e.hasAttribute("wild-card-routing-enabled")) {
          config.setWildcardRoutingEnabled(getBoolean(e, "wild-card-routing-enabled", config.isWildcardRoutingEnabled()));
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/Filter.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/Filter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/Filter.java
index 41d5e54..3737e19 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/Filter.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/Filter.java
@@ -16,8 +16,8 @@
  */
 package org.apache.activemq.artemis.core.filter;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 public interface Filter {
 
@@ -31,7 +31,7 @@ public interface Filter {
     */
    String GENERIC_IGNORED_FILTER = "__AMQX=-1";
 
-   boolean match(ServerMessage message);
+   boolean match(Message message);
 
    SimpleString getFilterString();
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
index 0a459c9..9d321c7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
@@ -18,11 +18,11 @@ package org.apache.activemq.artemis.core.filter.impl;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.FilterConstants;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.selector.filter.BooleanExpression;
 import org.apache.activemq.artemis.selector.filter.FilterException;
 import org.apache.activemq.artemis.selector.filter.Filterable;
@@ -103,7 +103,7 @@ public class FilterImpl implements Filter {
    }
 
    @Override
-   public synchronized boolean match(final ServerMessage message) {
+   public synchronized boolean match(final Message message) {
       try {
          boolean result = booleanExpression.matches(new FilterableServerMessage(message));
          return result;
@@ -148,7 +148,7 @@ public class FilterImpl implements Filter {
 
    // Private --------------------------------------------------------------------------
 
-   private static Object getHeaderFieldValue(final ServerMessage msg, final SimpleString fieldName) {
+   private static Object getHeaderFieldValue(final Message msg, final SimpleString fieldName) {
       if (FilterConstants.ACTIVEMQ_USERID.equals(fieldName)) {
          if (msg.getUserID() == null) {
             // Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
@@ -178,9 +178,9 @@ public class FilterImpl implements Filter {
 
    private static class FilterableServerMessage implements Filterable {
 
-      private final ServerMessage message;
+      private final Message message;
 
-      private FilterableServerMessage(ServerMessage message) {
+      private FilterableServerMessage(Message message) {
          this.message = message;
       }
 
@@ -191,7 +191,7 @@ public class FilterImpl implements Filter {
             result = getHeaderFieldValue(message, new SimpleString(id));
          }
          if (result == null) {
-            result = message.getObjectProperty(new SimpleString(id));
+            result = message.getObjectProperty(id);
          }
          if (result != null) {
             if (result.getClass() == SimpleString.class) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index 09dd702..31e056c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -25,10 +25,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.AddressControl;
 import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
@@ -40,9 +42,7 @@ import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.security.SecurityStore;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -282,7 +282,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
             return null;
          }
       });
-      ServerMessageImpl message = new ServerMessageImpl(storageManager.generateID(), 50);
+      CoreMessage message = new CoreMessage(storageManager.generateID(), 50);
       for (String header : headers.keySet()) {
          message.putStringProperty(new SimpleString(header), new SimpleString(headers.get(header)));
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index 4b84909..5ecea64 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -39,7 +39,7 @@ import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
 import org.apache.activemq.artemis.core.management.impl.openmbean.OpenTypeSupport;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
 import org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterHelper;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
@@ -53,8 +53,6 @@ import org.apache.activemq.artemis.core.server.Consumer;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -609,7 +607,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
       try {
          Filter singleMessageFilter = new Filter() {
             @Override
-            public boolean match(ServerMessage message) {
+            public boolean match(Message message) {
                return message.getMessageID() == messageID;
             }
 
@@ -738,7 +736,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
             return null;
          }
       });
-      ServerMessageImpl message = new ServerMessageImpl(storageManager.generateID(), 50);
+      CoreMessage message = new CoreMessage(storageManager.generateID(), 50);
       for (String header : headers.keySet()) {
          message.putStringProperty(new SimpleString(header), new SimpleString(headers.get(header)));
       }
@@ -755,7 +753,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
       message.setAddress(queue.getAddress());
       ByteBuffer buffer = ByteBuffer.allocate(8);
       buffer.putLong(queue.getID());
-      message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+      message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array());
       postOffice.route(message, true);
       return "" + message.getMessageID();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java
index ec6848b..9f36b7f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/openmbean/OpenTypeSupport.java
@@ -35,7 +35,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 
 public final class OpenTypeSupport {
 
@@ -128,6 +128,7 @@ public final class OpenTypeSupport {
 
       public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
          Map<String, Object> rc = new HashMap<>();
+         // TODO-now: fix this
          Message m = ref.getMessage();
          rc.put(CompositeDataConstants.MESSAGE_ID, "" + m.getMessageID());
          if (m.getUserID() != null) {
@@ -143,6 +144,11 @@ public final class OpenTypeSupport {
          rc.put(CompositeDataConstants.PRIORITY, m.getPriority());
          rc.put(CompositeDataConstants.REDELIVERED, ref.getDeliveryCount() > 1);
 
+         ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer();
+         byte[] bytes = new byte[bodyCopy.readableBytes()];
+         bodyCopy.readBytes(bytes);
+         rc.put(CompositeDataConstants.BODY, bytes);
+
          Map<String, Object> propertyMap = m.toPropertyMap();
 
          rc.put(CompositeDataConstants.PROPERTIES, "" + propertyMap);
@@ -264,8 +270,8 @@ public final class OpenTypeSupport {
       @Override
       public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
          Map<String, Object> rc = super.getFields(ref);
-         ServerMessage m = ref.getMessage();
-         ActiveMQBuffer bodyCopy = m.getBodyBufferDuplicate();
+         Message m = ref.getMessage();
+         ActiveMQBuffer bodyCopy = m.getReadOnlyBodyBuffer();
          byte[] bytes = new byte[bodyCopy.readableBytes()];
          bodyCopy.readBytes(bytes);
          rc.put(CompositeDataConstants.BODY, bytes);
@@ -285,8 +291,8 @@ public final class OpenTypeSupport {
       @Override
       public Map<String, Object> getFields(MessageReference ref) throws OpenDataException {
          Map<String, Object> rc = super.getFields(ref);
-         ServerMessage m = ref.getMessage();
-         SimpleString text = m.getBodyBuffer().copy().readNullableSimpleString();
+         Message m = ref.getMessage();
+         SimpleString text = m.getReadOnlyBodyBuffer().readNullableSimpleString();
          rc.put(CompositeDataConstants.TEXT_BODY, text != null ? text.toString() : "");
          return rc;
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagedMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagedMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagedMessage.java
index 9b1e243..b3d8adb 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagedMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagedMessage.java
@@ -16,9 +16,10 @@
  */
 package org.apache.activemq.artemis.core.paging;
 
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 /**
  * A Paged message.
@@ -28,7 +29,7 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
  */
 public interface PagedMessage extends EncodingSupport {
 
-   ServerMessage getMessage();
+   Message getMessage();
 
    /**
     * The queues that were routed during paging

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
index 5ead1a2..a7de713 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
@@ -20,13 +20,15 @@ import java.io.File;
 import java.util.Collection;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RefCountMessageListener;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider;
 import org.apache.activemq.artemis.core.paging.impl.Page;
 import org.apache.activemq.artemis.core.replication.ReplicationManager;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -41,7 +43,7 @@ import org.apache.activemq.artemis.core.transaction.Transaction;
  *
  * @see PagingManager
  */
-public interface PagingStore extends ActiveMQComponent {
+public interface PagingStore extends ActiveMQComponent, RefCountMessageListener {
 
    SimpleString getAddress();
 
@@ -90,7 +92,7 @@ public interface PagingStore extends ActiveMQComponent {
     * needs to be sent to the journal
     * @throws NullPointerException if {@code readLock} is null
     */
-   boolean page(ServerMessage message, Transaction tx, RouteContextList listCtx, ReadLock readLock) throws Exception;
+   boolean page(Message message, Transaction tx, RouteContextList listCtx, ReadLock readLock) throws Exception;
 
    Page createPage(final int page) throws Exception;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java
index 768b43f..823eef4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java
@@ -20,11 +20,11 @@ import java.lang.ref.WeakReference;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.AckReason;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.jboss.logging.Logger;
@@ -41,7 +41,7 @@ public class PagedReferenceImpl implements PagedReference {
 
    private int persistedCount;
 
-   private int messageEstimate;
+   private int messageEstimate = -1;
 
    private Long consumerId;
 
@@ -64,7 +64,7 @@ public class PagedReferenceImpl implements PagedReference {
    }
 
    @Override
-   public ServerMessage getMessage() {
+   public Message getMessage() {
       return getPagedMessage().getMessage();
    }
 
@@ -93,12 +93,6 @@ public class PagedReferenceImpl implements PagedReference {
                              final PagedMessage message,
                              final PageSubscription subscription) {
       this.position = position;
-
-      if (message == null) {
-         this.messageEstimate = -1;
-      } else {
-         this.messageEstimate = message.getMessage().getMemoryEstimate();
-      }
       this.message = new WeakReference<>(message);
       this.subscription = subscription;
    }
@@ -120,7 +114,7 @@ public class PagedReferenceImpl implements PagedReference {
 
    @Override
    public int getMessageMemoryEstimate() {
-      if (messageEstimate < 0) {
+      if (messageEstimate <= 0) {
          try {
             messageEstimate = getMessage().getMemoryEstimate();
          } catch (Throwable e) {
@@ -139,7 +133,7 @@ public class PagedReferenceImpl implements PagedReference {
    public long getScheduledDeliveryTime() {
       if (deliveryTime == null) {
          try {
-            ServerMessage msg = getMessage();
+            Message msg = getMessage();
             if (msg.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) {
                deliveryTime = getMessage().getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
             } else {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
index c40d20d..ab10eb4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
@@ -50,7 +51,6 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
 import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
@@ -772,7 +772,7 @@ final class PageSubscriptionImpl implements PageSubscription {
 
    // Protected -----------------------------------------------------
 
-   private boolean match(final ServerMessage message) {
+   private boolean match(final Message message) {
       if (filter == null) {
          return true;
       } else {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
index 4993d0c..aabec54 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java
@@ -132,7 +132,7 @@ public final class Page implements Comparable<Page> {
                   int messageSize = fileBuffer.readInt();
                   int oldPos = fileBuffer.readerIndex();
                   if (fileBuffer.readerIndex() + messageSize < fileBuffer.capacity() && fileBuffer.getByte(oldPos + messageSize) == Page.END_BYTE) {
-                     PagedMessage msg = new PagedMessageImpl();
+                     PagedMessage msg = new PagedMessageImpl(storageManager);
                      msg.decode(fileBuffer);
                      byte b = fileBuffer.readByte();
                      if (b != Page.END_BYTE) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
index e40d107..d50dd2e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
@@ -19,12 +19,12 @@ package org.apache.activemq.artemis.core.paging.impl;
 import java.util.Arrays;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
+import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessagePersister;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.utils.DataConstants;
 
 /**
@@ -38,39 +38,37 @@ public class PagedMessageImpl implements PagedMessage {
     */
    private byte[] largeMessageLazyData;
 
-   private ServerMessage message;
+   private Message message;
 
    private long[] queueIDs;
 
    private long transactionID = 0;
 
-   public PagedMessageImpl(final ServerMessage message, final long[] queueIDs, final long transactionID) {
+   private volatile StorageManager storageManager;
+
+   public PagedMessageImpl(final Message message, final long[] queueIDs, final long transactionID) {
       this(message, queueIDs);
       this.transactionID = transactionID;
    }
 
-   public PagedMessageImpl(final ServerMessage message, final long[] queueIDs) {
+   public PagedMessageImpl(final Message message, final long[] queueIDs) {
       this.queueIDs = queueIDs;
       this.message = message;
    }
 
-   public PagedMessageImpl() {
+   public PagedMessageImpl(StorageManager storageManager) {
+      this.storageManager = storageManager;
    }
 
    @Override
-   public ServerMessage getMessage() {
+   public Message getMessage() {
       return message;
    }
 
    @Override
    public void initMessage(StorageManager storage) {
       if (largeMessageLazyData != null) {
-         LargeServerMessage lgMessage = storage.createLargeMessage();
-         ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(largeMessageLazyData);
-         lgMessage.decodeHeadersAndProperties(buffer);
-         lgMessage.incrementDelayDeletionCount();
-         lgMessage.setPaged();
-         message = lgMessage;
+         // TODO-now: use the largeMessagePersister
          largeMessageLazyData = null;
       }
    }
@@ -96,15 +94,15 @@ public class PagedMessageImpl implements PagedMessage {
       if (isLargeMessage) {
          int largeMessageHeaderSize = buffer.readInt();
 
-         largeMessageLazyData = new byte[largeMessageHeaderSize];
-
-         buffer.readBytes(largeMessageLazyData);
+         if (storageManager == null) {
+            largeMessageLazyData = new byte[largeMessageHeaderSize];
+            buffer.readBytes(largeMessageLazyData);
+         } else {
+            this.message = storageManager.createLargeMessage();
+            LargeMessagePersister.getInstance().decode(buffer, (LargeServerMessage) message);
+         }
       } else {
-         buffer.readInt(); // This value is only used on LargeMessages for now
-
-         message = new ServerMessageImpl(-1, 50);
-
-         message.decode(buffer);
+         this.message = MessagePersister.getInstance().decode(buffer, null);
       }
 
       int queueIDsSize = buffer.readInt();
@@ -120,11 +118,16 @@ public class PagedMessageImpl implements PagedMessage {
    public void encode(final ActiveMQBuffer buffer) {
       buffer.writeLong(transactionID);
 
-      buffer.writeBoolean(message instanceof LargeServerMessage);
+      boolean isLargeMessage = isLargeMessage();
 
-      buffer.writeInt(message.getEncodeSize());
+      buffer.writeBoolean(isLargeMessage);
 
-      message.encode(buffer);
+      if (isLargeMessage) {
+         buffer.writeInt(LargeMessagePersister.getInstance().getEncodeSize((LargeServerMessage)message));
+         LargeMessagePersister.getInstance().encode(buffer, (LargeServerMessage) message);
+      } else {
+         message.getPersister().encode(buffer, message);
+      }
 
       buffer.writeInt(queueIDs.length);
 
@@ -133,10 +136,19 @@ public class PagedMessageImpl implements PagedMessage {
       }
    }
 
+   private boolean isLargeMessage() {
+      return message.isLargeMessage();
+   }
+
    @Override
    public int getEncodeSize() {
-      return DataConstants.SIZE_LONG + DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + message.getEncodeSize() +
-         DataConstants.SIZE_INT + queueIDs.length * DataConstants.SIZE_LONG;
+      if (isLargeMessage()) {
+         return DataConstants.SIZE_LONG + DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + LargeMessagePersister.getInstance().getEncodeSize((LargeServerMessage)message) +
+            DataConstants.SIZE_INT + queueIDs.length * DataConstants.SIZE_LONG;
+      } else {
+         return DataConstants.SIZE_LONG + DataConstants.SIZE_BYTE + message.getPersister().getEncodeSize(message) +
+            DataConstants.SIZE_INT + queueIDs.length * DataConstants.SIZE_LONG;
+      }
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
index 4e57c85..e39fe40 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java
@@ -36,6 +36,7 @@ import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
@@ -54,7 +55,8 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
+import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -699,7 +701,6 @@ public class PagingStoreImpl implements PagingStore {
 
    @Override
    public void addSize(final int size) {
-
       boolean globalFull = pagingManager.addSize(size).isGlobalFull();
       long newSize = sizeInBytes.addAndGet(size);
 
@@ -747,7 +748,7 @@ public class PagingStoreImpl implements PagingStore {
    }
 
    @Override
-   public boolean page(ServerMessage message,
+   public boolean page(Message message,
                        final Transaction tx,
                        RouteContextList listCtx,
                        final ReadLock managerLock) throws Exception {
@@ -806,11 +807,12 @@ public class PagingStoreImpl implements PagingStore {
                return false;
             }
 
-            if (!message.isDurable()) {
-               // The address should never be transient when paging (even for non-persistent messages when paging)
-               // This will force everything to be persisted
-               message.forceAddress(address);
-            }
+            message.setAddress(address);
+//            if (!message.isDurable()) {
+//               // The address should never be transient when paging (even for non-persistent messages when paging)
+//               // This will force everything to be persisted
+//               message.forceAddress(address);
+//            }
 
             final long transactionID = tx == null ? -1 : tx.getID();
             PagedMessage pagedMessage = new PagedMessageImpl(message, routeQueues(tx, listCtx), transactionID);
@@ -920,6 +922,40 @@ public class PagingStoreImpl implements PagingStore {
 
    }
 
+   @Override
+   public void durableDown(Message message, int durableCount) {
+   }
+
+   @Override
+   public void durableUp(Message message, int durableCount) {
+   }
+
+   @Override
+   public void nonDurableUp(Message message, int count) {
+      if (count == 1) {
+         this.addSize(message.getMemoryEstimate() + MessageReferenceImpl.getMemoryEstimate());
+      } else {
+         this.addSize(MessageReferenceImpl.getMemoryEstimate());
+      }
+   }
+
+   @Override
+   public void nonDurableDown(Message message, int count) {
+      if (count < 0) {
+         // this could happen on paged messages since they are not routed and incrementRefCount is never called
+         return;
+      }
+
+      if (count == 0) {
+         this.addSize(-message.getMemoryEstimate() - MessageReferenceImpl.getMemoryEstimate());
+
+      } else {
+         this.addSize(-MessageReferenceImpl.getMemoryEstimate());
+      }
+
+
+   }
+
    private void installPageTransaction(final Transaction tx, final RouteContextList listCtx) throws Exception {
       FinishPageMessageOperation pgOper = (FinishPageMessageOperation) tx.getProperty(TransactionPropertyIndexes.PAGE_TRANSACTION);
       if (pgOper == null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java
index b45775c..e27ed30 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java
@@ -23,13 +23,13 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Executor;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
@@ -45,7 +45,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 import org.apache.activemq.artemis.core.server.group.impl.GroupBinding;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
@@ -172,7 +171,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
     */
    void confirmPendingLargeMessage(long recordID) throws Exception;
 
-   void storeMessage(ServerMessage message) throws Exception;
+   void storeMessage(Message message) throws Exception;
 
    void storeReference(long queueID, long messageID, boolean last) throws Exception;
 
@@ -190,7 +189,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
 
    void deleteDuplicateID(long recordID) throws Exception;
 
-   void storeMessageTransactional(long txID, ServerMessage message) throws Exception;
+   void storeMessageTransactional(long txID, Message message) throws Exception;
 
    void storeReferenceTransactional(long txID, long queueID, long messageID) throws Exception;
 
@@ -225,7 +224,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
     * @return a large message object
     * @throws Exception
     */
-   LargeServerMessage createLargeMessage(long id, MessageInternal message) throws Exception;
+   LargeServerMessage createLargeMessage(long id, Message message) throws Exception;
 
    enum LargeMessageExtension {
       DURABLE(".msg"), TEMPORARY(".tmp"), SYNC(".sync");
@@ -265,11 +264,6 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
 
    void updatePageTransaction(long txID, PageTransactionInfo pageTransaction, int depage) throws Exception;
 
-   /**
-    * FIXME Unused
-    */
-   void updatePageTransaction(PageTransactionInfo pageTransaction, int depage) throws Exception;
-
    void deletePageTransactional(long recordID) throws Exception;
 
    JournalLoadInformation loadMessageJournal(final PostOffice postOffice,
@@ -383,7 +377,7 @@ public interface StorageManager extends IDGenerator, ActiveMQComponent {
     * needs to be sent to the journal
     * @throws Exception
     */
-   boolean addToPage(PagingStore store, ServerMessage msg, Transaction tx, RouteContextList listCtx) throws Exception;
+   boolean addToPage(PagingStore store, Message msg, Transaction tx, RouteContextList listCtx) throws Exception;
 
    /**
     * Stops the replication of data from the live to the backup.


[15/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java
index 2708c72..8311057 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java
@@ -39,6 +39,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.config.Configuration;
@@ -72,7 +73,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.codec.Duplicate
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.FinishPageMessageOperation;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.GroupingEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.HeuristicCompletionEncoding;
-import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessageEncoding;
+import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessagePersister;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountPendingImpl;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecord;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecordInc;
@@ -93,15 +94,14 @@ import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.group.impl.GroupBinding;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.server.impl.JournalLoader;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.transaction.ResourceManager;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
 import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.utils.Base64;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 import org.apache.activemq.artemis.utils.IDGenerator;
@@ -174,8 +174,6 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
 
    private final boolean syncNonTransactional;
 
-   protected int perfBlastPages = -1;
-
    protected boolean journalLoaded = false;
 
    private final IOCriticalErrorListener ioCriticalErrorListener;
@@ -347,7 +345,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
    }
 
    @Override
-   public void storeMessage(final ServerMessage message) throws Exception {
+   public void storeMessage(final Message message) throws Exception {
       if (message.getMessageID() <= 0) {
          // Sanity check only... this shouldn't happen unless there is a bug
          throw ActiveMQMessageBundle.BUNDLE.messageIdNotAssigned();
@@ -359,9 +357,9 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
          // appropriate
 
          if (message.isLargeMessage()) {
-            messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, new LargeMessageEncoding((LargeServerMessage) message), false, getContext(false));
+            messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, LargeMessagePersister.getInstance(), message, false, getContext(false));
          } else {
-            messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_MESSAGE, message, false, getContext(false));
+            messageJournal.appendAddRecord(message.getMessageID(), JournalRecordIds.ADD_MESSAGE_PROTOCOL, message.getPersister(), message, false, getContext(false));
          }
       } finally {
          readUnLock();
@@ -460,7 +458,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
    // Transactional operations
 
    @Override
-   public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception {
+   public void storeMessageTransactional(final long txID, final Message message) throws Exception {
       if (message.getMessageID() <= 0) {
          throw ActiveMQMessageBundle.BUNDLE.messageIdNotAssigned();
       }
@@ -468,9 +466,9 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
       readLock();
       try {
          if (message.isLargeMessage()) {
-            messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, new LargeMessageEncoding(((LargeServerMessage) message)));
+            messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_LARGE_MESSAGE, LargeMessagePersister.getInstance(), message);
          } else {
-            messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_MESSAGE, message);
+            messageJournal.appendAddRecordTransactional(txID, message.getMessageID(), JournalRecordIds.ADD_MESSAGE_PROTOCOL, message.getPersister(), message);
          }
 
       } finally {
@@ -502,16 +500,6 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
    }
 
    @Override
-   public void updatePageTransaction(final PageTransactionInfo pageTransaction, final int depages) throws Exception {
-      readLock();
-      try {
-         messageJournal.appendUpdateRecord(pageTransaction.getRecordID(), JournalRecordIds.PAGE_TRANSACTION, new PageUpdateTXEncoding(pageTransaction.getTransactionID(), depages), syncNonTransactional, getContext(syncNonTransactional));
-      } finally {
-         readUnLock();
-      }
-   }
-
-   @Override
    public void storeReferenceTransactional(final long txID, final long queueID, final long messageID) throws Exception {
       readLock();
       try {
@@ -833,7 +821,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
 
       List<PreparedTransactionInfo> preparedTransactions = new ArrayList<>();
 
-      Map<Long, ServerMessage> messages = new HashMap<>();
+      Map<Long, Message> messages = new HashMap<>();
       readLock();
       try {
 
@@ -884,9 +872,12 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
                   break;
                }
                case JournalRecordIds.ADD_MESSAGE: {
-                  ServerMessage message = new ServerMessageImpl(record.id, 50);
+                  throw new IllegalStateException("This is using old journal data, export your data and import at the correct version");
+               }
 
-                  message.decode(buff);
+               case JournalRecordIds.ADD_MESSAGE_PROTOCOL: {
+
+                  Message message = MessagePersister.getInstance().decode(buff, null);
 
                   messages.put(record.id, message);
 
@@ -907,7 +898,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
                      queueMap.put(encoding.queueID, queueMessages);
                   }
 
-                  ServerMessage message = messages.get(messageID);
+                  Message message = messages.get(messageID);
 
                   if (message == null) {
                      ActiveMQServerLogger.LOGGER.cannotFindMessage(record.id);
@@ -1151,10 +1142,6 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
             pagingManager.processReload();
          }
 
-         if (perfBlastPages != -1) {
-            messageJournal.perfBlast(perfBlastPages);
-         }
-
          journalLoader.postLoad(messageJournal, resourceManager, duplicateIDMap);
          journalLoaded = true;
          return info;
@@ -1581,7 +1568,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
       }
    }
 
-   protected abstract LargeServerMessage parseLargeMessage(Map<Long, ServerMessage> messages,
+   protected abstract LargeServerMessage parseLargeMessage(Map<Long, Message> messages,
                                                            ActiveMQBuffer buff) throws Exception;
 
    private void loadPreparedTransactions(final PostOffice postOffice,
@@ -1603,7 +1590,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
 
          List<MessageReference> referencesToAck = new ArrayList<>();
 
-         Map<Long, ServerMessage> messages = new HashMap<>();
+         Map<Long, Message> messages = new HashMap<>();
 
          // Use same method as load message journal to prune out acks, so they don't get added.
          // Then have reacknowledge(tx) methods on queue, which needs to add the page size
@@ -1623,9 +1610,11 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
                   break;
                }
                case JournalRecordIds.ADD_MESSAGE: {
-                  ServerMessage message = new ServerMessageImpl(record.id, 50);
 
-                  message.decode(buff);
+                  break;
+               }
+               case JournalRecordIds.ADD_MESSAGE_PROTOCOL: {
+                  Message message = MessagePersister.getInstance().decode(buff, null);
 
                   messages.put(record.id, message);
 
@@ -1638,7 +1627,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
 
                   encoding.decode(buff);
 
-                  ServerMessage message = messages.get(messageID);
+                  Message message = messages.get(messageID);
 
                   if (message == null) {
                      throw new IllegalStateException("Cannot find message with id " + messageID);
@@ -1915,7 +1904,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
 
    @Override
    public boolean addToPage(PagingStore store,
-                            ServerMessage msg,
+                            Message msg,
                             Transaction tx,
                             RouteContextList listCtx) throws Exception {
       /**
@@ -1939,4 +1928,5 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
       }
       txoper.confirmedMessages.add(recordID);
    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AddMessageRecord.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AddMessageRecord.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AddMessageRecord.java
index 3ca38e3..acf9c8e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AddMessageRecord.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AddMessageRecord.java
@@ -16,21 +16,21 @@
  */
 package org.apache.activemq.artemis.core.persistence.impl.journal;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.api.core.Message;
 
 public final class AddMessageRecord {
 
-   public AddMessageRecord(final ServerMessage message) {
+   public AddMessageRecord(final Message message) {
       this.message = message;
    }
 
-   final ServerMessage message;
+   final Message message;
 
    private long scheduledDeliveryTime;
 
    private int deliveryCount;
 
-   public ServerMessage getMessage() {
+   public Message getMessage() {
       return message;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
index b9449bc..698978b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
@@ -44,7 +44,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.codec.CursorAck
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.DeliveryCountUpdateEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.DuplicateIDEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.HeuristicCompletionEncoding;
-import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessageEncoding;
+import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessagePersister;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountPendingImpl;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecord;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageCountRecordInc;
@@ -53,8 +53,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PendingLa
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.RefEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.ScheduledDeliveryEncoding;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.utils.Base64;
 import org.apache.activemq.artemis.utils.XidCodecSupport;
 
@@ -64,6 +63,7 @@ import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalR
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE;
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE_PENDING;
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE;
+import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_MESSAGE_PROTOCOL;
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_REF;
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.DUPLICATE_ID;
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.HEURISTIC_COMPLETION;
@@ -445,16 +445,15 @@ public final class DescribeJournal {
 
             LargeServerMessage largeMessage = new LargeServerMessageImpl(storageManager);
 
-            LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage);
-
-            messageEncoding.decode(buffer);
+            LargeMessagePersister.getInstance().decode(buffer, largeMessage);
 
             return new MessageDescribe(largeMessage);
          }
          case ADD_MESSAGE: {
-            ServerMessage message = new ServerMessageImpl(rec, 50);
-
-            message.decode(buffer);
+            return "ADD-MESSAGE is not supported any longer, use export/import";
+         }
+         case ADD_MESSAGE_PROTOCOL: {
+            Message message = MessagePersister.getInstance().decode(buffer, null);
 
             return new MessageDescribe(message);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java
index cd1d526..348ac9b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalRecordIds.java
@@ -85,4 +85,7 @@ public final class JournalRecordIds {
    public static final byte PAGE_CURSOR_PENDING_COUNTER = 43;
 
    public static final byte ADDRESS_BINDING_RECORD = 44;
+
+   public static final byte ADD_MESSAGE_PROTOCOL = 45;
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
index 51fd6cc..c31de52 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
@@ -49,12 +49,11 @@ import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
-import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessageEncoding;
+import org.apache.activemq.artemis.core.persistence.impl.journal.codec.LargeMessagePersister;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PendingLargeMessageEncoding;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage;
 import org.apache.activemq.artemis.core.replication.ReplicatedJournal;
@@ -63,7 +62,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 import org.jboss.logging.Logger;
@@ -157,8 +155,6 @@ public class JournalStorageManager extends AbstractJournalStorageManager {
 
       largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesLocation(), false, criticalErrorListener, 1);
 
-      perfBlastPages = config.getJournalPerfBlastPages();
-
       if (config.getPageMaxConcurrentIO() != 1) {
          pageMaxConcurrentIO = new Semaphore(config.getPageMaxConcurrentIO());
       } else {
@@ -287,13 +283,11 @@ public class JournalStorageManager extends AbstractJournalStorageManager {
     * @param buff
     * @return
     * @throws Exception
-    */ protected LargeServerMessage parseLargeMessage(final Map<Long, ServerMessage> messages,
+    */ protected LargeServerMessage parseLargeMessage(final Map<Long, Message> messages,
                                                       final ActiveMQBuffer buff) throws Exception {
       LargeServerMessage largeMessage = createLargeMessage();
 
-      LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage);
-
-      messageEncoding.decode(buff);
+      LargeMessagePersister.getInstance().decode(buff, largeMessage);
 
       if (largeMessage.containsProperty(Message.HDR_ORIG_MESSAGE_ID)) {
          // for compatibility: couple with old behaviour, copying the old file to avoid message loss
@@ -451,7 +445,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager {
    }
 
    @Override
-   public LargeServerMessage createLargeMessage(final long id, final MessageInternal message) throws Exception {
+   public LargeServerMessage createLargeMessage(final long id, final Message message) throws Exception {
       readLock();
       try {
          if (isReplicated()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java
index 8953291..33be342 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeMessageTXFailureCallback.java
@@ -21,21 +21,21 @@ import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds.ADD_LARGE_MESSAGE;
 
 public class LargeMessageTXFailureCallback implements TransactionFailureCallback {
 
    private AbstractJournalStorageManager journalStorageManager;
-   private final Map<Long, ServerMessage> messages;
+   private final Map<Long, Message> messages;
 
    public LargeMessageTXFailureCallback(AbstractJournalStorageManager journalStorageManager,
-                                        final Map<Long, ServerMessage> messages) {
+                                        final Map<Long, Message> messages) {
       super();
       this.journalStorageManager = journalStorageManager;
       this.messages = messages;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index 90b1fdd..817a56a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -25,17 +25,15 @@ import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
 import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.io.SequentialFile;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.utils.DataConstants;
 import org.apache.activemq.artemis.utils.TypedProperties;
 import org.jboss.logging.Logger;
 
-public final class LargeServerMessageImpl extends ServerMessageImpl implements LargeServerMessage {
+public final class LargeServerMessageImpl extends CoreMessage implements LargeServerMessage {
 
    // Constants -----------------------------------------------------
    private static final Logger logger = Logger.getLogger(LargeServerMessageImpl.class);
@@ -43,30 +41,28 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
    // Attributes ----------------------------------------------------
 
    private final JournalStorageManager storageManager;
-
+   private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
    private long pendingRecordID = -1;
-
    private boolean paged;
-
    // We should only use the NIO implementation on the Journal
    private SequentialFile file;
-
    // set when a copyFrom is called
    // The actual copy is done when finishCopy is called
    private SequentialFile pendingCopy;
-
    private long bodySize = -1;
 
-   private final AtomicInteger delayDeletionCount = new AtomicInteger(0);
-
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
+   // We cache this
+   private volatile int memoryEstimate = -1;
 
    public LargeServerMessageImpl(final JournalStorageManager storageManager) {
       this.storageManager = storageManager;
    }
 
+   // Public --------------------------------------------------------
+
    /**
     * Copy constructor
     *
@@ -85,14 +81,18 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
       setMessageID(newID);
    }
 
-   // Public --------------------------------------------------------
+   private static String toDate(long timestamp) {
+      if (timestamp == 0) {
+         return "0";
+      } else {
+         return new java.util.Date(timestamp).toString();
+      }
+
+   }
 
-   /**
-    * @param pendingRecordID
-    */
    @Override
-   public void setPendingRecordID(long pendingRecordID) {
-      this.pendingRecordID = pendingRecordID;
+   public boolean isServerMessage() {
+      return true;
    }
 
    @Override
@@ -100,6 +100,14 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
       return this.pendingRecordID;
    }
 
+   /**
+    * @param pendingRecordID
+    */
+   @Override
+   public void setPendingRecordID(long pendingRecordID) {
+      this.pendingRecordID = pendingRecordID;
+   }
+
    @Override
    public void setPaged() {
       paged = true;
@@ -118,39 +126,19 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
       bodySize += bytes.length;
    }
 
-   public void encodeBody(final ActiveMQBuffer bufferOut, final BodyEncoder context, final int size) {
-      try {
-         // This could maybe be optimized (maybe reading directly into bufferOut)
-         ByteBuffer bufferRead = ByteBuffer.allocate(size);
-
-         int bytesRead = context.encode(bufferRead);
-
-         bufferRead.flip();
-
-         if (bytesRead > 0) {
-            bufferOut.writeBytes(bufferRead.array(), 0, bytesRead);
-         }
-
-      } catch (Exception e) {
-         throw new RuntimeException(e.getMessage(), e);
-      }
-   }
-
    @Override
    public synchronized int getEncodeSize() {
       return getHeadersAndPropertiesEncodeSize();
    }
 
-   @Override
    public void encode(final ActiveMQBuffer buffer1) {
-      super.encodeHeadersAndProperties(buffer1);
+      super.encodeHeadersAndProperties(buffer1.byteBuf());
    }
 
-   @Override
    public void decode(final ActiveMQBuffer buffer1) {
       file = null;
 
-      super.decodeHeadersAndProperties(buffer1);
+      super.decodeHeadersAndProperties(buffer1.byteBuf());
    }
 
    @Override
@@ -175,7 +163,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
    }
 
    @Override
-   public BodyEncoder getBodyEncoder() throws ActiveMQException {
+   public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
       validateFile();
       return new DecodingContext();
    }
@@ -220,9 +208,6 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
       storageManager.deleteLargeMessageFile(this);
    }
 
-   // We cache this
-   private volatile int memoryEstimate = -1;
-
    @Override
    public synchronized int getMemoryEstimate() {
       if (memoryEstimate == -1) {
@@ -248,28 +233,29 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
    }
 
    @Override
-   public void setOriginalHeaders(final ServerMessage other,
-                                  final MessageReference originalReference,
-                                  final boolean expiry) {
-      super.setOriginalHeaders(other, originalReference, expiry);
-
-      LargeServerMessageImpl otherLM = (LargeServerMessageImpl) other;
-      this.paged = otherLM.paged;
-      if (this.paged) {
-         this.removeProperty(Message.HDR_ORIG_MESSAGE_ID);
+   public void referenceOriginalMessage(final Message original, String originalQueue) {
+
+      super.referenceOriginalMessage(original, originalQueue);
+
+      if (original instanceof LargeServerMessageImpl) {
+         LargeServerMessageImpl otherLM = (LargeServerMessageImpl) original;
+         this.paged = otherLM.paged;
+         if (this.paged) {
+            this.removeProperty(Message.HDR_ORIG_MESSAGE_ID);
+         }
       }
    }
 
    @Override
-   public ServerMessage copy() {
+   public Message copy() {
       SequentialFile newfile = storageManager.createFileForLargeMessage(messageID, durable);
 
-      ServerMessage newMessage = new LargeServerMessageImpl(this, properties, newfile, messageID);
+      Message newMessage = new LargeServerMessageImpl(this, properties, newfile, messageID);
       return newMessage;
    }
 
    @Override
-   public ServerMessage copy(final long newID) {
+   public Message copy(final long newID) {
       try {
          LargeServerMessage newMessage = storageManager.createLargeMessage(newID, this);
 
@@ -286,7 +272,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
          file.open();
          file.position(0);
 
-         for (;;) {
+         for (; ; ) {
             // The buffer is reused...
             // We need to make sure we clear the limits and the buffer before reusing it
             buffer.clear();
@@ -337,19 +323,6 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
          ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this);
    }
 
-   private static String toDate(long timestamp) {
-      if (timestamp == 0) {
-         return "0";
-      } else {
-         return new java.util.Date(timestamp).toString();
-      }
-
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
    @Override
    protected void finalize() throws Throwable {
       releaseResources();
@@ -400,7 +373,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
 
    // Inner classes -------------------------------------------------
 
-   class DecodingContext implements BodyEncoder {
+   class DecodingContext implements LargeBodyEncoder {
 
       private SequentialFile cFile;
 
@@ -454,7 +427,7 @@ public final class LargeServerMessageImpl extends ServerMessageImpl implements L
       }
 
       /* (non-Javadoc)
-       * @see org.apache.activemq.artemis.core.message.BodyEncoder#getLargeBodySize()
+       * @see org.apache.activemq.artemis.core.message.LargeBodyEncoder#getLargeBodySize()
        */
       @Override
       public long getLargeBodySize() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessagePersister.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessagePersister.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessagePersister.java
new file mode 100644
index 0000000..cb578e1
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessagePersister.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.persistence.impl.journal;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.apache.activemq.artemis.core.server.LargeServerMessage;
+import org.apache.activemq.artemis.utils.DataConstants;
+
+public class LargeServerMessagePersister implements Persister<LargeServerMessage> {
+
+   /**
+    *  for future usage...
+    *  when we have refactored large message properly
+    *  this could be used to differentiate other protocols large message persisters
+    */
+   byte PERSISTER_ID = 11;
+
+   public static LargeServerMessagePersister theInstance = new LargeServerMessagePersister();
+
+   public static LargeServerMessagePersister getInstance() {
+      return theInstance;
+   }
+
+   protected LargeServerMessagePersister() {
+   }
+
+   @Override
+   public int getEncodeSize(LargeServerMessage record) {
+      return DataConstants.SIZE_BYTE + DataConstants.SIZE_LONG + SimpleString.sizeofNullableString(record.getAddressSimpleString())
+             + record.getPersistSize();
+   }
+
+   /** Sub classes must add the first short as the protocol-id */
+   @Override
+   public void encode(ActiveMQBuffer buffer, LargeServerMessage record) {
+      buffer.writeByte(PERSISTER_ID);
+      buffer.writeLong(record.getMessageID());
+      buffer.writeNullableSimpleString(record.getAddressSimpleString());
+      record.persist(buffer);
+   }
+
+
+   @Override
+   public LargeServerMessage decode(ActiveMQBuffer buffer, LargeServerMessage record) {
+      // the caller must consume the first byte already, as that will be used to decide what persister (protocol) to use
+      buffer.readByte(); // for future usage, not used now
+      long id = buffer.readLong();
+      SimpleString address = buffer.readNullableSimpleString();
+      record.reloadPersistence(buffer);
+      record.setMessageID(id);
+      record.setAddress(address);
+      return record;
+   }
+
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessageEncoding.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessageEncoding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessageEncoding.java
deleted file mode 100644
index cdb5702..0000000
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessageEncoding.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.persistence.impl.journal.codec;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
-import org.apache.activemq.artemis.core.server.LargeServerMessage;
-
-public class LargeMessageEncoding implements EncodingSupport {
-
-   public final LargeServerMessage message;
-
-   public LargeMessageEncoding(final LargeServerMessage message) {
-      this.message = message;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#decode(org.apache.activemq.artemis.spi.core.remoting.ActiveMQBuffer)
-    */
-   @Override
-   public void decode(final ActiveMQBuffer buffer) {
-      message.decodeHeadersAndProperties(buffer);
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#encode(org.apache.activemq.artemis.spi.core.remoting.ActiveMQBuffer)
-    */
-   @Override
-   public void encode(final ActiveMQBuffer buffer) {
-      message.encode(buffer);
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#getEncodeSize()
-    */
-   @Override
-   public int getEncodeSize() {
-      return message.getEncodeSize();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessagePersister.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessagePersister.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessagePersister.java
new file mode 100644
index 0000000..cb3129b
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/codec/LargeMessagePersister.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.persistence.impl.journal.codec;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.apache.activemq.artemis.core.server.LargeServerMessage;
+
+public class LargeMessagePersister implements Persister<LargeServerMessage> {
+
+   private static final LargeMessagePersister theInstance = new LargeMessagePersister();
+
+
+   public static LargeMessagePersister getInstance() {
+      return theInstance;
+   }
+
+
+   protected LargeMessagePersister() {
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#decode(org.apache.activemq.artemis.spi.core.remoting.ActiveMQBuffer)
+    */
+   @Override
+   public LargeServerMessage decode(final ActiveMQBuffer buffer, LargeServerMessage message) {
+      ((CoreMessage)message).decodeHeadersAndProperties(buffer.byteBuf());
+      return message;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#encode(org.apache.activemq.artemis.spi.core.remoting.ActiveMQBuffer)
+    */
+   @Override
+   public void encode(final ActiveMQBuffer buffer, LargeServerMessage message) {
+      ((CoreMessage)message).encodeHeadersAndProperties(buffer.byteBuf());
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.activemq.artemis.core.journal.EncodingSupport#getEncodeSize()
+    */
+   @Override
+   public int getEncodeSize(LargeServerMessage message) {
+      return message.getEncodeSize();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
index 5b325b6..28ccc09 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
@@ -17,12 +17,14 @@
 package org.apache.activemq.artemis.core.persistence.impl.nullpm;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.io.SequentialFile;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 
-class NullStorageLargeServerMessage extends ServerMessageImpl implements LargeServerMessage {
+
+
+class NullStorageLargeServerMessage extends CoreMessage implements LargeServerMessage {
 
    NullStorageLargeServerMessage() {
       super();
@@ -39,7 +41,7 @@ class NullStorageLargeServerMessage extends ServerMessageImpl implements LargeSe
    @Override
    public synchronized void addBytes(final byte[] bytes) {
       if (buffer == null) {
-         buffer = ActiveMQBuffers.dynamicBuffer(bytes.length);
+         buffer = ActiveMQBuffers.dynamicBuffer(bytes.length).byteBuf();
       }
 
       // expand the buffer
@@ -67,6 +69,12 @@ class NullStorageLargeServerMessage extends ServerMessageImpl implements LargeSe
    }
 
    @Override
+   public boolean isServerMessage() {
+      return true;
+   }
+
+
+   @Override
    public synchronized int getEncodeSize() {
       return getHeadersAndPropertiesEncodeSize();
    }
@@ -77,7 +85,7 @@ class NullStorageLargeServerMessage extends ServerMessageImpl implements LargeSe
    }
 
    @Override
-   public ServerMessage copy() {
+   public Message copy() {
       // This is a simple copy, used only to avoid changing original properties
       return new NullStorageLargeServerMessage(this);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java
index 2154879..cb035ec 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/nullpm/NullStorageManager.java
@@ -25,6 +25,7 @@ import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.IOCallback;
@@ -32,7 +33,6 @@ import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
@@ -53,7 +53,7 @@ import org.apache.activemq.artemis.core.replication.ReplicationManager;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 import org.apache.activemq.artemis.core.server.group.impl.GroupBinding;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
@@ -214,11 +214,11 @@ public class NullStorageManager implements StorageManager {
    }
 
    @Override
-   public void storeMessage(final ServerMessage message) throws Exception {
+   public void storeMessage(final Message message) throws Exception {
    }
 
    @Override
-   public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception {
+   public void storeMessageTransactional(final long txID, final Message message) throws Exception {
    }
 
    @Override
@@ -274,7 +274,7 @@ public class NullStorageManager implements StorageManager {
    }
 
    @Override
-   public LargeServerMessage createLargeMessage(final long id, final MessageInternal message) {
+   public LargeServerMessage createLargeMessage(final long id, final Message message) {
       NullStorageLargeServerMessage largeMessage = new NullStorageLargeServerMessage();
 
       largeMessage.copyHeadersAndProperties(message);
@@ -464,10 +464,6 @@ public class NullStorageManager implements StorageManager {
    }
 
    @Override
-   public void updatePageTransaction(final PageTransactionInfo pageTransaction, final int depage) throws Exception {
-   }
-
-   @Override
    public long storePageCounter(final long txID, final long queueID, final long value) throws Exception {
       return 0;
    }
@@ -543,7 +539,7 @@ public class NullStorageManager implements StorageManager {
 
    @Override
    public boolean addToPage(PagingStore store,
-                            ServerMessage msg,
+                            Message msg,
                             Transaction tx,
                             RouteContextList listCtx) throws Exception {
       /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Binding.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Binding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Binding.java
index 4c6763d..f1e83d2 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Binding.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Binding.java
@@ -16,11 +16,12 @@
  */
 package org.apache.activemq.artemis.core.postoffice;
 
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.group.UnproposalListener;
 
 public interface Binding extends UnproposalListener {
@@ -39,7 +40,7 @@ public interface Binding extends UnproposalListener {
 
    Filter getFilter();
 
-   boolean isHighAcceptPriority(ServerMessage message);
+   boolean isHighAcceptPriority(Message message);
 
    boolean isExclusive();
 
@@ -47,9 +48,9 @@ public interface Binding extends UnproposalListener {
 
    int getDistance();
 
-   void route(ServerMessage message, RoutingContext context) throws Exception;
+   void route(Message message, RoutingContext context) throws Exception;
 
-   void routeWithAck(ServerMessage message, RoutingContext context) throws Exception;
+   void routeWithAck(Message message, RoutingContext context) throws Exception;
 
    void close() throws Exception;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Bindings.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Bindings.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Bindings.java
index b79f1da..1d335ad 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Bindings.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/Bindings.java
@@ -18,9 +18,9 @@ package org.apache.activemq.artemis.core.postoffice;
 
 import java.util.Collection;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.core.server.group.UnproposalListener;
 
@@ -34,7 +34,7 @@ public interface Bindings extends UnproposalListener {
 
    void setMessageLoadBalancingType(MessageLoadBalancingType messageLoadBalancingType);
 
-   boolean redistribute(ServerMessage message, Queue originatingQueue, RoutingContext context) throws Exception;
+   boolean redistribute(Message message, Queue originatingQueue, RoutingContext context) throws Exception;
 
-   void route(ServerMessage message, RoutingContext context) throws Exception;
+   void route(Message message, RoutingContext context) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
index 7b8ce18..f682777 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
@@ -28,7 +29,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 
@@ -96,33 +96,33 @@ public interface PostOffice extends ActiveMQComponent {
 
    SimpleString getMatchingQueue(SimpleString address, SimpleString queueName, RoutingType routingType) throws Exception;
 
-   RoutingStatus route(ServerMessage message, boolean direct) throws Exception;
+   RoutingStatus route(Message message, boolean direct) throws Exception;
 
-   RoutingStatus route(ServerMessage message,
+   RoutingStatus route(Message message,
                        Transaction tx,
                        boolean direct) throws Exception;
 
-   RoutingStatus route(ServerMessage message,
+   RoutingStatus route(Message message,
                        Transaction tx,
                        boolean direct,
                        boolean rejectDuplicates) throws Exception;
 
-   RoutingStatus route(ServerMessage message,
+   RoutingStatus route(Message message,
                        RoutingContext context,
                        boolean direct) throws Exception;
 
-   RoutingStatus route(ServerMessage message,
+   RoutingStatus route(Message message,
                        RoutingContext context,
                        boolean direct,
                        boolean rejectDuplicates) throws Exception;
 
-   MessageReference reroute(ServerMessage message, Queue queue, Transaction tx) throws Exception;
+   MessageReference reroute(Message message, Queue queue, Transaction tx) throws Exception;
 
-   Pair<RoutingContext, ServerMessage> redistribute(ServerMessage message,
+   Pair<RoutingContext, Message> redistribute(Message message,
                                                     final Queue originatingQueue,
                                                     Transaction tx) throws Exception;
 
-   void processRoute(final ServerMessage message, final RoutingContext context, final boolean direct) throws Exception;
+   void processRoute(final Message message, final RoutingContext context, final boolean direct) throws Exception;
 
    DuplicateIDCache getDuplicateIDCache(SimpleString address);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
index 6be0311..c1f0dba 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
@@ -30,14 +30,13 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.core.server.group.GroupingHandler;
@@ -152,7 +151,7 @@ public final class BindingsImpl implements Bindings {
    }
 
    @Override
-   public boolean redistribute(final ServerMessage message,
+   public boolean redistribute(final Message message,
                                final Queue originatingQueue,
                                final RoutingContext context) throws Exception {
       if (messageLoadBalancingType.equals(MessageLoadBalancingType.STRICT) || messageLoadBalancingType.equals(MessageLoadBalancingType.OFF)) {
@@ -230,18 +229,18 @@ public final class BindingsImpl implements Bindings {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       route(message, context, true);
    }
 
-   private void route(final ServerMessage message,
+   private void route(final Message message,
                       final RoutingContext context,
                       final boolean groupRouting) throws Exception {
       /* This is a special treatment for scaled-down messages involving SnF queues.
        * See org.apache.activemq.artemis.core.server.impl.ScaleDownHandler.scaleDownMessages() for the logic that sends messages with this property
        */
-      if (message.containsProperty(MessageImpl.HDR_SCALEDOWN_TO_IDS)) {
-         byte[] ids = (byte[]) message.removeProperty(MessageImpl.HDR_SCALEDOWN_TO_IDS);
+      if (message.containsProperty(Message.HDR_SCALEDOWN_TO_IDS)) {
+         byte[] ids = (byte[]) message.removeProperty(Message.HDR_SCALEDOWN_TO_IDS);
 
          if (ids != null) {
             ByteBuffer buffer = ByteBuffer.wrap(ids);
@@ -251,7 +250,7 @@ public final class BindingsImpl implements Bindings {
                   if (entry.getValue() instanceof RemoteQueueBinding) {
                      RemoteQueueBinding remoteQueueBinding = (RemoteQueueBinding) entry.getValue();
                      if (remoteQueueBinding.getRemoteQueueID() == id) {
-                        message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, ByteBuffer.allocate(8).putLong(remoteQueueBinding.getID()).array());
+                        message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, ByteBuffer.allocate(8).putLong(remoteQueueBinding.getID()).array());
                      }
                   }
                }
@@ -272,7 +271,7 @@ public final class BindingsImpl implements Bindings {
 
       if (!routed) {
          // Remove the ids now, in order to avoid double check
-         byte[] ids = (byte[]) message.removeProperty(MessageImpl.HDR_ROUTE_TO_IDS);
+         byte[] ids = (byte[]) message.removeProperty(Message.HDR_ROUTE_TO_IDS);
 
          // Fetch the groupId now, in order to avoid double checking
          SimpleString groupId = message.getSimpleStringProperty(Message.HDR_GROUP_ID);
@@ -319,7 +318,7 @@ public final class BindingsImpl implements Bindings {
     * these two servers. This will eventually send more messages to one server than the other
     * (depending if you are using multi-thread), and not lose messages.
     */
-   private Binding getNextBinding(final ServerMessage message,
+   private Binding getNextBinding(final Message message,
                                   final SimpleString routingName,
                                   final List<Binding> bindings) {
       Integer ipos = routingNamePositions.get(routingName);
@@ -407,7 +406,7 @@ public final class BindingsImpl implements Bindings {
       return theBinding;
    }
 
-   private void routeUsingStrictOrdering(final ServerMessage message,
+   private void routeUsingStrictOrdering(final Message message,
                                          final RoutingContext context,
                                          final GroupingHandler groupingGroupingHandler,
                                          final SimpleString groupId,
@@ -473,7 +472,7 @@ public final class BindingsImpl implements Bindings {
       return null;
    }
 
-   private void routeAndCheckNull(ServerMessage message,
+   private void routeAndCheckNull(Message message,
                                   RoutingContext context,
                                   Response resp,
                                   Binding theBinding,
@@ -552,10 +551,10 @@ public final class BindingsImpl implements Bindings {
       return writer.toString();
    }
 
-   private void routeFromCluster(final ServerMessage message,
+   private void routeFromCluster(final Message message,
                                  final RoutingContext context,
                                  final byte[] ids) throws Exception {
-      byte[] idsToAck = (byte[]) message.removeProperty(MessageImpl.HDR_ROUTE_TO_ACK_IDS);
+      byte[] idsToAck = (byte[]) message.removeProperty(Message.HDR_ROUTE_TO_ACK_IDS);
 
       List<Long> idsToAckList = new ArrayList<>();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DivertBinding.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DivertBinding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DivertBinding.java
index 04f432d..8f4ab48 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DivertBinding.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DivertBinding.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.postoffice.impl;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.postoffice.Binding;
@@ -23,7 +24,6 @@ import org.apache.activemq.artemis.core.postoffice.BindingType;
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 public class DivertBinding implements Binding {
 
@@ -98,12 +98,12 @@ public class DivertBinding implements Binding {
    }
 
    @Override
-   public boolean isHighAcceptPriority(final ServerMessage message) {
+   public boolean isHighAcceptPriority(final Message message) {
       return true;
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       divert.route(message, context);
    }
 
@@ -150,7 +150,7 @@ public class DivertBinding implements Binding {
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) {
+   public void routeWithAck(Message message, RoutingContext context) {
       //noop
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java
index af49c4d..176d614 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.postoffice.impl;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.postoffice.BindingType;
@@ -24,7 +25,6 @@ import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 public class LocalQueueBinding implements QueueBinding {
 
@@ -104,7 +104,7 @@ public class LocalQueueBinding implements QueueBinding {
    }
 
    @Override
-   public boolean isHighAcceptPriority(final ServerMessage message) {
+   public boolean isHighAcceptPriority(final Message message) {
       // It's a high accept priority if the queue has at least one matching consumer
 
       return queue.hasMatchingConsumer(message);
@@ -116,14 +116,14 @@ public class LocalQueueBinding implements QueueBinding {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       if (isMatchRoutingType(context)) {
          queue.route(message, context);
       }
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) throws Exception {
+   public void routeWithAck(Message message, RoutingContext context) throws Exception {
       if (isMatchRoutingType(context)) {
          queue.routeWithAck(message, context);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
index 2f6ae3d..81a83ac 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
@@ -38,6 +38,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQDuplicateIdException;
 import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
@@ -45,7 +46,7 @@ import org.apache.activemq.artemis.api.core.management.NotificationType;
 import org.apache.activemq.artemis.core.config.WildcardConfiguration;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.io.IOCallback;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
@@ -69,12 +70,9 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.core.server.RouteContextList;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.group.GroupingHandler;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.server.management.NotificationListener;
@@ -665,20 +663,20 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    }
 
    @Override
-   public RoutingStatus route(final ServerMessage message,
+   public RoutingStatus route(final Message message,
                               final boolean direct) throws Exception {
       return route(message, (Transaction) null, direct);
    }
 
    @Override
-   public RoutingStatus route(final ServerMessage message,
+   public RoutingStatus route(final Message message,
                               final Transaction tx,
                               final boolean direct) throws Exception {
       return route(message, new RoutingContextImpl(tx), direct);
    }
 
    @Override
-   public RoutingStatus route(final ServerMessage message,
+   public RoutingStatus route(final Message message,
                               final Transaction tx,
                               final boolean direct,
                               final boolean rejectDuplicates) throws Exception {
@@ -686,14 +684,14 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    }
 
    @Override
-   public RoutingStatus route(final ServerMessage message,
+   public RoutingStatus route(final Message message,
                               final RoutingContext context,
                               final boolean direct) throws Exception {
       return route(message, context, direct, true);
    }
 
    @Override
-   public RoutingStatus route(final ServerMessage message,
+   public RoutingStatus route(final Message message,
                               final RoutingContext context,
                               final boolean direct,
                               boolean rejectDuplicates) throws Exception {
@@ -708,7 +706,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
 
       AtomicBoolean startedTX = new AtomicBoolean(false);
 
-      final SimpleString address = message.getAddress();
+      final SimpleString address = message.getAddressSimpleString();
 
       applyExpiryDelay(message, address);
 
@@ -716,13 +714,12 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          return RoutingStatus.DUPLICATED_ID;
       }
 
-      if (message.hasInternalProperties()) {
-         // We need to perform some cleanup on internal properties,
-         // but we don't do it every time, otherwise it wouldn't be optimal
-         cleanupInternalPropertiesBeforeRouting(message);
-      }
+      // TODO-now: Internal properties shouldn't be part of the ServerMessage
+      // We need to perform some cleanup on internal properties,
+      // but we don't do it every time, otherwise it wouldn't be optimal
+      cleanupInternalPropertiesBeforeRouting(message);
 
-      Bindings bindings = addressManager.getBindingsForRoutingAddress(context.getAddress() == null ? message.getAddress() : context.getAddress());
+      Bindings bindings = addressManager.getBindingsForRoutingAddress(context.getAddress() == null ? message.getAddressSimpleString() : context.getAddress());
 
       // TODO auto-create queues here?
       // first check for the auto-queue creation thing
@@ -768,8 +765,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
                result = RoutingStatus.NO_BINDINGS;
                ActiveMQServerLogger.LOGGER.noDLA(address);
             } else {
-               message.setOriginalHeaders(message, null, false);
 
+               message.referenceOriginalMessage(message, null);
                message.setAddress(dlaAddress);
 
                route(message, context.getTransaction(), false);
@@ -806,7 +803,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    }
 
    // HORNETQ-1029
-   private void applyExpiryDelay(ServerMessage message, SimpleString address) {
+   private void applyExpiryDelay(Message message, SimpleString address) {
       long expirationOverride = addressSettingsRepository.getMatch(address.toString()).getExpiryDelay();
 
       // A -1 <expiry-delay> means don't do anything
@@ -819,12 +816,13 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    }
 
    @Override
-   public MessageReference reroute(final ServerMessage message,
+   public MessageReference reroute(final Message message,
                                    final Queue queue,
                                    final Transaction tx) throws Exception {
+
       setPagingStore(message);
 
-      MessageReference reference = message.createReference(queue);
+      MessageReference reference = MessageReference.Factory.createReference(message, queue);
 
       if (message.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) {
          Long scheduledDeliveryTime = message.getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
@@ -852,15 +850,15 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
     * The redistribution can't process the route right away as we may be dealing with a large message which will need to be processed on a different thread
     */
    @Override
-   public Pair<RoutingContext, ServerMessage> redistribute(final ServerMessage message,
+   public Pair<RoutingContext, Message> redistribute(final Message message,
                                                            final Queue originatingQueue,
                                                            final Transaction tx) throws Exception {
       // We have to copy the message and store it separately, otherwise we may lose remote bindings in case of restart before the message
       // arrived the target node
       // as described on https://issues.jboss.org/browse/JBPAPP-6130
-      ServerMessage copyRedistribute = message.copy(storageManager.generateID());
+      Message copyRedistribute = message.copy(storageManager.generateID());
 
-      Bindings bindings = addressManager.getBindingsForRoutingAddress(message.getAddress());
+      Bindings bindings = addressManager.getBindingsForRoutingAddress(message.getAddressSimpleString());
 
       if (bindings != null) {
          RoutingContext context = new RoutingContextImpl(tx);
@@ -937,7 +935,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
       synchronized (notificationLock) {
          // First send a reset message
 
-         ServerMessage message = new ServerMessageImpl(storageManager.generateID(), 50);
+         Message message = new CoreMessage(storageManager.generateID(), 50);
 
          message.setAddress(queueName);
          message.putBooleanProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA, true);
@@ -987,7 +985,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
                }
             }
          }
-         ServerMessage completeMessage = new ServerMessageImpl(storageManager.generateID(), 50);
+         Message completeMessage = new CoreMessage(storageManager.generateID(), 50);
 
          completeMessage.setAddress(queueName);
          completeMessage.putBooleanProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE, true);
@@ -1009,13 +1007,13 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    /**
     * @param message
     */
-   protected void cleanupInternalPropertiesBeforeRouting(final ServerMessage message) {
+   protected void cleanupInternalPropertiesBeforeRouting(final Message message) {
       LinkedList<SimpleString> valuesToRemove = null;
 
       for (SimpleString name : message.getPropertyNames()) {
          // We use properties to establish routing context on clustering.
          // However if the client resends the message after receiving, it needs to be removed
-         if ((name.startsWith(MessageImpl.HDR_ROUTE_TO_IDS) && !name.equals(MessageImpl.HDR_ROUTE_TO_IDS)) || (name.startsWith(MessageImpl.HDR_ROUTE_TO_ACK_IDS) && !name.equals(MessageImpl.HDR_ROUTE_TO_ACK_IDS))) {
+         if ((name.startsWith(Message.HDR_ROUTE_TO_IDS) && !name.equals(Message.HDR_ROUTE_TO_IDS)) || (name.startsWith(Message.HDR_ROUTE_TO_ACK_IDS) && !name.equals(Message.HDR_ROUTE_TO_ACK_IDS))) {
             if (valuesToRemove == null) {
                valuesToRemove = new LinkedList<>();
             }
@@ -1030,13 +1028,13 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
       }
    }
 
-   private void setPagingStore(final ServerMessage message) throws Exception {
-      PagingStore store = pagingManager.getPageStore(message.getAddress());
+   private void setPagingStore(final Message message) throws Exception {
+      PagingStore store = pagingManager.getPageStore(message.getAddressSimpleString());
 
-      message.setPagingStore(store);
+      message.setContext(store);
    }
 
-   private void routeQueueInfo(final ServerMessage message,
+   private void routeQueueInfo(final Message message,
                                final Queue queue,
                                final boolean applyFilters) throws Exception {
       if (!applyFilters || queue.getFilter() == null || queue.getFilter().match(message)) {
@@ -1074,7 +1072,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
    }
 
    @Override
-   public void processRoute(final ServerMessage message,
+   public void processRoute(final Message message,
                             final RoutingContext context,
                             final boolean direct) throws Exception {
       final List<MessageReference> refs = new ArrayList<>();
@@ -1095,7 +1093,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          }
 
          for (Queue queue : entry.getValue().getNonDurableQueues()) {
-            MessageReference reference = message.createReference(queue);
+            MessageReference reference = MessageReference.Factory.createReference(message, queue);
 
             refs.add(reference);
             if (message.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) {
@@ -1112,9 +1110,9 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          while (iter.hasNext()) {
             Queue queue = iter.next();
 
-            MessageReference reference = message.createReference(queue);
+            MessageReference reference = MessageReference.Factory.createReference(message, queue);
 
-            if (context.isAlreadyAcked(message.getAddress(), queue)) {
+            if (context.isAlreadyAcked(message.getAddressSimpleString(), queue)) {
                reference.setAlreadyAcked();
                if (tx != null) {
                   queue.acknowledge(tx, reference);
@@ -1189,7 +1187,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
     * @param message
     * @throws Exception
     */
-   private void confirmLargeMessageSend(Transaction tx, final ServerMessage message) throws Exception {
+   private void confirmLargeMessageSend(Transaction tx, final Message message) throws Exception {
       LargeServerMessage largeServerMessage = (LargeServerMessage) message;
       if (largeServerMessage.getPendingRecordID() >= 0) {
          if (tx == null) {
@@ -1245,13 +1243,13 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
       }
    }
 
-   private boolean checkDuplicateID(final ServerMessage message,
+   private boolean checkDuplicateID(final Message message,
                                     final RoutingContext context,
                                     boolean rejectDuplicates,
                                     AtomicBoolean startedTX) throws Exception {
       // Check the DuplicateCache for the Bridge first
 
-      Object bridgeDup = message.getObjectProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID);
+      Object bridgeDup = message.getObjectProperty(Message.HDR_BRIDGE_DUPLICATE_ID);
       if (bridgeDup != null) {
          // if the message is being sent from the bridge, we just ignore the duplicate id, and use the internal one
          byte[] bridgeDupBytes = (byte[]) bridgeDup;
@@ -1270,7 +1268,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
             return false;
          }
 
-         message.removeProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID);
+         message.removeProperty(Message.HDR_BRIDGE_DUPLICATE_ID);
       } else {
          // if used BridgeDuplicate, it's not going to use the regular duplicate
          // since this will would break redistribution (re-setting the duplicateId)
@@ -1281,7 +1279,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          boolean isDuplicate = false;
 
          if (duplicateIDBytes != null) {
-            cache = getDuplicateIDCache(message.getAddress());
+            cache = getDuplicateIDCache(message.getAddressSimpleString());
 
             isDuplicate = cache.contains(duplicateIDBytes);
 
@@ -1338,8 +1336,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
       }
    }
 
-   private ServerMessage createQueueInfoMessage(final NotificationType type, final SimpleString queueName) {
-      ServerMessage message = new ServerMessageImpl(storageManager.generateID(), 50);
+   private Message createQueueInfoMessage(final NotificationType type, final SimpleString queueName) {
+      Message message = new CoreMessage().initBuffer(50).setMessageID(storageManager.generateID());
 
       message.setAddress(queueName);
 
@@ -1433,7 +1431,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          // Reverse the ref counts, and paging sizes
 
          for (MessageReference ref : refs) {
-            ServerMessage message = ref.getMessage();
+            Message message = ref.getMessage();
 
             if (message.isDurable() && ref.getQueue().isDurable()) {
                message.decrementDurableRefCount();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java
index 2869e38..45082b9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/ServerPacketDecoder.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.core.protocol;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRegistrationMessage;
@@ -47,7 +48,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.Replicatio
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ScaleDownAnnounceMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendLargeMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST;
 import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.BACKUP_REQUEST_RESPONSE;
@@ -87,11 +87,11 @@ public class ServerPacketDecoder extends ClientPacketDecoder {
       switch (packetType) {
 
          case SESS_SEND: {
-            packet = new SessionSendMessage(new ServerMessageImpl());
+            packet = new SessionSendMessage(new CoreMessage());
             break;
          }
          case SESS_SEND_LARGE: {
-            packet = new SessionSendLargeMessage(new ServerMessageImpl());
+            packet = new SessionSendLargeMessage(new CoreMessage());
             break;
          }
          case REPLICATION_APPEND: {


[04/29] activemq-artemis git commit: removing vertx

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java
deleted file mode 100644
index c445a86..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.tests.integration.vertx;
-
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.client.ClientConsumer;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.core.config.Configuration;
-import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
-import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
-import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.integration.vertx.VertxConstants;
-import org.apache.activemq.artemis.integration.vertx.VertxIncomingConnectorServiceFactory;
-import org.apache.activemq.artemis.integration.vertx.VertxOutgoingConnectorServiceFactory;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.vertx.java.core.Handler;
-import org.vertx.java.core.Vertx;
-import org.vertx.java.core.buffer.Buffer;
-import org.vertx.java.core.eventbus.impl.BaseMessage;
-import org.vertx.java.core.json.JsonArray;
-import org.vertx.java.core.json.JsonObject;
-import org.vertx.java.platform.PlatformLocator;
-import org.vertx.java.platform.PlatformManager;
-import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory;
-
-/**
- * This class tests the basics of ActiveMQ
- * vertx inte
- * gration
- */
-@Ignore
-public class ActiveMQVertxUnitTest extends ActiveMQTestBase {
-
-   private PlatformManager vertxManager;
-   private ActiveMQServer server;
-
-   private String host = "localhost";
-   private String port = "0";
-
-   private String incomingQueue1 = "vertxTestIncomingQueue1";
-   private String incomingVertxAddress1 = "org.apache.activemq.test.incoming1";
-
-   //outgoing using send
-   private String inOutQueue1 = "vertxTestInOutQueue1";
-   private String incomingVertxAddress2 = "org.apache.activemq.test.incoming2";
-   private String outgoingVertxAddress1 = "org.apache.activemq.test.outgoing1";
-
-   //outgoing using publish
-   private String inOutQueue2 = "vertxTestInOutQueue2";
-   private String incomingVertxAddress3 = "org.apache.activemq.test.incoming3";
-   private String outgoingVertxAddress2 = "org.apache.activemq.test.outgoing2";
-
-   // Vertx is changing the classLoader to null.. this will preserve the original classloader
-   private ClassLoader contextClassLoader;
-
-   //subclasses may override this method
-   //in order to get a server with different connector services
-   @Before
-   @Override
-   public void setUp() throws Exception {
-      contextClassLoader = Thread.currentThread().getContextClassLoader();
-      createVertxService();
-
-      super.setUp();
-      //all queues
-      CoreQueueConfiguration qc1 = createCoreQueueConfiguration(incomingQueue1);
-      CoreQueueConfiguration qc2 = createCoreQueueConfiguration(inOutQueue1);
-      CoreQueueConfiguration qc3 = createCoreQueueConfiguration(inOutQueue2);
-
-      //incoming
-      HashMap<String, Object> config1 = createIncomingConnectionConfig(incomingVertxAddress1, incomingQueue1);
-      ConnectorServiceConfiguration inconf1 = createIncomingConnectorServiceConfiguration(config1, "test-vertx-incoming-connector1");
-
-      //outgoing send style
-      HashMap<String, Object> config2 = createOutgoingConnectionConfig(inOutQueue1, incomingVertxAddress2);
-      ConnectorServiceConfiguration inconf2 = createIncomingConnectorServiceConfiguration(config2, "test-vertx-incoming-connector2");
-
-      HashMap<String, Object> config3 = createOutgoingConnectionConfig(inOutQueue1, outgoingVertxAddress1);
-      ConnectorServiceConfiguration outconf1 = createOutgoingConnectorServiceConfiguration(config3, "test-vertx-outgoing-connector1");
-
-      //outgoing publish style
-      HashMap<String, Object> config4 = createOutgoingConnectionConfig(inOutQueue2, incomingVertxAddress3);
-      ConnectorServiceConfiguration inconf3 = createIncomingConnectorServiceConfiguration(config4, "test-vertx-incoming-connector3");
-
-      HashMap<String, Object> config5 = createOutgoingConnectionConfig(inOutQueue2, outgoingVertxAddress2);
-      config5.put(VertxConstants.VERTX_PUBLISH, "true");
-      ConnectorServiceConfiguration outconf2 = createOutgoingConnectorServiceConfiguration(config5, "test-vertx-outgoing-connector2");
-
-      Configuration configuration = createDefaultInVMConfig().addQueueConfiguration(qc1).addQueueConfiguration(qc2).addQueueConfiguration(qc3).addConnectorServiceConfiguration(inconf1).addConnectorServiceConfiguration(inconf2).addConnectorServiceConfiguration(outconf1).addConnectorServiceConfiguration(inconf3).addConnectorServiceConfiguration(outconf2);
-
-      server = createServer(false, configuration);
-      server.start();
-   }
-
-   /**
-    * (vertx events) ===> (incomingQueue1) ===> (activemq consumer)
-    */
-   @Test
-   public void testIncomingEvents() throws Exception {
-      Vertx vertx = vertxManager.vertx();
-
-      //send a string message
-      String greeting = "Hello World!";
-      vertx.eventBus().send(incomingVertxAddress1, greeting);
-
-      ClientMessage msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      System.out.println("==== received msg: " + msg);
-
-      int vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_STRING, vertxType);
-
-      String body = msg.getBodyBuffer().readString();
-      System.out.println("==== body: " + body);
-
-      assertEquals(greeting, body);
-
-      //send a Buffer message
-      final byte[] content = greeting.getBytes(StandardCharsets.UTF_8);
-      Buffer buffer = new Buffer(content);
-      vertx.eventBus().send(incomingVertxAddress1, buffer);
-
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_BUFFER, vertxType);
-
-      ActiveMQBuffer activeMQBuffer = msg.getBodyBuffer();
-      int len = activeMQBuffer.readInt();
-      System.out.println("==== len is: " + len);
-      assertEquals(content.length, len);
-      byte[] bytes = new byte[len];
-      activeMQBuffer.readBytes(bytes);
-
-      //bytes must match
-      for (int i = 0; i < len; i++) {
-         assertEquals(content[i], bytes[i]);
-      }
-
-      //send a boolean
-      vertx.eventBus().send(incomingVertxAddress1, Boolean.TRUE);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_BOOLEAN, vertxType);
-
-      Boolean booleanValue = msg.getBodyBuffer().readBoolean();
-      assertEquals(Boolean.TRUE, booleanValue);
-
-      //send a byte array
-      vertx.eventBus().send(incomingVertxAddress1, content);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_BYTEARRAY, vertxType);
-
-      len = msg.getBodyBuffer().readInt();
-      byte[] recvBytes = new byte[len];
-      msg.getBodyBuffer().readBytes(recvBytes);
-      //bytes must match
-      for (int i = 0; i < len; i++) {
-         assertEquals(content[i], recvBytes[i]);
-      }
-
-      //send a byte
-      Byte aByte = (byte) 15;
-      vertx.eventBus().send(incomingVertxAddress1, aByte);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_BYTE, vertxType);
-
-      Byte recvByte = msg.getBodyBuffer().readByte();
-      assertEquals(aByte, recvByte);
-
-      //send a Character
-      Character aChar = 'a';
-      vertx.eventBus().send(incomingVertxAddress1, aChar);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_CHARACTER, vertxType);
-      Character recvChar = msg.getBodyBuffer().readChar();
-      assertEquals(aChar, recvChar);
-
-      //send a Double
-      Double aDouble = 1234.56d;
-      vertx.eventBus().send(incomingVertxAddress1, aDouble);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_DOUBLE, vertxType);
-      Double recvDouble = msg.getBodyBuffer().readDouble();
-      assertEquals(aDouble, recvDouble);
-
-      //send a Float
-      Float aFloat = 1234.56f;
-      vertx.eventBus().send(incomingVertxAddress1, aFloat);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_FLOAT, vertxType);
-      Float recvFloat = msg.getBodyBuffer().readFloat();
-      assertEquals(aFloat, recvFloat);
-
-      //send an Integer
-      Integer aInt = 1234;
-      vertx.eventBus().send(incomingVertxAddress1, aInt);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_INT, vertxType);
-      Integer recvInt = msg.getBodyBuffer().readInt();
-      assertEquals(aInt, recvInt);
-
-      //send a Long
-      Long aLong = 12345678L;
-      vertx.eventBus().send(incomingVertxAddress1, aLong);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_LONG, vertxType);
-      Long recvLong = msg.getBodyBuffer().readLong();
-      assertEquals(aLong, recvLong);
-
-      //send a Short
-      Short aShort = (short) 321;
-      vertx.eventBus().send(incomingVertxAddress1, aShort);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_SHORT, vertxType);
-      Short recvShort = msg.getBodyBuffer().readShort();
-      assertEquals(aShort, recvShort);
-
-      //send a JsonObject
-      String jsonObjectString = "{\n" +
-         "\"Image\": {\n" +
-         "\"Width\":  800,\n" +
-         "\"Height\": 600,\n" +
-         "\"Title\":  \"View from 15th Floor\",\n" +
-         "\"Thumbnail\": {\n" +
-         "\"Url\":    \"http://www.example.com/image/481989943\",\n" +
-         "\"Height\": 125,\n" +
-         "\"Width\":  100\n" +
-         "},\n" +
-         "\"IDs\": [116, 943, 234, 38793]\n" +
-         "}\n" +
-         "}";
-      JsonObject aJsonObj = new JsonObject(jsonObjectString);
-      vertx.eventBus().send(incomingVertxAddress1, aJsonObj);
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_JSON_OBJECT, vertxType);
-      String recvJsonString = msg.getBodyBuffer().readString();
-      System.out.println("==== received json: " + recvJsonString);
-      assertEquals(aJsonObj, new JsonObject(recvJsonString));
-
-      //send a JsonArray
-      String jsonArrayString = "[\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.7668,\n" +
-         "\"Longitude\": -122.3959,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SAN FRANCISCO\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94107\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "},\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.371991,\n" +
-         "\"Longitude\": -122.026020,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SUNNYVALE\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94085\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "}\n" +
-         "]";
-      JsonArray aJsonArray = new JsonArray(jsonArrayString);
-      System.out.println("a json array string: " + aJsonArray);
-      vertx.eventBus().send(incomingVertxAddress1, aJsonArray);
-
-      msg = receiveFromQueue(incomingQueue1);
-      assertNotNull(msg);
-      vertxType = msg.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-      assertEquals(VertxConstants.TYPE_JSON_ARRAY, vertxType);
-      recvJsonString = msg.getBodyBuffer().readString();
-      System.out.println("==== received json: " + recvJsonString);
-      assertEquals(aJsonArray, new JsonArray(recvJsonString));
-   }
-
-   /**
-    * vertx events (incomingVertxAddress2)
-    * ===> (inOutQueue1)
-    * ===> (outgoing handler)
-    * ===> send to vertx (outgoingVertxAddress1)
-    */
-   @Test
-   public void testOutgoingEvents() throws Exception {
-      Vertx vertx = vertxManager.vertx();
-
-      //regiser a handler to receive outgoing messages
-      VertxTestHandler handler = new VertxTestHandler();
-      vertx.eventBus().registerHandler(outgoingVertxAddress1, handler);
-
-      //send a string message
-      String greeting = "Hello World!";
-      vertx.eventBus().send(incomingVertxAddress2, greeting);
-
-      //check message in handler
-      handler.checkStringMessageReceived(greeting);
-
-      //send a Buffer message
-      final byte[] content = greeting.getBytes(StandardCharsets.UTF_8);
-      Buffer buffer = new Buffer(content);
-      vertx.eventBus().send(incomingVertxAddress2, buffer);
-
-      handler.checkBufferMessageReceived(buffer);
-
-      //send a boolean
-      Boolean boolValue = Boolean.TRUE;
-      vertx.eventBus().send(incomingVertxAddress2, boolValue);
-
-      handler.checkBooleanMessageReceived(boolValue);
-
-      byte[] byteArray = greeting.getBytes(StandardCharsets.UTF_8);
-      vertx.eventBus().send(incomingVertxAddress2, byteArray);
-
-      handler.checkByteArrayMessageReceived(byteArray);
-
-      //send a byte
-      Byte aByte = (byte) 15;
-      vertx.eventBus().send(incomingVertxAddress2, aByte);
-
-      handler.checkByteMessageReceived(aByte);
-
-      //send a Character
-      Character aChar = 'a';
-      vertx.eventBus().send(incomingVertxAddress2, aChar);
-
-      handler.checkCharacterMessageReceived(aChar);
-
-      //send a Double
-      Double aDouble = 1234.56d;
-      vertx.eventBus().send(incomingVertxAddress2, aDouble);
-
-      handler.checkDoubleMessageReceived(aDouble);
-
-      //send a Float
-      Float aFloat = 1234.56f;
-      vertx.eventBus().send(incomingVertxAddress2, aFloat);
-
-      handler.checkFloatMessageReceived(aFloat);
-
-      //send an Integer
-      Integer aInt = 1234;
-      vertx.eventBus().send(incomingVertxAddress2, aInt);
-
-      handler.checkIntegerMessageReceived(aInt);
-
-      //send a Long
-      Long aLong = 12345678L;
-      vertx.eventBus().send(incomingVertxAddress2, aLong);
-
-      handler.checkLongMessageReceived(aLong);
-
-      //send a Short
-      Short aShort = (short) 321;
-      vertx.eventBus().send(incomingVertxAddress2, aShort);
-
-      handler.checkShortMessageReceived(aShort);
-
-      //send a JsonObject
-      String jsonObjectString = "{\n" +
-         "\"Image\": {\n" +
-         "\"Width\":  800,\n" +
-         "\"Height\": 600,\n" +
-         "\"Title\":  \"View from 15th Floor\",\n" +
-         "\"Thumbnail\": {\n" +
-         "\"Url\":    \"http://www.example.com/image/481989943\",\n" +
-         "\"Height\": 125,\n" +
-         "\"Width\":  100\n" +
-         "},\n" +
-         "\"IDs\": [116, 943, 234, 38793]\n" +
-         "}\n" +
-         "}";
-      JsonObject aJsonObj = new JsonObject(jsonObjectString);
-      vertx.eventBus().send(incomingVertxAddress2, aJsonObj);
-
-      handler.checkJsonObjectMessageReceived(aJsonObj);
-
-      //send a JsonArray
-      String jsonArrayString = "[\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.7668,\n" +
-         "\"Longitude\": -122.3959,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SAN FRANCISCO\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94107\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "},\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.371991,\n" +
-         "\"Longitude\": -122.026020,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SUNNYVALE\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94085\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "}\n" +
-         "]";
-      JsonArray aJsonArray = new JsonArray(jsonArrayString);
-      vertx.eventBus().send(incomingVertxAddress2, aJsonArray);
-
-      handler.checkJsonArrayMessageReceived(aJsonArray);
-   }
-
-   /**
-    * vertx events (incomingVertxAddress3)
-    * ===> (inOutQueue2)
-    * ===> (outgoing handler)
-    * ===> public to vertx (outgoingVertxAddress2)
-    */
-   @Test
-   public void testOutgoingEvents2() throws Exception {
-      Vertx vertx = vertxManager.vertx();
-
-      //regiser two handlers to receive outgoing messages
-      VertxTestHandler handler1 = new VertxTestHandler();
-      vertx.eventBus().registerHandler(outgoingVertxAddress2, handler1);
-      VertxTestHandler handler2 = new VertxTestHandler();
-      vertx.eventBus().registerHandler(outgoingVertxAddress2, handler2);
-
-      //send a string message
-      String greeting = "Hello World!";
-      vertx.eventBus().send(incomingVertxAddress3, greeting);
-
-      //check message in handler
-      handler1.checkStringMessageReceived(greeting);
-      handler2.checkStringMessageReceived(greeting);
-
-      //send a Buffer message
-      final byte[] content = greeting.getBytes(StandardCharsets.UTF_8);
-      Buffer buffer = new Buffer(content);
-      vertx.eventBus().send(incomingVertxAddress3, buffer);
-
-      handler1.checkBufferMessageReceived(buffer);
-      handler2.checkBufferMessageReceived(buffer);
-
-      //send a boolean
-      Boolean boolValue = Boolean.TRUE;
-      vertx.eventBus().send(incomingVertxAddress3, boolValue);
-
-      handler1.checkBooleanMessageReceived(boolValue);
-      handler2.checkBooleanMessageReceived(boolValue);
-
-      byte[] byteArray = greeting.getBytes(StandardCharsets.UTF_8);
-      vertx.eventBus().send(incomingVertxAddress3, byteArray);
-
-      handler1.checkByteArrayMessageReceived(byteArray);
-      handler2.checkByteArrayMessageReceived(byteArray);
-
-      //send a byte
-      Byte aByte = (byte) 15;
-      vertx.eventBus().send(incomingVertxAddress3, aByte);
-
-      handler1.checkByteMessageReceived(aByte);
-      handler2.checkByteMessageReceived(aByte);
-
-      //send a Character
-      Character aChar = 'a';
-      vertx.eventBus().send(incomingVertxAddress3, aChar);
-
-      handler1.checkCharacterMessageReceived(aChar);
-      handler2.checkCharacterMessageReceived(aChar);
-
-      //send a Double
-      Double aDouble = 1234.56d;
-      vertx.eventBus().send(incomingVertxAddress3, aDouble);
-
-      handler1.checkDoubleMessageReceived(aDouble);
-      handler2.checkDoubleMessageReceived(aDouble);
-
-      //send a Float
-      Float aFloat = 1234.56f;
-      vertx.eventBus().send(incomingVertxAddress3, aFloat);
-
-      handler1.checkFloatMessageReceived(aFloat);
-      handler2.checkFloatMessageReceived(aFloat);
-
-      //send an Integer
-      Integer aInt = 1234;
-      vertx.eventBus().send(incomingVertxAddress3, aInt);
-
-      handler1.checkIntegerMessageReceived(aInt);
-      handler2.checkIntegerMessageReceived(aInt);
-
-      //send a Long
-      Long aLong = 12345678L;
-      vertx.eventBus().send(incomingVertxAddress3, aLong);
-
-      handler1.checkLongMessageReceived(aLong);
-      handler2.checkLongMessageReceived(aLong);
-
-      //send a Short
-      Short aShort = (short) 321;
-      vertx.eventBus().send(incomingVertxAddress3, aShort);
-
-      handler1.checkShortMessageReceived(aShort);
-      handler2.checkShortMessageReceived(aShort);
-
-      //send a JsonObject
-      String jsonObjectString = "{\n" +
-         "\"Image\": {\n" +
-         "\"Width\":  800,\n" +
-         "\"Height\": 600,\n" +
-         "\"Title\":  \"View from 15th Floor\",\n" +
-         "\"Thumbnail\": {\n" +
-         "\"Url\":    \"http://www.example.com/image/481989943\",\n" +
-         "\"Height\": 125,\n" +
-         "\"Width\":  100\n" +
-         "},\n" +
-         "\"IDs\": [116, 943, 234, 38793]\n" +
-         "}\n" +
-         "}";
-      JsonObject aJsonObj = new JsonObject(jsonObjectString);
-      vertx.eventBus().send(incomingVertxAddress3, aJsonObj);
-
-      handler1.checkJsonObjectMessageReceived(aJsonObj);
-      handler2.checkJsonObjectMessageReceived(aJsonObj);
-
-      //send a JsonArray
-      String jsonArrayString = "[\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.7668,\n" +
-         "\"Longitude\": -122.3959,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SAN FRANCISCO\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94107\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "},\n" +
-         "{\n" +
-         "\"precision\": \"zip\",\n" +
-         "\"Latitude\":  37.371991,\n" +
-         "\"Longitude\": -122.026020,\n" +
-         "\"Address\":   \"\",\n" +
-         "\"City\":      \"SUNNYVALE\",\n" +
-         "\"State\":     \"CA\",\n" +
-         "\"Zip\":       \"94085\",\n" +
-         "\"Country\":   \"US\"\n" +
-         "}\n" +
-         "]";
-      JsonArray aJsonArray = new JsonArray(jsonArrayString);
-      vertx.eventBus().send(incomingVertxAddress3, aJsonArray);
-
-      handler1.checkJsonArrayMessageReceived(aJsonArray);
-      handler2.checkJsonArrayMessageReceived(aJsonArray);
-
-   }
-
-   private ClientMessage receiveFromQueue(String queueName) throws Exception {
-      ClientMessage msg = null;
-
-      try (ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true)) {
-
-         ClientConsumer consumer = session.createConsumer(queueName);
-         session.start();
-         msg = consumer.receive(60 * 1000);
-         msg.acknowledge();
-         session.commit();
-      }
-      return msg;
-   }
-
-   private void createVertxService() {
-      System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName());
-      vertxManager = PlatformLocator.factory.createPlatformManager(Integer.valueOf(port), host);
-   }
-
-   private class VertxTestHandler implements Handler<BaseMessage<?>> {
-
-      private volatile BaseMessage<?> vertxMsg = null;
-      private final Object lock = new Object();
-
-      @Override
-      public void handle(BaseMessage<?> arg0) {
-         synchronized (lock) {
-            vertxMsg = arg0;
-            lock.notify();
-         }
-      }
-
-      void checkJsonArrayMessageReceived(JsonArray aJsonArray) {
-         BaseMessage<?> msg = waitMessage();
-         JsonArray body = (JsonArray) msg.body();
-         assertEquals(aJsonArray, body);
-      }
-
-      void checkJsonObjectMessageReceived(final JsonObject aJsonObj) {
-         BaseMessage<?> msg = waitMessage();
-         JsonObject body = (JsonObject) msg.body();
-         assertEquals(aJsonObj, body);
-      }
-
-      void checkShortMessageReceived(final Short aShort) {
-         BaseMessage<?> msg = waitMessage();
-         Short body = (Short) msg.body();
-         assertEquals(aShort, body);
-      }
-
-      void checkLongMessageReceived(final Long aLong) {
-         BaseMessage<?> msg = waitMessage();
-         Long body = (Long) msg.body();
-         assertEquals(aLong, body);
-      }
-
-      void checkIntegerMessageReceived(final Integer aInt) {
-         BaseMessage<?> msg = waitMessage();
-         Integer body = (Integer) msg.body();
-         assertEquals(aInt, body);
-      }
-
-      void checkFloatMessageReceived(final Float aFloat) {
-         BaseMessage<?> msg = waitMessage();
-         Float body = (Float) msg.body();
-         assertEquals(aFloat, body);
-      }
-
-      void checkDoubleMessageReceived(final Double aDouble) {
-         BaseMessage<?> msg = waitMessage();
-         Double body = (Double) msg.body();
-         assertEquals(aDouble, body);
-      }
-
-      void checkCharacterMessageReceived(final Character aChar) {
-         BaseMessage<?> msg = waitMessage();
-         Character body = (Character) msg.body();
-         assertEquals(aChar, body);
-      }
-
-      void checkByteMessageReceived(final Byte aByte) {
-         BaseMessage<?> msg = waitMessage();
-         Byte body = (Byte) msg.body();
-         assertEquals(aByte, body);
-      }
-
-      void checkByteArrayMessageReceived(final byte[] byteArray) {
-         BaseMessage<?> msg = waitMessage();
-         byte[] body = (byte[]) msg.body();
-         assertEquals(byteArray.length, body.length);
-         for (int i = 0; i < byteArray.length; i++) {
-            assertEquals(byteArray[i], body[i]);
-         }
-      }
-
-      void checkBooleanMessageReceived(final Boolean boolValue) {
-         BaseMessage<?> msg = waitMessage();
-         Boolean body = (Boolean) msg.body();
-         assertEquals(boolValue, body);
-      }
-
-      void checkStringMessageReceived(final String str) {
-         BaseMessage<?> msg = waitMessage();
-         String body = (String) msg.body();
-         assertEquals(str, body);
-      }
-
-      void checkBufferMessageReceived(final Buffer buffer) {
-         byte[] source = buffer.getBytes();
-         BaseMessage<?> msg = waitMessage();
-         Buffer body = (Buffer) msg.body();
-         byte[] bytes = body.getBytes();
-         assertEquals(source.length, bytes.length);
-         for (int i = 0; i < bytes.length; i++) {
-            assertEquals(source[i], bytes[i]);
-         }
-      }
-
-      private BaseMessage<?> waitMessage() {
-         BaseMessage<?> msg = null;
-         synchronized (lock) {
-            long timeout = System.currentTimeMillis() + 10000;
-            while (vertxMsg == null && timeout > System.currentTimeMillis()) {
-               try {
-                  lock.wait(1000);
-               } catch (InterruptedException e) {
-               }
-            }
-            msg = vertxMsg;
-            vertxMsg = null;
-         }
-         assertNotNull("Message didn't arrive after 10 seconds.", msg);
-         return msg;
-      }
-
-   }
-
-   @After
-   @Override
-   public void tearDown() throws Exception {
-      vertxManager.stop();
-      server.stop();
-      server = null;
-
-      // Something on vertx is setting the TCL to null what would break subsequent tests
-      Thread.currentThread().setContextClassLoader(contextClassLoader);
-      super.tearDown();
-   }
-
-   private CoreQueueConfiguration createCoreQueueConfiguration(String queueName) {
-      return new CoreQueueConfiguration().setAddress(queueName).setName(queueName);
-   }
-
-   private ConnectorServiceConfiguration createOutgoingConnectorServiceConfiguration(HashMap<String, Object> config,
-                                                                                     String name) {
-      return new ConnectorServiceConfiguration().setFactoryClassName(VertxOutgoingConnectorServiceFactory.class.getName()).setParams(config).setName(name);
-   }
-
-   private ConnectorServiceConfiguration createIncomingConnectorServiceConfiguration(HashMap<String, Object> config,
-                                                                                     String name) {
-      return new ConnectorServiceConfiguration().setFactoryClassName(VertxIncomingConnectorServiceFactory.class.getName()).setParams(config).setName(name);
-   }
-
-   private HashMap<String, Object> createIncomingConnectionConfig(String vertxAddress, String incomingQueue) {
-      HashMap<String, Object> config1 = new HashMap<>();
-      config1.put(VertxConstants.HOST, host);
-      config1.put(VertxConstants.PORT, port);
-      config1.put(VertxConstants.VERTX_ADDRESS, vertxAddress);
-      config1.put(VertxConstants.QUEUE_NAME, incomingQueue);
-      return config1;
-   }
-
-   private HashMap<String, Object> createOutgoingConnectionConfig(String queueName, String vertxAddress) {
-      HashMap<String, Object> config1 = new HashMap<>();
-      config1.put(VertxConstants.HOST, host);
-      config1.put(VertxConstants.PORT, port);
-      config1.put(VertxConstants.QUEUE_NAME, queueName);
-      config1.put(VertxConstants.VERTX_ADDRESS, vertxAddress);
-      return config1;
-   }
-}


[05/29] activemq-artemis git commit: removing vertx

Posted by cl...@apache.org.
removing vertx


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4fd9b5ea
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4fd9b5ea
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4fd9b5ea

Branch: refs/heads/artemis-1009
Commit: 4fd9b5ea25371ea71620fa4ce7322b63ae824775
Parents: 61e10fe
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Feb 6 19:57:16 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 artemis-distribution/pom.xml                    |   5 -
 docs/user-manual/en/SUMMARY.md                  |   1 -
 docs/user-manual/en/vertx-integration.md        |  88 ---
 examples/features/sub-modules/pom.xml           |   1 -
 examples/features/sub-modules/vertx/pom.xml     | 142 ----
 examples/features/sub-modules/vertx/readme.html | 103 ---
 .../artemis/core/example/ExampleVerticle.java   |  53 --
 .../core/example/VertxConnectorExample.java     | 103 ---
 .../main/resources/activemq/server0/broker.xml  |  82 --
 integration/activemq-vertx-integration/pom.xml  | 144 ----
 .../integration/vertx/ActiveMQVertxLogger.java  |  55 --
 .../vertx/IncomingVertxEventHandler.java        | 265 -------
 .../vertx/OutgoingVertxEventHandler.java        | 290 -------
 .../integration/vertx/VertxConstants.java       |  82 --
 .../VertxIncomingConnectorServiceFactory.java   |  51 --
 .../VertxOutgoingConnectorServiceFactory.java   |  49 --
 pom.xml                                         |   6 -
 tests/integration-tests/pom.xml                 |  38 -
 .../integration/mqtt/imported/MQTTTest.java     |   2 +-
 .../vertx/ActiveMQVertxUnitTest.java            | 774 -------------------
 20 files changed, 1 insertion(+), 2333 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/artemis-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml
index 1236f17..7d5cc49 100644
--- a/artemis-distribution/pom.xml
+++ b/artemis-distribution/pom.xml
@@ -78,11 +78,6 @@
         <version>${project.version}</version>
      </dependency>
      <dependency>
-        <groupId>org.apache.activemq</groupId>
-        <artifactId>artemis-vertx-integration</artifactId>
-        <version>${project.version}</version>
-     </dependency>
-     <dependency>
         <groupId>org.apache.activemq.rest</groupId>
         <artifactId>artemis-rest</artifactId>
         <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 4030aa9..b612a5e 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -52,7 +52,6 @@
 * [Apache Karaf](karaf.md)
 * [Spring Integration](spring-integration.md)
 * [AeroGear Integration](aerogear-integration.md)
-* [VertX Integration](vertx-integration.md)
 * [CDI Integration](cdi-integration.md)
 * [Intercepting Operations](intercepting-operations.md)
 * [Protocols and Interoperability](protocols-interoperability.md)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/docs/user-manual/en/vertx-integration.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/vertx-integration.md b/docs/user-manual/en/vertx-integration.md
deleted file mode 100644
index f823f11..0000000
--- a/docs/user-manual/en/vertx-integration.md
+++ /dev/null
@@ -1,88 +0,0 @@
-# Vert.x Integration
-
-[Vert.x](http://vertx.io/) is a lightweight, high performance
-application platform for the JVM that's designed for modern mobile, web,
-and enterprise applications. Vert.x provides a distributed event bus
-that allows messages to be sent across vert.x instances and clients. You
-can now redirect and persist any vert.x messages to Apache ActiveMQ Artemis and route
-those messages to a specified vertx address by configuring Apache ActiveMQ Artemis
-vertx incoming and outgoing vertx connector services.
-
-## Configuring a Vertx Incoming Connector Service
-
-Vertx Incoming Connector services receive messages from vertx event bus
-and route them to an Apache ActiveMQ Artemis queue. Such a service can be configured as
-follows:
-
-    <connector-service name="vertx-incoming-connector">
-    <factory-class>org.apache.activemq.integration.vertx.VertxIncomingConnectorServiceFactory</factory-class>
-    <param key="host" value="127.0.0.1"/>
-    <param key="port" value="0"/>
-    <param key="queue" value="jms.queue.vertxQueue"/>
-    <param key="vertx-address" value="vertx.in.eventaddress"/>
-    </connector-service>
-
-
-Shown are the required params for the connector service:
-
--   `queue`. The name of the Apache ActiveMQ Artemis queue to send message to.
-
-As well as these required parameters there are the following optional
-parameters
-
--   `host`. The host name on which the vertx target container is
-    running. Default is localhost.
-
--   `port`. The port number to which the target vertx listens. Default
-    is zero.
-
--   `quorum-size`. The quorum size of the target vertx instance.
-
--   `ha-group`. The name of the ha-group of target vertx instance.
-    Default is `activemq`.
-
--   `vertx-address`. The vertx address to listen to. default is
-    `org.apache.activemq`.
-
-## Configuring a Vertx Outgoing Connector Service
-
-Vertx Outgoing Connector services fetch vertx messages from a ActiveMQ
-queue and put them to vertx event bus. Such a service can be configured
-as follows:
-
-    <connector-service name="vertx-outgoing-connector">
-    <factory-class>org.apache.activemq.integration.vertx.VertxOutgoingConnectorServiceFactory</factory-class>
-    <param key="host" value="127.0.0.1"/>
-    <param key="port" value="0"/>
-    <param key="queue" value="jms.queue.vertxQueue"/>
-    <param key="vertx-address" value="vertx.out.eventaddress"/>
-    <param key="publish" value="true"/>
-    </connector-service>
-
-
-Shown are the required params for the connector service:
-
--   `queue`. The name of the Apache ActiveMQ Artemis queue to fetch message from.
-
-As well as these required parameters there are the following optional
-parameters
-
--   `host`. The host name on which the vertx target container is
-    running. Default is localhost.
-
--   `port`. The port number to which the target vertx listens. Default
-    is zero.
-
--   `quorum-size`. The quorum size of the target vertx instance.
-
--   `ha-group`. The name of the ha-group of target vertx instance.
-    Default is `activemq`.
-
--   `vertx-address`. The vertx address to put messages to. default is
-    org.apache.activemq.
-
--   `publish`. How messages is sent to vertx event bus. "true" means
-    using publish style. "false" means using send style. Default is
-    false.
-
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/pom.xml b/examples/features/sub-modules/pom.xml
index d59f915..ef47365 100644
--- a/examples/features/sub-modules/pom.xml
+++ b/examples/features/sub-modules/pom.xml
@@ -51,7 +51,6 @@ under the License.
          <modules>
             <module>aerogear</module>
             <module>artemis-ra-rar</module>
-            <module>vertx</module>
          </modules>
       </profile>
    </profiles>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/vertx/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/vertx/pom.xml b/examples/features/sub-modules/vertx/pom.xml
deleted file mode 100644
index c09aada..0000000
--- a/examples/features/sub-modules/vertx/pom.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<?xml version='1.0'?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-   <modelVersion>4.0.0</modelVersion>
-
-   <parent>
-      <groupId>org.apache.activemq.examples.modules</groupId>
-      <artifactId>broker-modules</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-   </parent>
-
-   <artifactId>artemis-vertx-example</artifactId>
-   <packaging>jar</packaging>
-   <name>ActiveMQ Artemis Vert.x Example</name>
-
-   <properties>
-      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
-      <vertx.version>2.1.2</vertx.version>
-   </properties>
-
-   <dependencies>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-server</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-core-client</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-commons</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>io.netty</groupId>
-         <artifactId>netty-all</artifactId>
-         <version>${netty.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.geronimo.specs</groupId>
-         <artifactId>geronimo-jms_2.0_spec</artifactId>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-core</artifactId>
-         <version>${vertx.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-platform</artifactId>
-         <version>${vertx.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-hazelcast</artifactId>
-         <version>${vertx.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-vertx-integration</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-
-   </dependencies>
-   <build>
-      <plugins>
-         <plugin>
-            <groupId>org.apache.activemq</groupId>
-            <artifactId>artemis-maven-plugin</artifactId>
-            <executions>
-               <execution>
-                  <id>create0</id>
-                  <goals>
-                     <goal>create</goal>
-                  </goals>
-                  <configuration>
-                     <libListWithDeps>
-                        <arg>org.apache.activemq.examples.modules:artemis-vertx-example:${project.version}</arg>
-                     </libListWithDeps>
-
-                     <instance>${basedir}/target/server0</instance>
-                     <configuration>${basedir}/target/classes/activemq/server0</configuration>
-                  </configuration>
-               </execution>
-               <execution>
-                  <id>start0</id>
-                  <goals>
-                     <goal>cli</goal>
-                  </goals>
-                  <configuration>
-                     <ignore>${noServer}</ignore>
-                     <spawn>true</spawn>
-                     <location>${basedir}/target/server0</location>
-                     <testURI>tcp://localhost:61616</testURI>
-                     <args>
-                        <param>run</param>
-                     </args>
-                     <name>server0</name>
-                  </configuration>
-               </execution>
-               <execution>
-                  <id>runClient</id>
-                  <goals>
-                     <goal>runClient</goal>
-                  </goals>
-                  <configuration>
-                     <clientClass>org.apache.activemq.artemis.core.example.VertxConnectorExample</clientClass>
-                  </configuration>
-               </execution>
-            </executions>
-            <dependencies>
-               <dependency>
-                  <groupId>org.apache.activemq.examples.modules</groupId>
-                  <artifactId>artemis-vertx-example</artifactId>
-                  <version>${project.version}</version>
-               </dependency>
-            </dependencies>
-         </plugin>
-      </plugins>
-   </build>
-</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/vertx/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/vertx/readme.html b/examples/features/sub-modules/vertx/readme.html
deleted file mode 100644
index e8f053a..0000000
--- a/examples/features/sub-modules/vertx/readme.html
+++ /dev/null
@@ -1,103 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<html>
-  <head>
-    <title>ActiveMQ Artemis Vert.x Connector Service Example</title>
-    <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
-    <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
-    <script type="text/javascript" src="../../../common/prettify.js"></script>
-  </head>
-  <body onload="prettyPrint()">
-     <h1>Vert.x Connector Service Example</h1>
-
-     <p>This example shows you how to configure ActiveMQ Artemis to use the Vert.x Connector Service.</p>
-
-     <p>ActiveMQ Artemis supports 2 types of Vert.x connector, incoming and outgoing.
-     Incoming connector consumes from Vert.x event bus and forwards to a configurable address.
-     Outgoing connector consumes from a configurable address and forwards to a configurable Vert.x event bus.
-     </p>
-
-     <p>In this example, an incoming connector and an outgoing connector are configured. A simple java Verticle
-     is deployed. The verticle registers a message handler on the outgoing connector's address ("outgoing.vertx.address").
-     A String message is sent to Vert.x event bus on the incoming connector's address("incoming.vertx.address").
-     The message then will be forwarded to a ActiveMQ Artemis queue by the incoming connector. The outgoing connector listens to
-     the ActiveMQ Artemis queue and forwards the message from ActiveMQ Artemis to Vert.x event bus on the outgoing connector's address.
-     The verticle finally receives the message from it's event bus.</p>
-
-     <p>For more information on Vert.x concept please visit the <a href="http://vertx.io/">Vertx site</a></p>
-
-     <h2>Example step-by-step</h2>
-     <p><i>To run the server, simply type <code>mvn verify</code>
-         from this directory.</p>
-
-     <ol>
-        <li>First we need to create a Vert.x PlatformManager</li>
-        <pre class="prettyprint">
-           <code>platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST);</code>
-        </pre>
-
-        <li>We deploy a Verticle using the platformManager</li>
-        <pre class="prettyprint">
-           <code>String verticle = "org.apache.activemq.artemis.core.example.ExampleVerticle";
-           platformManager.deployVerticle(verticle, null, new URL[0], 1, null,
-                  new Handler<AsyncResult<String>>(){
-
-                     @Override
-                     public void handle(AsyncResult<String> result)
-                     {
-                        if (!result.succeeded())
-                        {
-                           throw new RuntimeException("failed to deploy verticle", result.cause());
-                        }
-                        latch0.countDown();
-                     }
-
-           });</code>
-        </pre>
-
-        <li>We register a message handler with the event bus in the Verticle to listen on the outgoing connector's address.</li>
-        <pre class="prettyprint">
-           <code>EventBus eventBus = vertx.eventBus();
-           eventBus.registerHandler(VertxConnectorExample.OUTGOING,
-                      new Handler<Message<?>>() {
-                         @Override
-                         public void handle(Message<?> startMsg)
-                         {
-                            Object body = startMsg.body();
-                            System.out.println("Verticle receives a message: " + body);
-                            VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body));
-                            latch0.countDown();
-                         }
-                      });
-           </code>
-        </pre>
-
-        <li>We send a message to incoming connector's address via event bus</li>
-        <pre class="prettyprint">
-           <code>
-              EventBus bus = platformManager.vertx().eventBus();
-              bus.send(INCOMING, MSG);
-           </code>
-        </pre>
-
-        <li>The message will eventually arrives at the Verticle's message handler.</li>
-     </ol>
-  </body>
-</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java
deleted file mode 100644
index 3f248af..0000000
--- a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.example;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.vertx.java.core.Handler;
-import org.vertx.java.core.eventbus.EventBus;
-import org.vertx.java.core.eventbus.Message;
-import org.vertx.java.platform.Verticle;
-
-public class ExampleVerticle extends Verticle {
-
-   @Override
-   public void start() {
-      EventBus eventBus = vertx.eventBus();
-
-      final CountDownLatch latch0 = new CountDownLatch(1);
-
-      // Register a handler on the outgoing connector's address
-      eventBus.registerHandler(VertxConnectorExample.OUTGOING, new Handler<Message<?>>() {
-         @Override
-         public void handle(Message<?> startMsg) {
-            Object body = startMsg.body();
-            System.out.println("Verticle receives a message: " + body);
-            VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body));
-            latch0.countDown();
-            //Tell the example to finish.
-            VertxConnectorExample.latch.countDown();
-         }
-      });
-
-      try {
-         latch0.await(5000, TimeUnit.MILLISECONDS);
-      } catch (InterruptedException e) {
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java b/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java
deleted file mode 100644
index b8e6d98..0000000
--- a/examples/features/sub-modules/vertx/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.example;
-
-import java.net.URL;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.vertx.java.core.AsyncResult;
-import org.vertx.java.core.Handler;
-import org.vertx.java.core.eventbus.EventBus;
-import org.vertx.java.platform.PlatformLocator;
-import org.vertx.java.platform.PlatformManager;
-import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory;
-
-/**
- * A simple example of using Vert.x connector service.
- */
-public class VertxConnectorExample {
-
-   public static final String INCOMING = "incoming.vertx.address";
-   public static final String OUTGOING = "outgoing.vertx.address";
-   public static final String MSG = "Welcome to Vertx world!";
-
-   public static final CountDownLatch latch = new CountDownLatch(1);
-   public static final AtomicBoolean result = new AtomicBoolean(false);
-
-   private static final String HOST = "127.0.0.1";
-   private static final int PORT = 0;
-
-   public static void main(final String[] args) throws Exception {
-      System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName());
-      PlatformManager platformManager = null;
-
-      try {
-         // Step 1 Create a Vert.x PlatformManager
-         platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST);
-
-         final CountDownLatch latch0 = new CountDownLatch(1);
-
-         // Step 2 Deploy a Verticle to receive message
-         String verticle = "org.apache.activemq.artemis.core.example.ExampleVerticle";
-         platformManager.deployVerticle(verticle, null, new URL[0], 1, null, new Handler<AsyncResult<String>>() {
-
-            @Override
-            public void handle(AsyncResult<String> result) {
-               if (!result.succeeded()) {
-                  throw new RuntimeException("failed to deploy verticle", result.cause());
-               }
-               latch0.countDown();
-            }
-
-         });
-
-         latch0.await();
-
-         // Step 3 Send a message to the incoming connector's address
-         EventBus bus = platformManager.vertx().eventBus();
-         bus.send(INCOMING, MSG);
-
-         // Step 4 Waiting for the Verticle to process the message
-         latch.await(10000, TimeUnit.MILLISECONDS);
-      } finally {
-         if (platformManager != null) {
-            platformManager.undeployAll(null);
-            platformManager.stop();
-         }
-         reportResultAndExit();
-      }
-   }
-
-   private static void reportResultAndExit() {
-      if (!result.get()) {
-         System.err.println();
-         System.err.println("#####################");
-         System.err.println("###    FAILURE!   ###");
-         System.err.println("#####################");
-         System.exit(1);
-      } else {
-         System.out.println();
-         System.out.println("#####################");
-         System.out.println("###    SUCCESS!   ###");
-         System.out.println("#####################");
-         System.exit(0);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/examples/features/sub-modules/vertx/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/vertx/src/main/resources/activemq/server0/broker.xml b/examples/features/sub-modules/vertx/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index c550203..0000000
--- a/examples/features/sub-modules/vertx/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
-   
-   <core xmlns="urn:activemq:core">
-      <bindings-directory>target/server0/data/messaging/bindings</bindings-directory>
-
-      <journal-directory>target/server0/data/messaging/journal</journal-directory>
-
-      <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory>
-
-      <paging-directory>target/server0/data/messaging/paging</paging-directory>
-      <!-- Connectors -->
-
-      <connectors>
-         <connector name="netty-connector">tcp://localhost:61616</connector>
-      </connectors>
-
-      <!-- Acceptors -->
-      <acceptors>
-         <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
-      </acceptors>
-
-      <!-- Other config -->
-
-      <security-settings>
-         <!--security for example queue-->
-         <security-setting match="queue.vertxQueue">
-            <permission roles="guest" type="consume"/>
-            <permission roles="guest" type="send"/>
-         </security-setting>
-      </security-settings>
-
-      
-
-      <connector-services>
-         <connector-service name="my-incoming-vertx">
-            <factory-class>org.apache.activemq.artemis.integration.vertx.VertxIncomingConnectorServiceFactory</factory-class>
-            <param key="queue" value="queue.vertxQueue"/>
-            <param key="host" value="localhost"/>
-            <param key="port" value="0"/>
-            <param key="vertx-address" value="incoming.vertx.address"/>
-         </connector-service>
-         <connector-service name="my-outgoing-vertx">
-            <factory-class>org.apache.activemq.artemis.integration.vertx.VertxOutgoingConnectorServiceFactory</factory-class>
-            <param key="queue" value="queue.vertxQueue"/>
-            <param key="host" value="localhost"/>
-            <param key="port" value="0"/>
-            <param key="vertx-address" value="outgoing.vertx.address"/>
-         </connector-service>
-      </connector-services>
-   <addresses>
-         <address name="queue.vertxQueue">
-            <multicast>
-               <queue name="queue.vertxQueue"/>
-            </multicast>
-         </address>
-         <address name="exampleQueue">
-            <anycast>
-               <queue name="jms.queue.exampleQueue"/>
-            </anycast>
-         </address>
-      </addresses>
-   </core>
-
-</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/pom.xml
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/pom.xml b/integration/activemq-vertx-integration/pom.xml
deleted file mode 100644
index ef8d31c..0000000
--- a/integration/activemq-vertx-integration/pom.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-   <parent>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>artemis-pom</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-      <relativePath>../../pom.xml</relativePath>
-   </parent>
-
-   <artifactId>artemis-vertx-integration</artifactId>
-   <packaging>jar</packaging>
-   <name>ActiveMQ Artemis Vert.x Integration</name>
-
-  <properties>
-
-    <activemq.basedir>${project.basedir}/../..</activemq.basedir>
-
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-
-    <!-- Set pullInDeps to true if you want any modules specified in the 'includes' and 'deploys' fields
-    in your mod.json to be automatically pulled in during packaging and added inside your module. Doing this means your
-    module won't download and install those dependencies at run-time when they're first requested. -->
-    <vertx.pullInDeps>false</vertx.pullInDeps>
-
-    <!-- Set createFatJar to true if you want to create a fat executable jar which contains the Vert.x binaries
-    along with the module so it can be run with java -jar <jarname> -->
-    <vertx.createFatJar>false</vertx.createFatJar>
-
-    <!--Vertx module name-->
-    <module.name>${project.groupId}~${project.artifactId}~${project.version}</module.name>
-
-    <!-- The directory where the module will be assembled - you can override this on the command line
-    with -Dmods.directory=mydir -->
-    <mods.directory>target/mods</mods.directory>
-
-    <!--Dependency versions-->
-    <vertx.version>2.1.2</vertx.version>
-    <vertx.testtools.version>2.0.3-final</vertx.testtools.version>
-    <junit.version>4.11</junit.version>
-
-    <!--Plugin versions-->
-    <maven.compiler.plugin.version>3.0</maven.compiler.plugin.version>
-    <maven.resources.plugin.version>2.6</maven.resources.plugin.version>
-    <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
-    <maven.vertx.plugin.version>2.0.8-final</maven.vertx.plugin.version>
-    <maven.surefire.plugin.version>2.14</maven.surefire.plugin.version>
-    <maven.failsafe.plugin.version>2.14</maven.failsafe.plugin.version>
-    <maven.surefire.report.plugin.version>2.14</maven.surefire.report.plugin.version>
-    <maven.javadoc.plugin.version>2.9</maven.javadoc.plugin.version>
-    <maven.dependency.plugin.version>2.7</maven.dependency.plugin.version>
-  </properties>
-
-  <repositories>
-    <repository>
-      <id>sonatype-nexus-snapshots</id>
-      <url>https://oss.sonatype.org/content/repositories/public</url>
-    </repository>
-  </repositories>
-
-  <dependencies>
-     <dependency>
-        <groupId>org.jboss.logging</groupId>
-        <artifactId>jboss-logging-processor</artifactId>
-        <scope>provided</scope>
-        <optional>true</optional>
-     </dependency>
-
-      <!--
-          JBoss Logging
-      -->
-      <dependency>
-         <groupId>org.jboss.logging</groupId>
-         <artifactId>jboss-logging</artifactId>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-server</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-
-    <!--Vertx provided dependencies-->
-    <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>vertx-core</artifactId>
-      <version>${vertx.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>vertx-platform</artifactId>
-      <version>${vertx.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>vertx-hazelcast</artifactId>
-      <version>${vertx.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <!--Test dependencies-->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.11</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>testtools</artifactId>
-      <version>${vertx.testtools.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <!-- Add any other dependencies that you want packaged into your module (in the lib dir) here
-    as 'compile' dependencies. Here is an example
-    <dependency>
-      <groupId>org.hamcrest</groupId>
-      <artifactId>hamcrest-core</artifactId>
-      <version>1.3</version>
-      <scope>compile</scope>
-    </dependency>
-    -->
-
-  </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/ActiveMQVertxLogger.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/ActiveMQVertxLogger.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/ActiveMQVertxLogger.java
deleted file mode 100644
index 1f30c4c..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/ActiveMQVertxLogger.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.jboss.logging.BasicLogger;
-import org.jboss.logging.Logger;
-import org.jboss.logging.annotations.LogMessage;
-import org.jboss.logging.annotations.Message;
-import org.jboss.logging.annotations.MessageLogger;
-
-/**
- * Logger Code 19
- *
- * each message id must be 6 digits long starting with 19, the 3rd digit donates the level so
- *
- * INF0  1
- * WARN  2
- * DEBUG 3
- * ERROR 4
- * TRACE 5
- * FATAL 6
- *
- * so an INFO message would be 191000 to 191999
- */
-@MessageLogger(projectCode = "AMQ")
-interface ActiveMQVertxLogger extends BasicLogger {
-
-   /**
-    * The vertx logger.
-    */
-   ActiveMQVertxLogger LOGGER = Logger.getMessageLogger(ActiveMQVertxLogger.class, ActiveMQVertxLogger.class.getPackage().getName());
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 192001, value = "Non vertx message: {0}", format = Message.Format.MESSAGE_FORMAT)
-   void nonVertxMessage(ServerMessage message);
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 192002, value = "Invalid vertx type: {0}", format = Message.Format.MESSAGE_FORMAT)
-   void invalidVertxType(Integer type);
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java
deleted file mode 100644
index 4d89e6d..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/IncomingVertxEventHandler.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import java.util.Map;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.postoffice.Binding;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
-import org.apache.activemq.artemis.utils.ConfigurationHelper;
-import org.vertx.java.core.Handler;
-import org.vertx.java.core.buffer.Buffer;
-import org.vertx.java.core.eventbus.EventBus;
-import org.vertx.java.core.eventbus.Message;
-import org.vertx.java.core.eventbus.ReplyException;
-import org.vertx.java.core.eventbus.impl.PingMessage;
-import org.vertx.java.core.json.JsonArray;
-import org.vertx.java.core.json.JsonObject;
-import org.vertx.java.platform.PlatformLocator;
-import org.vertx.java.platform.PlatformManager;
-import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory;
-
-class IncomingVertxEventHandler implements ConnectorService {
-
-   private final String connectorName;
-
-   private final String queueName;
-
-   private final int port;
-
-   private final String host;
-
-   private final int quorumSize;
-
-   private final String haGroup;
-
-   private final String vertxAddress;
-
-   private EventBus eventBus;
-
-   private PlatformManager platformManager;
-
-   private EventHandler handler;
-
-   private final StorageManager storageManager;
-
-   private final PostOffice postOffice;
-
-   private boolean isStarted = false;
-
-   IncomingVertxEventHandler(String connectorName,
-                             Map<String, Object> configuration,
-                             StorageManager storageManager,
-                             PostOffice postOffice) {
-      this.connectorName = connectorName;
-      this.queueName = ConfigurationHelper.getStringProperty(VertxConstants.QUEUE_NAME, null, configuration);
-
-      this.port = ConfigurationHelper.getIntProperty(VertxConstants.PORT, 0, configuration);
-      this.host = ConfigurationHelper.getStringProperty(VertxConstants.HOST, "localhost", configuration);
-      this.quorumSize = ConfigurationHelper.getIntProperty(VertxConstants.VERTX_QUORUM_SIZE, -1, configuration);
-      this.haGroup = ConfigurationHelper.getStringProperty(VertxConstants.VERTX_HA_GROUP, "activemq", configuration);
-      this.vertxAddress = ConfigurationHelper.getStringProperty(VertxConstants.VERTX_ADDRESS, "org.apache.activemq", configuration);
-
-      this.storageManager = storageManager;
-      this.postOffice = postOffice;
-   }
-
-   @Override
-   public void start() throws Exception {
-      if (this.isStarted) {
-         return;
-      }
-      System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName());
-      if (quorumSize != -1) {
-         platformManager = PlatformLocator.factory.createPlatformManager(port, host, quorumSize, haGroup);
-      } else {
-         platformManager = PlatformLocator.factory.createPlatformManager(port, host);
-      }
-
-      eventBus = platformManager.vertx().eventBus();
-
-      Binding b = postOffice.getBinding(new SimpleString(queueName));
-      if (b == null) {
-         throw new Exception(connectorName + ": queue " + queueName + " not found");
-      }
-
-      handler = new EventHandler();
-      eventBus.registerHandler(vertxAddress, handler);
-
-      isStarted = true;
-      ActiveMQVertxLogger.LOGGER.debug(connectorName + ": started");
-   }
-
-   @Override
-   public void stop() throws Exception {
-      if (!isStarted) {
-         return;
-      }
-      eventBus.unregisterHandler(vertxAddress, handler);
-      platformManager.stop();
-      System.clearProperty("vertx.clusterManagerFactory");
-      isStarted = false;
-      ActiveMQVertxLogger.LOGGER.debug(connectorName + ": stopped");
-   }
-
-   @Override
-   public boolean isStarted() {
-      return isStarted;
-   }
-
-   @Override
-   public String getName() {
-      return connectorName;
-   }
-
-   private class EventHandler implements Handler<Message<?>> {
-
-      @Override
-      public void handle(Message<?> message) {
-         ServerMessage msg = new ServerMessageImpl(storageManager.generateID(), VertxConstants.INITIAL_MESSAGE_BUFFER_SIZE);
-         msg.setAddress(new SimpleString(queueName));
-         msg.setDurable(true);
-         msg.encodeMessageIDToBuffer();
-
-         String replyAddress = message.replyAddress();
-         if (replyAddress != null) {
-            msg.putStringProperty(VertxConstants.VERTX_MESSAGE_REPLYADDRESS, replyAddress);
-         }
-
-         // it'd be better that Message expose its type information
-         int type = getMessageType(message);
-
-         msg.putIntProperty(VertxConstants.VERTX_MESSAGE_TYPE, type);
-
-         manualEncodeVertxMessageBody(msg.getBodyBuffer(), message.body(), type);
-
-         try {
-            postOffice.route(msg, false);
-         } catch (Exception e) {
-            ActiveMQVertxLogger.LOGGER.error("failed to route msg " + msg, e);
-         }
-      }
-
-      private void manualEncodeVertxMessageBody(ActiveMQBuffer bodyBuffer, Object body, int type) {
-         switch (type) {
-            case VertxConstants.TYPE_BOOLEAN:
-               bodyBuffer.writeBoolean(((Boolean) body));
-               break;
-            case VertxConstants.TYPE_BUFFER:
-               Buffer buff = (Buffer) body;
-               int len = buff.length();
-               bodyBuffer.writeInt(len);
-               bodyBuffer.writeBytes(((Buffer) body).getBytes());
-               break;
-            case VertxConstants.TYPE_BYTEARRAY:
-               byte[] bytes = (byte[]) body;
-               bodyBuffer.writeInt(bytes.length);
-               bodyBuffer.writeBytes(bytes);
-               break;
-            case VertxConstants.TYPE_BYTE:
-               bodyBuffer.writeByte((byte) body);
-               break;
-            case VertxConstants.TYPE_CHARACTER:
-               bodyBuffer.writeChar((Character) body);
-               break;
-            case VertxConstants.TYPE_DOUBLE:
-               bodyBuffer.writeDouble((double) body);
-               break;
-            case VertxConstants.TYPE_FLOAT:
-               bodyBuffer.writeFloat((Float) body);
-               break;
-            case VertxConstants.TYPE_INT:
-               bodyBuffer.writeInt((Integer) body);
-               break;
-            case VertxConstants.TYPE_LONG:
-               bodyBuffer.writeLong((Long) body);
-               break;
-            case VertxConstants.TYPE_SHORT:
-               bodyBuffer.writeShort((Short) body);
-               break;
-            case VertxConstants.TYPE_STRING:
-            case VertxConstants.TYPE_PING:
-               bodyBuffer.writeString((String) body);
-               break;
-            case VertxConstants.TYPE_JSON_OBJECT:
-               bodyBuffer.writeString(((JsonObject) body).encode());
-               break;
-            case VertxConstants.TYPE_JSON_ARRAY:
-               bodyBuffer.writeString(((JsonArray) body).encode());
-               break;
-            case VertxConstants.TYPE_REPLY_FAILURE:
-               ReplyException except = (ReplyException) body;
-               bodyBuffer.writeInt(except.failureType().toInt());
-               bodyBuffer.writeInt(except.failureCode());
-               bodyBuffer.writeString(except.getMessage());
-               break;
-            default:
-               throw new IllegalArgumentException("Invalid body type: " + type);
-         }
-      }
-
-      private int getMessageType(Message<?> message) {
-
-         Object body = message.body();
-
-         if (message instanceof PingMessage) {
-            return VertxConstants.TYPE_PING;
-         } else if (body instanceof Buffer) {
-            return VertxConstants.TYPE_BUFFER;
-         } else if (body instanceof Boolean) {
-            return VertxConstants.TYPE_BOOLEAN;
-         } else if (body instanceof byte[]) {
-            return VertxConstants.TYPE_BYTEARRAY;
-         } else if (body instanceof Byte) {
-            return VertxConstants.TYPE_BYTE;
-         } else if (body instanceof Character) {
-            return VertxConstants.TYPE_CHARACTER;
-         } else if (body instanceof Double) {
-            return VertxConstants.TYPE_DOUBLE;
-         } else if (body instanceof Float) {
-            return VertxConstants.TYPE_FLOAT;
-         } else if (body instanceof Integer) {
-            return VertxConstants.TYPE_INT;
-         } else if (body instanceof Long) {
-            return VertxConstants.TYPE_LONG;
-         } else if (body instanceof Short) {
-            return VertxConstants.TYPE_SHORT;
-         } else if (body instanceof String) {
-            return VertxConstants.TYPE_STRING;
-         } else if (body instanceof JsonArray) {
-            return VertxConstants.TYPE_JSON_ARRAY;
-         } else if (body instanceof JsonObject) {
-            return VertxConstants.TYPE_JSON_OBJECT;
-         } else if (body instanceof ReplyException) {
-            return VertxConstants.TYPE_REPLY_FAILURE;
-         }
-         throw new IllegalArgumentException("Type not supported: " + message);
-      }
-
-   }
-
-   @Override
-   public String toString() {
-      return "[IncomingVertxEventHandler(" + connectorName + "), queueName: " + queueName + " host: " + host + " port: " + port + " vertxAddress: " + vertxAddress + "]";
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java
deleted file mode 100644
index 8820c39..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/OutgoingVertxEventHandler.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.postoffice.Binding;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.Consumer;
-import org.apache.activemq.artemis.core.server.HandleStatus;
-import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.utils.ConfigurationHelper;
-import org.vertx.java.core.buffer.Buffer;
-import org.vertx.java.core.eventbus.EventBus;
-import org.vertx.java.core.eventbus.ReplyException;
-import org.vertx.java.core.eventbus.ReplyFailure;
-import org.vertx.java.core.json.JsonArray;
-import org.vertx.java.core.json.JsonObject;
-import org.vertx.java.platform.PlatformLocator;
-import org.vertx.java.platform.PlatformManager;
-import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory;
-
-class OutgoingVertxEventHandler implements Consumer, ConnectorService {
-
-   private final String connectorName;
-
-   private final String queueName;
-
-   private final int port;
-
-   private final String host;
-
-   private final int quorumSize;
-
-   private final String haGroup;
-
-   private final String vertxAddress;
-
-   private final boolean publish;
-
-   private final PostOffice postOffice;
-
-   private Queue queue = null;
-
-   private Filter filter = null;
-
-   private EventBus eventBus;
-
-   private PlatformManager platformManager;
-
-   private boolean isStarted = false;
-
-   OutgoingVertxEventHandler(String connectorName, Map<String, Object> configuration, PostOffice postOffice) {
-      this.connectorName = connectorName;
-      this.queueName = ConfigurationHelper.getStringProperty(VertxConstants.QUEUE_NAME, null, configuration);
-      this.postOffice = postOffice;
-
-      this.port = ConfigurationHelper.getIntProperty(VertxConstants.PORT, 0, configuration);
-      this.host = ConfigurationHelper.getStringProperty(VertxConstants.HOST, "localhost", configuration);
-      this.quorumSize = ConfigurationHelper.getIntProperty(VertxConstants.VERTX_QUORUM_SIZE, -1, configuration);
-      this.haGroup = ConfigurationHelper.getStringProperty(VertxConstants.VERTX_HA_GROUP, "activemq", configuration);
-      this.vertxAddress = ConfigurationHelper.getStringProperty(VertxConstants.VERTX_ADDRESS, "org.apache.activemq", configuration);
-      this.publish = ConfigurationHelper.getBooleanProperty(VertxConstants.VERTX_PUBLISH, false, configuration);
-   }
-
-   @Override
-   public void start() throws Exception {
-      if (this.isStarted) {
-         return;
-      }
-      System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName());
-      if (quorumSize != -1) {
-         platformManager = PlatformLocator.factory.createPlatformManager(port, host, quorumSize, haGroup);
-      } else {
-         platformManager = PlatformLocator.factory.createPlatformManager(port, host);
-      }
-
-      eventBus = platformManager.vertx().eventBus();
-
-      if (this.connectorName == null || this.connectorName.trim().equals("")) {
-         throw new Exception("invalid connector name: " + this.connectorName);
-      }
-
-      if (this.queueName == null || this.queueName.trim().equals("")) {
-         throw new Exception("invalid queue name: " + queueName);
-      }
-
-      SimpleString name = new SimpleString(this.queueName);
-      Binding b = this.postOffice.getBinding(name);
-      if (b == null) {
-         throw new Exception(connectorName + ": queue " + queueName + " not found");
-      }
-      this.queue = (Queue) b.getBindable();
-      this.queue.addConsumer(this);
-
-      this.queue.deliverAsync();
-      this.isStarted = true;
-
-      ActiveMQVertxLogger.LOGGER.debug(connectorName + ": started");
-   }
-
-   @Override
-   public void stop() throws Exception {
-      if (!this.isStarted) {
-         return;
-      }
-
-      ActiveMQVertxLogger.LOGGER.debug(connectorName + ": receive shutdown request");
-
-      this.queue.removeConsumer(this);
-
-      this.platformManager.stop();
-      System.clearProperty("vertx.clusterManagerFactory");
-      this.isStarted = false;
-      ActiveMQVertxLogger.LOGGER.debug(connectorName + ": stopped");
-   }
-
-   @Override
-   public boolean isStarted() {
-      return this.isStarted;
-   }
-
-   @Override
-   public String getName() {
-      return this.connectorName;
-   }
-
-   @Override
-   public HandleStatus handle(MessageReference ref) throws Exception {
-      if (filter != null && !filter.match(ref.getMessage())) {
-         return HandleStatus.NO_MATCH;
-      }
-
-      synchronized (this) {
-         ref.handled();
-
-         ServerMessage message = ref.getMessage();
-
-         Object vertxMsgBody;
-         // extract information from message
-         Integer type = message.getIntProperty(VertxConstants.VERTX_MESSAGE_TYPE);
-
-         if (type == null) {
-            // log a warning and default to raw bytes
-            ActiveMQVertxLogger.LOGGER.nonVertxMessage(message);
-            type = VertxConstants.TYPE_RAWBYTES;
-         }
-
-         // from vertx
-         vertxMsgBody = extractMessageBody(message, type);
-
-         if (vertxMsgBody == null) {
-            return HandleStatus.NO_MATCH;
-         }
-
-         // send to bus
-         if (!publish) {
-            eventBus.send(vertxAddress, vertxMsgBody);
-         } else {
-            eventBus.publish(vertxAddress, vertxMsgBody);
-         }
-
-         queue.acknowledge(ref);
-
-         ActiveMQVertxLogger.LOGGER.debug(connectorName + ": forwarded to vertx: " + message.getMessageID());
-         return HandleStatus.HANDLED;
-      }
-   }
-
-   private Object extractMessageBody(ServerMessage message, Integer type) throws Exception {
-      Object vertxMsgBody = null;
-      ActiveMQBuffer bodyBuffer = message.getBodyBuffer();
-      switch (type) {
-         case VertxConstants.TYPE_PING:
-         case VertxConstants.TYPE_STRING:
-            bodyBuffer.resetReaderIndex();
-            vertxMsgBody = bodyBuffer.readString();
-            break;
-         case VertxConstants.TYPE_BUFFER:
-            int len = bodyBuffer.readInt();
-            byte[] bytes = new byte[len];
-            bodyBuffer.readBytes(bytes);
-            vertxMsgBody = new Buffer(bytes);
-            break;
-         case VertxConstants.TYPE_BOOLEAN:
-            vertxMsgBody = bodyBuffer.readBoolean();
-            break;
-         case VertxConstants.TYPE_BYTEARRAY:
-            int length = bodyBuffer.readInt();
-            byte[] byteArray = new byte[length];
-            bodyBuffer.readBytes(byteArray);
-            vertxMsgBody = byteArray;
-            break;
-         case VertxConstants.TYPE_BYTE:
-            vertxMsgBody = bodyBuffer.readByte();
-            break;
-         case VertxConstants.TYPE_CHARACTER:
-            vertxMsgBody = bodyBuffer.readChar();
-            break;
-         case VertxConstants.TYPE_DOUBLE:
-            vertxMsgBody = bodyBuffer.readDouble();
-            break;
-         case VertxConstants.TYPE_FLOAT:
-            vertxMsgBody = bodyBuffer.readFloat();
-            break;
-         case VertxConstants.TYPE_INT:
-            vertxMsgBody = bodyBuffer.readInt();
-            break;
-         case VertxConstants.TYPE_LONG:
-            vertxMsgBody = bodyBuffer.readLong();
-            break;
-         case VertxConstants.TYPE_SHORT:
-            vertxMsgBody = bodyBuffer.readShort();
-            break;
-         case VertxConstants.TYPE_JSON_OBJECT:
-            vertxMsgBody = new JsonObject(bodyBuffer.readString());
-            break;
-         case VertxConstants.TYPE_JSON_ARRAY:
-            vertxMsgBody = new JsonArray(bodyBuffer.readString());
-            break;
-         case VertxConstants.TYPE_REPLY_FAILURE:
-            int failureType = bodyBuffer.readInt();
-            int failureCode = bodyBuffer.readInt();
-            String errMsg = bodyBuffer.readString();
-            vertxMsgBody = new ReplyException(ReplyFailure.fromInt(failureType), failureCode, errMsg);
-            break;
-         case VertxConstants.TYPE_RAWBYTES:
-            int size = bodyBuffer.readableBytes();
-            byte[] rawBytes = new byte[size];
-            bodyBuffer.readBytes(rawBytes);
-            vertxMsgBody = rawBytes;
-            break;
-         default:
-            ActiveMQVertxLogger.LOGGER.invalidVertxType(type);
-            break;
-      }
-      return vertxMsgBody;
-   }
-
-   @Override
-   public void proceedDeliver(MessageReference reference) throws Exception {
-      // no op
-   }
-
-   @Override
-   public Filter getFilter() {
-      return this.filter;
-   }
-
-   @Override
-   public String debug() {
-      return null;
-   }
-
-   @Override
-   public String toManagementString() {
-      return null;
-   }
-
-   @Override
-   public List<MessageReference> getDeliveringMessages() {
-      return null;
-   }
-
-   @Override
-   public void disconnect() {
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxConstants.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxConstants.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxConstants.java
deleted file mode 100644
index e0d1537..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxConstants.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class VertxConstants {
-
-   // org.vertx.java.core.eventbus.impl.MessageFactory
-   public static final int TYPE_PING = 0;
-   public static final int TYPE_BUFFER = 1;
-   public static final int TYPE_BOOLEAN = 2;
-   public static final int TYPE_BYTEARRAY = 3;
-   public static final int TYPE_BYTE = 4;
-   public static final int TYPE_CHARACTER = 5;
-   public static final int TYPE_DOUBLE = 6;
-   public static final int TYPE_FLOAT = 7;
-   public static final int TYPE_INT = 8;
-   public static final int TYPE_LONG = 9;
-   public static final int TYPE_SHORT = 10;
-   public static final int TYPE_STRING = 11;
-   public static final int TYPE_JSON_OBJECT = 12;
-   public static final int TYPE_JSON_ARRAY = 13;
-   public static final int TYPE_REPLY_FAILURE = 100;
-   public static final int TYPE_RAWBYTES = 200;
-
-   public static final String PORT = "port";
-   public static final String HOST = "host";
-   public static final String QUEUE_NAME = "queue";
-   public static final String VERTX_ADDRESS = "vertx-address";
-   public static final String VERTX_PUBLISH = "publish";
-   public static final String VERTX_QUORUM_SIZE = "quorum-size";
-   public static final String VERTX_HA_GROUP = "ha-group";
-
-   public static final Set<String> ALLOWABLE_INCOMING_CONNECTOR_KEYS;
-   public static final Set<String> REQUIRED_INCOMING_CONNECTOR_KEYS;
-   public static final Set<String> ALLOWABLE_OUTGOING_CONNECTOR_KEYS;
-   public static final Set<String> REQUIRED_OUTGOING_CONNECTOR_KEYS;
-   public static final int INITIAL_MESSAGE_BUFFER_SIZE = 50;
-   public static final String VERTX_MESSAGE_REPLYADDRESS = "VertxMessageReplyAddress";
-   public static final String VERTX_MESSAGE_TYPE = "VertxMessageType";
-
-   static {
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS = new HashSet<>();
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(PORT);
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(HOST);
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(QUEUE_NAME);
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(VERTX_ADDRESS);
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(VERTX_QUORUM_SIZE);
-      ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(VERTX_HA_GROUP);
-
-      REQUIRED_INCOMING_CONNECTOR_KEYS = new HashSet<>();
-      REQUIRED_INCOMING_CONNECTOR_KEYS.add(QUEUE_NAME);
-
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS = new HashSet<>();
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(PORT);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(HOST);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(QUEUE_NAME);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(VERTX_ADDRESS);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(VERTX_PUBLISH);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(VERTX_QUORUM_SIZE);
-      ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(VERTX_HA_GROUP);
-
-      REQUIRED_OUTGOING_CONNECTOR_KEYS = new HashSet<>();
-      REQUIRED_OUTGOING_CONNECTOR_KEYS.add(QUEUE_NAME);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxIncomingConnectorServiceFactory.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxIncomingConnectorServiceFactory.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxIncomingConnectorServiceFactory.java
deleted file mode 100644
index 03afe20..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxIncomingConnectorServiceFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
-
-public class VertxIncomingConnectorServiceFactory implements ConnectorServiceFactory {
-
-   @Override
-   public ConnectorService createConnectorService(String connectorName,
-                                                  Map<String, Object> configuration,
-                                                  StorageManager storageManager,
-                                                  PostOffice postOffice,
-                                                  ScheduledExecutorService scheduledThreadPool) {
-
-      return new IncomingVertxEventHandler(connectorName, configuration, storageManager, postOffice);
-
-   }
-
-   @Override
-   public Set<String> getAllowableProperties() {
-      return VertxConstants.ALLOWABLE_INCOMING_CONNECTOR_KEYS;
-   }
-
-   @Override
-   public Set<String> getRequiredProperties() {
-      return VertxConstants.REQUIRED_INCOMING_CONNECTOR_KEYS;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxOutgoingConnectorServiceFactory.java
----------------------------------------------------------------------
diff --git a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxOutgoingConnectorServiceFactory.java b/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxOutgoingConnectorServiceFactory.java
deleted file mode 100644
index 2ae0848..0000000
--- a/integration/activemq-vertx-integration/src/main/java/org/apache/activemq/artemis/integration/vertx/VertxOutgoingConnectorServiceFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.vertx;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
-
-public class VertxOutgoingConnectorServiceFactory implements ConnectorServiceFactory {
-
-   @Override
-   public ConnectorService createConnectorService(String connectorName,
-                                                  Map<String, Object> configuration,
-                                                  StorageManager storageManager,
-                                                  PostOffice postOffice,
-                                                  ScheduledExecutorService scheduledThreadPool) {
-      return new OutgoingVertxEventHandler(connectorName, configuration, postOffice);
-   }
-
-   @Override
-   public Set<String> getAllowableProperties() {
-      return VertxConstants.ALLOWABLE_OUTGOING_CONNECTOR_KEYS;
-   }
-
-   @Override
-   public Set<String> getRequiredProperties() {
-      return VertxConstants.REQUIRED_OUTGOING_CONNECTOR_KEYS;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 454aad2..d182bbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,6 @@
       <module>artemis-server-osgi</module>
       <module>integration/activemq-spring-integration</module>
       <module>integration/activemq-aerogear-integration</module>
-      <module>integration/activemq-vertx-integration</module>
       <module>artemis-distribution</module>
       <module>artemis-tools</module>
       <module>tests</module>
@@ -736,7 +735,6 @@
             <module>artemis-jdbc-store</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
-            <module>integration/activemq-vertx-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -772,7 +770,6 @@
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
-            <module>integration/activemq-vertx-integration</module>
             <module>examples</module>
             <module>tests</module>
             <module>artemis-distribution</module>
@@ -831,7 +828,6 @@
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
-            <module>integration/activemq-vertx-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -874,7 +870,6 @@
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
-            <module>integration/activemq-vertx-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -909,7 +904,6 @@
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
             <module>integration/activemq-aerogear-integration</module>
-            <module>integration/activemq-vertx-integration</module>
             <module>tests</module>
             <module>examples</module>
          </modules>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 8dd8b16..afdaee2 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -30,8 +30,6 @@
       <activemq.basedir>${project.basedir}/../..</activemq.basedir>
       <karaf.version>4.0.6</karaf.version>
      <pax.exam.version>4.9.1</pax.exam.version>
-      <vertx.version>2.1.6</vertx.version>
-      <vertx.testtools.version>2.0.3-final</vertx.testtools.version>
    </properties>
 
    <repositories>
@@ -123,11 +121,6 @@
       </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-vertx-integration</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-journal</artifactId>
          <version>${project.version}</version>
       </dependency>
@@ -248,37 +241,6 @@
          <scope>test</scope>
       </dependency>
 
-      <!--Vertx provided dependencies-->
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-core</artifactId>
-         <version>${vertx.version}</version>
-         <scope>provided</scope>
-         <exclusions>
-            <exclusion>
-               <groupId>log4j</groupId>
-               <artifactId>log4j</artifactId>
-            </exclusion>
-         </exclusions>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-platform</artifactId>
-         <version>${vertx.version}</version>
-         <scope>provided</scope>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>vertx-hazelcast</artifactId>
-         <version>${vertx.version}</version>
-         <scope>provided</scope>
-      </dependency>
-      <dependency>
-         <groupId>io.vertx</groupId>
-         <artifactId>testtools</artifactId>
-         <version>${vertx.testtools.version}</version>
-         <scope>test</scope>
-      </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
          <artifactId>activemq-client</artifactId>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4fd9b5ea/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
index 7a12f42..91db1d2a 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
@@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager;
 import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.tests.util.Wait;
+import org.apache.activemq.artemis.utils.ConcurrentHashSet;
 import org.fusesource.mqtt.client.BlockingConnection;
 import org.fusesource.mqtt.client.MQTT;
 import org.fusesource.mqtt.client.MQTTException;
@@ -57,7 +58,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.vertx.java.core.impl.ConcurrentHashSet;
 
 /**
  * QT


[02/29] activemq-artemis git commit: Fixing Compilation on examples

Posted by cl...@apache.org.
Fixing Compilation on examples


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/9d3260b9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/9d3260b9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/9d3260b9

Branch: refs/heads/artemis-1009
Commit: 9d3260b902405c8996589dd9061ff5c2e716d820
Parents: 062ab57
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Mar 2 09:45:07 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../artemis/jms/example/HatColourChangeTransformer.java       | 4 ++--
 .../artemis/jms/example/AddForwardingTimeTransformer.java     | 7 ++-----
 2 files changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9d3260b9/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
index 91fe808..df9d79e 100644
--- a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
+++ b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
@@ -16,14 +16,14 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 
 public class HatColourChangeTransformer implements Transformer {
 
    @Override
-   public ServerMessage transform(final ServerMessage message) {
+   public Message transform(final Message message) {
       SimpleString propName = new SimpleString("hat");
 
       SimpleString oldProp = message.getSimpleStringProperty(propName);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9d3260b9/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
index 32035e7..2f75d4c 100644
--- a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
+++ b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
@@ -16,16 +16,13 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import org.apache.activemq.artemis.api.core.SimpleString;
-
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 
 public class AddForwardingTimeTransformer implements Transformer {
 
    @Override
-   public ServerMessage transform(final ServerMessage message) {
-      message.putLongProperty(new SimpleString("time_of_forward"), System.currentTimeMillis());
-
+   public Message transform(final Message message) {
       return message;
    }
 


[26/29] activemq-artemis git commit: Fixing tests (clustering)

Posted by cl...@apache.org.
Fixing tests (clustering)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/03fdc204
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/03fdc204
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/03fdc204

Branch: refs/heads/artemis-1009
Commit: 03fdc204fbb811516ff7e10745e337fba3f6029e
Parents: ba1fea6
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 09:52:51 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/api/core/Message.java      | 20 ++++++++++++++++++--
 .../core/client/impl/ClientConsumerImpl.java    |  2 +-
 .../core/client/impl/ClientMessageImpl.java     |  5 -----
 .../core/client/impl/ClientMessageInternal.java |  7 -------
 .../core/client/impl/ClientProducerImpl.java    | 19 ++++++++++---------
 .../core/server/impl/ActiveMQServerImpl.java    |  3 +--
 6 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
index b266279..a6ef408 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.api.core;
 
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -174,14 +175,29 @@ public interface Message {
 
    void messageChanged();
 
+
+   /** Used for Large messages on Core.
+    *  Do not use this, it will go away
+    *  @deprecated  use it directly from core message, as it doesn't make sense on other protocols */
+   @Deprecated
+   default InputStream getBodyInputStream() {
+      return null;
+   }
+
    /**
     * Careful: Unless you are changing the body of the message, prefer getReadOnlyBodyBuffer
-    */
+    *  @deprecated  use it directly from core message, as it doesn't make sense on other protocols */
+   @Deprecated
    ActiveMQBuffer getBodyBuffer();
 
+   /**
+    *  @deprecated  use it directly from core message, as it doesn't make sense on other protocols */
+   @Deprecated
    ActiveMQBuffer getReadOnlyBodyBuffer();
 
-   /** Used in the cases of large messages */
+   /** Used in the cases of large messages
+    *  @deprecated  use it directly from core message, as it doesn't make sense on other protocols */
+   @Deprecated
    LargeBodyEncoder getBodyEncoder() throws ActiveMQException;
 
    /** Context can be used by the application server to inject extra control, like a protocol specific on the server.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java
index 2b4ab7e..d95aeba 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java
@@ -569,7 +569,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
 
    private void handleRegularMessage(ClientMessageInternal message) {
       if (message.getAddress() == null) {
-         message.setAddressTransient(queueInfo.getAddress());
+         message.setAddress(queueInfo.getAddress());
       }
 
       message.onReceipt(this);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
index 9472b01..252ae86 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
@@ -102,11 +102,6 @@ public class ClientMessageImpl extends CoreMessage implements ClientMessageInter
    }
 
    @Override
-   public void setAddressTransient(SimpleString address) {
-      this.address = address;
-   }
-
-   @Override
    public TypedProperties getProperties() {
       return this.checkProperties();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
index 878f799..4b87878 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
@@ -16,9 +16,6 @@
  */
 package org.apache.activemq.artemis.core.client.impl;
 
-import java.io.InputStream;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.utils.TypedProperties;
 
@@ -36,8 +33,6 @@ public interface ClientMessageInternal extends ClientMessage {
     */
    void setFlowControlSize(int flowControlSize);
 
-   void setAddressTransient(SimpleString address);
-
    void onReceipt(ClientConsumerInternal consumer);
 
    /**
@@ -47,6 +42,4 @@ public interface ClientMessageInternal extends ClientMessage {
 
    boolean isCompressed();
 
-   InputStream getBodyInputStream();
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
index ce16011..1704de0 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
@@ -208,7 +208,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
    }
 
    private void doSend(SimpleString sendingAddress,
-                       final Message msg,
+                       final Message msgToSend,
                        final SendAcknowledgementHandler handler,
                        final boolean forceAsync) throws ActiveMQException {
       if (sendingAddress == null) {
@@ -217,7 +217,8 @@ public class ClientProducerImpl implements ClientProducerInternal {
       session.startCall();
 
       try {
-         Message msgI = msg;
+         // In case we received message from another protocol, we first need to convert it to core as the ClientProducer only understands core
+         Message msg = msgToSend.toCore();
 
          ClientProducerCredits theCredits;
 
@@ -225,8 +226,8 @@ public class ClientProducerImpl implements ClientProducerInternal {
          // a note about the second check on the writerIndexSize,
          // If it's a server's message, it means this is being done through the bridge or some special consumer on the
          // server's on which case we can't' convert the message into large at the servers
-         if (sessionContext.supportsLargeMessage() && (getBodyInputStream(msgI) != null || msgI.isLargeMessage() ||
-            msgI.getBodyBuffer().writerIndex() > minLargeMessageSize)) {
+         if (sessionContext.supportsLargeMessage() && (getBodyInputStream(msg) != null || msg.isLargeMessage() ||
+            msg.getBodyBuffer().writerIndex() > minLargeMessageSize)) {
             isLarge = true;
          } else {
             isLarge = false;
@@ -248,19 +249,19 @@ public class ClientProducerImpl implements ClientProducerInternal {
          }
 
          if (groupID != null) {
-            msgI.putStringProperty(Message.HDR_GROUP_ID, groupID);
+            msg.putStringProperty(Message.HDR_GROUP_ID, groupID);
          }
 
-         final boolean sendBlockingConfig = msgI.isDurable() ? blockOnDurableSend : blockOnNonDurableSend;
+         final boolean sendBlockingConfig = msg.isDurable() ? blockOnDurableSend : blockOnNonDurableSend;
          final boolean forceAsyncOverride = handler != null;
          final boolean sendBlocking = sendBlockingConfig && !forceAsyncOverride;
 
          session.workDone();
 
          if (isLarge) {
-            largeMessageSend(sendBlocking, (CoreMessage)msgI, theCredits, handler);
+            largeMessageSend(sendBlocking, (CoreMessage)msg, theCredits, handler);
          } else {
-            sendRegularMessage(sendingAddress, msgI, sendBlocking, theCredits, handler);
+            sendRegularMessage(sendingAddress, msg, sendBlocking, theCredits, handler);
          }
       } finally {
          session.endCall();
@@ -268,7 +269,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
    }
 
    private InputStream getBodyInputStream(Message msgI) {
-      return ((ClientMessageInternal)msgI).getBodyInputStream();
+      return msgI.getBodyInputStream();
    }
 
    private void sendRegularMessage(final SimpleString sendingAddress,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/03fdc204/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 38500b7..2b5ecaf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -51,6 +51,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.ActiveMQDeleteAddressException;
 import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
@@ -127,7 +128,6 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueConfig;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.ServiceComponent;
@@ -2622,7 +2622,6 @@ public class ActiveMQServerImpl implements ActiveMQServer {
    @Override
    public void addProtocolManagerFactory(ProtocolManagerFactory factory) {
       protocolManagerFactories.add(factory);
-      new Exception("protocol....").printStackTrace();
    }
 
    @Override


[24/29] activemq-artemis git commit: using older proton version

Posted by cl...@apache.org.
using older proton version


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ba1fea6c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ba1fea6c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ba1fea6c

Branch: refs/heads/artemis-1009
Commit: ba1fea6ce324a6e9e6aa41a941f608c51e62ca1b
Parents: 7174b53
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 28 22:42:06 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../protocol/amqp/broker/AMQPMessage.java       |  8 +--
 .../message/JMSMappingOutboundTransformer.java  | 21 +-------
 .../proton/ProtonServerReceiverContext.java     | 19 +++++--
 .../protocol/amqp/util/DeliveryUtil.java        | 13 +++++
 .../artemis/protocol/amqp/util/TLSEncode.java   | 52 ++++++++++++++++++++
 .../amqp/client/util/UnmodifiableDelivery.java  |  3 +-
 6 files changed, 89 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index 1cb85ea..c963061 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -35,6 +35,7 @@ import org.apache.activemq.artemis.api.core.encode.BodyType;
 import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
 import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
+import org.apache.activemq.artemis.protocol.amqp.util.TLSEncode;
 import org.apache.activemq.artemis.utils.DataConstants;
 import org.apache.qpid.proton.amqp.UnsignedInteger;
 import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
@@ -46,7 +47,6 @@ import org.apache.qpid.proton.amqp.messaging.Section;
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.message.impl.MessageImpl;
-import org.apache.qpid.proton.util.TLSEncoder;
 
 // see https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
 public class AMQPMessage extends RefCountMessage {
@@ -183,7 +183,7 @@ public class AMQPMessage extends RefCountMessage {
    }
 
    private synchronized void partialDecode(ByteBuffer buffer, boolean readApplicationProperties) {
-      DecoderImpl decoder = TLSEncoder.getDecoder();
+      DecoderImpl decoder = TLSEncode.getDecoder();
       decoder.setByteBuffer(buffer);
       buffer.position(0);
 
@@ -500,8 +500,8 @@ public class AMQPMessage extends RefCountMessage {
             } else {
                header.setDeliveryCount(UnsignedInteger.valueOf(1));
             }
-            TLSEncoder.getEncoder().setByteBuffer(new NettyWritable(buffer));
-            TLSEncoder.getEncoder().writeObject(header);
+            TLSEncode.getEncoder().setByteBuffer(new NettyWritable(buffer));
+            TLSEncode.getEncoder().writeObject(header);
          }
       }
       buffer.writeBytes(data, headerEnd, data.writerIndex() - headerEnd);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
index 2ef3122..23bcaf1 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
@@ -71,6 +71,7 @@ import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMe
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException;
+import org.apache.activemq.artemis.protocol.amqp.util.TLSEncode;
 import org.apache.activemq.artemis.reader.MessageUtil;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.qpid.proton.amqp.Binary;
@@ -87,8 +88,6 @@ import org.apache.qpid.proton.amqp.messaging.Header;
 import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
 import org.apache.qpid.proton.amqp.messaging.Properties;
 import org.apache.qpid.proton.amqp.messaging.Section;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 import org.apache.qpid.proton.codec.WritableBuffer;
 import org.jboss.logging.Logger;
@@ -105,22 +104,6 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
    public static final byte TEMP_QUEUE_TYPE = 0x02;
    public static final byte TEMP_TOPIC_TYPE = 0x03;
 
-   // For now Proton requires that we create a decoder to create an encoder
-   private static class EncoderDecoderPair {
-      DecoderImpl decoder = new DecoderImpl();
-      EncoderImpl encoder = new EncoderImpl(decoder);
-      {
-         AMQPDefinedTypes.registerAllTypes(decoder, encoder);
-      }
-   }
-
-   private static final ThreadLocal<EncoderDecoderPair> tlsCodec = new ThreadLocal<EncoderDecoderPair>() {
-      @Override
-      protected EncoderDecoderPair initialValue() {
-         return new EncoderDecoderPair();
-      }
-   };
-
    public JMSMappingOutboundTransformer(IDGenerator idGenerator) {
       super(idGenerator);
    }
@@ -375,7 +358,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
          apMap.put(key, objectProperty);
       }
 
-      EncoderImpl encoder = tlsCodec.get().encoder;
+      EncoderImpl encoder = TLSEncode.getEncoder();
       encoder.setByteBuffer(buffer);
 
       if (header != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
----------------------------------------------------------------------
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 34c2c07..ea2635e 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
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.proton;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
@@ -23,6 +25,7 @@ import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPExceptio
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException;
 import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle;
+import org.apache.activemq.artemis.protocol.amqp.util.DeliveryUtil;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.messaging.Rejected;
 import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
@@ -131,6 +134,7 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
    @Override
    public void onMessage(Delivery delivery) throws ActiveMQAMQPException {
       Receiver receiver;
+      ByteBuf buffer = null;
       try {
          receiver = ((Receiver) delivery.getLink());
 
@@ -141,15 +145,20 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
          if (delivery.isPartial()) {
             return;
          }
-         byte[] data = new byte[delivery.getDataLength()];
+         // This should be used if getDataLength was avilable
+//         byte[] data = new byte[delivery.getDataLength()];
+
+         buffer = PooledByteBufAllocator.DEFAULT.heapBuffer(10 * 1024);
          Transaction tx = null;
 
          synchronized (connection.getLock()) {
-            receiver.recv(data, 0, data.length);
-
+            DeliveryUtil.readDelivery(receiver, buffer);
             receiver.advance();
          }
 
+         byte[] data = new byte[buffer.writerIndex()];
+         buffer.readBytes(data);
+
          if (delivery.getRemoteState() instanceof TransactionalState) {
 
             TransactionalState txState = (TransactionalState) delivery.getRemoteState();
@@ -170,6 +179,10 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
          rejected.setError(condition);
          delivery.disposition(rejected);
          delivery.settle();
+      } finally {
+         if (buffer != null) {
+            buffer.release();
+         }
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
index 0ff1d3b..9257c6b 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
@@ -17,11 +17,24 @@
 package org.apache.activemq.artemis.protocol.amqp.util;
 
 import io.netty.buffer.ByteBuf;
+import org.apache.qpid.proton.engine.Receiver;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.message.impl.MessageImpl;
 
 public class DeliveryUtil {
 
+   public static int readDelivery(Receiver receiver, ByteBuf buffer) {
+      int initial = buffer.writerIndex();
+      // optimization by norman
+      int count;
+      while ((count = receiver.recv(buffer.array(), buffer.arrayOffset() + buffer.writerIndex(), buffer.writableBytes())) > 0) {
+         // Increment the writer index by the number of bytes written into it while calling recv.
+         buffer.writerIndex(buffer.writerIndex() + count);
+         buffer.ensureWritable(count);
+      }
+      return buffer.writerIndex() - initial;
+   }
+
    public static MessageImpl decodeMessageImpl(ByteBuf buffer) {
       MessageImpl message = (MessageImpl) Message.Factory.create();
       message.decode(buffer.array(), buffer.arrayOffset() + buffer.readerIndex(), buffer.readableBytes());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/TLSEncode.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/TLSEncode.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/TLSEncode.java
new file mode 100644
index 0000000..b2f0fdc
--- /dev/null
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/TLSEncode.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.protocol.amqp.util;
+
+import org.apache.qpid.proton.codec.AMQPDefinedTypes;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+
+/** This can go away if Proton provides this feature. */
+public class TLSEncode {
+
+   // For now Proton requires that we create a decoder to create an encoder
+   private static class EncoderDecoderPair {
+      DecoderImpl decoder = new DecoderImpl();
+      EncoderImpl encoder = new EncoderImpl(decoder);
+      {
+         AMQPDefinedTypes.registerAllTypes(decoder, encoder);
+      }
+   }
+
+   private static final ThreadLocal<EncoderDecoderPair> tlsCodec = new ThreadLocal<EncoderDecoderPair>() {
+      @Override
+      protected EncoderDecoderPair initialValue() {
+         return new EncoderDecoderPair();
+      }
+   };
+
+   public static EncoderImpl getEncoder() {
+      return tlsCodec.get().encoder;
+   }
+
+   public static DecoderImpl getDecoder() {
+      return tlsCodec.get().decoder;
+   }
+
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ba1fea6c/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
index d7d7f9d..d9bddcb 100644
--- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
@@ -51,10 +51,11 @@ public class UnmodifiableDelivery implements Delivery {
       }
    }
 
+   /* waiting Pull Request sent
    @Override
    public int getDataLength() {
       return delivery.getDataLength();
-   }
+   } */
 
    @Override
    public DeliveryState getLocalState() {


[09/29] activemq-artemis git commit: Removing Aeroegear

Posted by cl...@apache.org.
Removing Aeroegear


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/02906b56
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/02906b56
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/02906b56

Branch: refs/heads/artemis-1009
Commit: 02906b5605625c408651ccce0c169ad3340e6221
Parents: 4fd9b5e
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Feb 6 21:17:39 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 artemis-distribution/pom.xml                    |   5 -
 .../activemq/artemis/ActiveMQWebLogger.java     |   5 +-
 docs/user-manual/en/SUMMARY.md                  |   1 -
 docs/user-manual/en/aerogear-integration.md     | 104 -----
 examples/features/sub-modules/aerogear/pom.xml  | 115 ------
 .../features/sub-modules/aerogear/readme.html   | 157 --------
 .../artemis/jms/example/AerogearExample.java    |  76 ----
 .../main/resources/activemq/server0/broker.xml  |  76 ----
 .../aerogear/src/main/resources/jndi.properties |  20 -
 examples/features/sub-modules/pom.xml           |   1 -
 .../aerogear-chat/aerogear-chat.css             | 102 -----
 .../aerogear-chat/aerogear-chat.js              | 116 ------
 .../aerogear-chat/aerogear-index.html           |  97 -----
 .../aerogear-chat/aerogear.min.js               |  19 -
 .../stomp-websockets/aerogear-chat/stomp.js     | 392 -------------------
 .../activemq-aerogear-integration/pom.xml       |  75 ----
 .../aerogear/ActiveMQAeroGearBundle.java        |  47 ---
 .../aerogear/ActiveMQAeroGearLogger.java        |  70 ----
 .../aerogear/AeroGearConnectorService.java      | 367 -----------------
 .../AeroGearConnectorServiceFactory.java        |  48 ---
 .../integration/aerogear/AeroGearConstants.java |  83 ----
 pom.xml                                         |   6 -
 tests/integration-tests/pom.xml                 |   5 -
 .../aerogear/AeroGearBasicServerTest.java       | 350 -----------------
 24 files changed, 1 insertion(+), 2336 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/artemis-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml
index 7d5cc49..7a5b637 100644
--- a/artemis-distribution/pom.xml
+++ b/artemis-distribution/pom.xml
@@ -82,11 +82,6 @@
         <artifactId>artemis-rest</artifactId>
         <version>${project.version}</version>
      </dependency>
-     <dependency>
-        <groupId>org.apache.activemq</groupId>
-        <artifactId>artemis-aerogear-integration</artifactId>
-        <version>${project.version}</version>
-     </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-web</artifactId>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java
----------------------------------------------------------------------
diff --git a/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java b/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java
index e4fd854..ae3592e 100644
--- a/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java
+++ b/artemis-web/src/main/java/org/apache/activemq/artemis/ActiveMQWebLogger.java
@@ -41,9 +41,6 @@ import java.io.File;
 @MessageLogger(projectCode = "AMQ")
 public interface ActiveMQWebLogger extends BasicLogger {
 
-   /**
-    * The aerogear logger.
-    */
    ActiveMQWebLogger LOGGER = Logger.getMessageLogger(ActiveMQWebLogger.class, ActiveMQWebLogger.class.getPackage().getName());
 
    @LogMessage(level = Logger.Level.INFO)
@@ -57,4 +54,4 @@ public interface ActiveMQWebLogger extends BasicLogger {
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 244003, value = "Temporary file not deleted on shutdown: {0}", format = Message.Format.MESSAGE_FORMAT)
    void tmpFileNotDeleted(File tmpdir);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index b612a5e..198e1fb 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -51,7 +51,6 @@
 * [Embedding Apache ActiveMQ Artemis](embedding-activemq.md)
 * [Apache Karaf](karaf.md)
 * [Spring Integration](spring-integration.md)
-* [AeroGear Integration](aerogear-integration.md)
 * [CDI Integration](cdi-integration.md)
 * [Intercepting Operations](intercepting-operations.md)
 * [Protocols and Interoperability](protocols-interoperability.md)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/docs/user-manual/en/aerogear-integration.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/aerogear-integration.md b/docs/user-manual/en/aerogear-integration.md
deleted file mode 100644
index 0dbafb2..0000000
--- a/docs/user-manual/en/aerogear-integration.md
+++ /dev/null
@@ -1,104 +0,0 @@
-# AeroGear Integration
-
-AeroGears push technology provides support for different push
-notification technologies like Google Cloud Messaging, Apple's APNs or
-Mozilla's SimplePush. Apache ActiveMQ Artemis allows you to configure a Connector
-Service that will consume messages from a queue and forward them to an
-AeroGear push server and subsequently sent as notifications to mobile
-devices.
-
-## Configuring an AeroGear Connector Service
-
-AeroGear Connector services are configured in the connector-services
-configuration:
-
-        <connector-service name="aerogear-connector">
-        <factory-class>org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory</factory-class>
-        <param key="endpoint" value="endpoint"/>
-        <param key="queue" value="jms.queue.aerogearQueue"/>
-        <param key="application-id" value="an applicationid"/>
-        <param key="master-secret" value="a mastersecret"/>
-        </connector-service>
-        <address-setting match="jms.queue.lastValueQueue">
-        <last-value-queue>true</last-value-queue>
-        </address-setting>
-
-
-Shown are the required params for the connector service and are:
-
--   `endpoint`. The endpoint or URL of you AeroGear application.
-
--   `queue`. The name of the queue to consume from.
-
--   `application-id`. The application id of your mobile application in
-    AeroGear.
-
--   `master-secret`. The secret of your mobile application in AeroGear.
-
-As well as these required parameters there are the following optional
-parameters
-
--   `ttl`. The time to live for the message once AeroGear receives it.
-
--   `badge`. The badge the mobile app should use for the notification.
-
--   `sound`. The sound the mobile app should use for the notification.
-
--   `filter`. A message filter(selector) to use on the connector.
-
--   `retry-interval`. If an error occurs on send, how long before we try
-    again to connect.
-
--   `retry-attempts`. How many times we should try to reconnect after an
-    error.
-
--   `variants`. A comma separated list of variants that should get the
-    message.
-
--   `aliases`. A list of aliases that should get the message.
-
--   `device-types`. A list of device types that should get the messag.
-
-More in depth explanations of the AeroGear related parameters can be
-found in the [AeroGear Push docs](http://aerogear.org/push/)
-
-## How to send a message for AeroGear
-
-To send a message intended for AeroGear simply send a JMS Message and
-set the appropriate headers, like so
-
-``` java
-Message message = session.createMessage();
-
-message.setStringProperty("AEROGEAR_ALERT", "Hello this is a notification from ActiveMQ");
-
-producer.send(message);
-```
-
-
-The 'AEROGEAR_ALERT' property will be the alert sent to the mobile
-device.
-
-> **Note**
->
-> If the message does not contain this property then it will be simply
-> ignored and left on the queue
-
-Its also possible to override any of the other AeroGear parameters by
-simply setting them on the message, for instance if you wanted to set
-ttl of a message you would:
-
-``` java
-message.setIntProperty("AEROGEAR_TTL", 1234);
-```
-
-
-or if you wanted to set the list of variants you would use:
-
-``` java
-message.setStringProperty("AEROGEAR_VARIANTS", "variant1,variant2,variant3");
-```
-```
-
-Again refer to the AeroGear documentation for a more in depth view on
-how to use these settings

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/aerogear/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/aerogear/pom.xml b/examples/features/sub-modules/aerogear/pom.xml
deleted file mode 100644
index 8c92feb..0000000
--- a/examples/features/sub-modules/aerogear/pom.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version='1.0'?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-   <modelVersion>4.0.0</modelVersion>
-
-   <parent>
-      <groupId>org.apache.activemq.examples.modules</groupId>
-      <artifactId>broker-modules</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-   </parent>
-
-   <properties>
-      <endpoint />
-      <applicationid />
-      <mastersecret />
-      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
-   </properties>
-
-   <artifactId>aerogear</artifactId>
-   <packaging>jar</packaging>
-   <name>ActiveMQ Artemis JMS AeroGear Example</name>
-
-   <dependencies>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-cli</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-   </dependencies>
-
-   <build>
-      <plugins>
-         <plugin>
-            <groupId>org.apache.activemq</groupId>
-            <artifactId>artemis-maven-plugin</artifactId>
-            <executions>
-               <execution>
-                  <id>create</id>
-                  <goals>
-                     <goal>create</goal>
-                  </goals>
-                  <configuration>
-                     <ignore>${noServer}</ignore>
-                     <!-- this list was extracted from mvn dependency:tree on integration/aerogear -->
-                     <libListWithDeps>
-                        <param>org.apache.activemq:artemis-aerogear-integration:${project.version}</param>
-                     </libListWithDeps>
-                  </configuration>
-               </execution>
-               <execution>
-                  <id>start</id>
-                  <goals>
-                     <goal>cli</goal>
-                  </goals>
-                  <configuration>
-                     <ignore>${noServer}</ignore>
-                     <spawn>true</spawn>
-                     <testURI>tcp://localhost:61616</testURI>
-                     <args>
-                        <param>run</param>
-                     </args>
-                  </configuration>
-               </execution>
-               <execution>
-                  <id>runClient</id>
-                  <goals>
-                     <goal>runClient</goal>
-                  </goals>
-                  <configuration>
-                     <clientClass>org.apache.activemq.artemis.jms.example.AerogearExample</clientClass>
-                  </configuration>
-               </execution>
-               <execution>
-                  <id>stop</id>
-                  <goals>
-                     <goal>cli</goal>
-                  </goals>
-                  <configuration>
-                     <ignore>${noServer}</ignore>
-                     <args>
-                        <param>stop</param>
-                     </args>
-                  </configuration>
-               </execution>
-            </executions>
-            <dependencies>
-               <dependency>
-                  <groupId>org.apache.activemq.examples.modules</groupId>
-                  <artifactId>aerogear</artifactId>
-                  <version>${project.version}</version>
-               </dependency>
-            </dependencies>
-         </plugin>
-      </plugins>
-   </build>
-
-</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/aerogear/readme.html
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/aerogear/readme.html b/examples/features/sub-modules/aerogear/readme.html
deleted file mode 100644
index 4d0c964..0000000
--- a/examples/features/sub-modules/aerogear/readme.html
+++ /dev/null
@@ -1,157 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<html>
-  <head>
-    <title>ActiveMQ Artemis JMS AeroGear Example</title>
-    <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
-    <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
-    <script type="text/javascript" src="../../../common/prettify.js"></script>
-  </head>
-  <body onload="prettyPrint()">
-     <h1>JMS AeroGear Example</h1>
-
-
-     <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
-
-     <p>This example shows how you can send a message to a mobile device by leveraging <a href="http://aerogear.org/push/">AeroGears push</a> technology which
-         provides support for different push notification technologies like Google Cloud Messaging, Apple's APNs or
-         Mozilla's SimplePush.</p>
-
-     <p>For this example you will need an AeroGear Application running somewhere, a good way to do this is to deploy the
-        Push Application on <href a="">openshift</href>, you can follow the AeroGear Push 0.X Quickstart.</p>
-
-     <p>Once you have created your AeroGear Push Application you can create a mobile application. Simply log into the application
-     on the web and create a new mobile application by clicking the 'create' button. Once created you will see an application id
-     and a master secret, you will need the later to run the example.</p>
-
-     <p>lastly you will need to create a variant. For this example we will be using Android so you will need to create a google project,
-     this <a href="http://aerogear.org/docs/guides/aerogear-push-android/google-setup/">article</a> explains how to do this.
-     Once created click on your app then click 'add' to add a variant. choose 'google cloud messaging', enter your google
-         API key and the project number from your google project and click create</p>
-
-     <p>Now before we run the example we need a mobile application to receive it. Writing a mobile app is beyond the scope
-     of this example but for testing purposes we have supplied an Android app you can use, simply install on your android phone.
-     It can be found <a href="http://downloads.jboss.org/hornetq/HornetQAeroGear.apk">here</a>. For a more in depth mobile
-         app example visit the AeroGear site.</p>
-
-     <p>Once you have installed the mobile app you will need to configure the following:</p>
-     <p>AeroGear Unified Push URL : This is the URL where your aerogear server is running, something like http://myapp-mydomain.rhcloud.com
-        AeroGear Variant ID : This is the ID of the variant you created in AeroGear
-        AeroGear Variant Secret : This is the secret for your variant
-        GCM Sender ID : this is the Google project Number you created on Google
-        Variant : you can use this to target messages if needed.
-     </p>
-
-     <p>Once you set all these correctly you should get a message saying your mobile app is registered, if you log into
-         your AeroGear app you should see it registered with the variant.</p>
-
-
-     <p>Now to run the example simply run the following command
-         'mvn -Dendpoint=my aerogear url -Dapplicationid=my application id -Dmastersecret=my master secret -Djsse.enableSNIExtension=false clean verify'.
-     If you arent using java 7 you can omit the 'jsse.enableSNIExtension=false'</p>
-
-   <p>You should see something like this in your ActiveMQServer</p>
-     <ol>
-        <pre class="prettyprint">
-           <code>
-   Dec 04, 2013 3:25:39 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload
-   INFO: HTTP Response code from UnifiedPush Server: 302
-   Dec 04, 2013 3:25:39 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload
-   INFO: Performing redirect to 'https://myapp-mydomain.rhcloud.com/rest/sender/'
-   Dec 04, 2013 3:25:40 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload
-   INFO: HTTP Response code from UnifiedPush Server: 200
-           </code>
-        </pre>
-     </ol>
-   <p>And on your mobile app you should see a message from ActiveMQ</p>
-
-  <p>Now lets look a bit more closely at the configuration in broker.xml</p>
-     <ol>
-        <pre class="prettyprint">
-           <code>
-   &lt;queues>
-       &lt;queue name="jms.queue.exampleQueue">
-           &lt;address>jms.queue.exampleQueue&lt;/address>
-       &lt;/queue>
-   &lt;/queues>
-
-   &lt;connector-services>
-       &lt;connector-service name="aerogear-connector">
-           &lt;factory-class>org.apache.activemq.integration.aerogear.AeroGearConnectorServiceFactory&lt;/factory-class>
-           &lt;param key="endpoint" value="${endpoint}"/>
-           &lt;param key="queue" value="jms.queue.exampleQueue"/>
-           &lt;param key="application-id" value="${applicationid}"/>
-           &lt;param key="master-secret" value="${mastersecret}"/>
-       &lt;/connector-service>
-   &lt;/connector-services>
-           </code>
-        </pre>
-     </ol>
-  <p>Firstly you will see that we have to create a core queue so it is available when the connector is started, the following are mandatory parameters:</p>
-  <ol>
-      <li>endpoint - The endpoint or URL of you AeroGear application</li>
-      <li>queue - The name of the queue to consume from</li>
-      <li>application-id - The application id of your mobile application in AeroGear</li>
-      <li>master-secret - the secret of your mobile application in AeroGear</li>
-  </ol>
-  <p>as well as those there are also the following optional parameters</p>
-  <ol>
-      <li>ttl - The time to live for the message once AeroGear receives it</li>
-      <li>badge - The badge the mobile app should use for the notification</li>
-      <li>sound - The sound the mobile app should use for the notification</li>
-      <li>filter - A message filter(selector) to use on the connector</li>
-      <li>retry-interval - If an error occurs on send, how long before we try again</li>
-      <li>retry-attempts - How many times we should try to reconnect after an error</li>
-      <li>variants - A comma separated list of variants that should get the message</li>
-      <li>aliases - A list of aliases that should get the message</li>
-      <li>device-types - A list of device types that should get the message</li>
-  </ol>
-  <p>More in depth explanations of these can be found in the AeroGear docs.</p>
-  <p>Now lets look at a snippet of code we used to send the message for our JMS client</p>
-  <pre class="prettyprint">
-      <code>
-  Queue queue = (Queue)initialContext.lookup("queue/exampleQueue");
-
-  // Step 3. Perform a lookup on the Connection Factory
-  ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
-
-  // Step 4.Create a JMS Connection
-  connection = cf.createConnection();
-
-  // Step 5. Create a JMS Session
-  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-  // Step 6. Create a JMS Message Producer
-  MessageProducer producer = session.createProducer(queue);
-
-  // Step 7. Create a Text Message
-  Message message = session.createMessage();
-
-  message.setStringProperty("AEROGEAR_ALERT", "Hello this is a notification from ActiveMQ");
-
-  producer.send(message);
-      </code>
-  </pre>
-  <p> The most important thing here is string propert we have set on the message, i.e. 'AEROGEAR_ALERT'. This is the
-      actual alert that is sent via AeroGear</p>
-  <p>As well as the alert itself you can override any of the above optional parameters in the same fashionby using the
-      following propert names: AEROGEAR_SOUND,AEROGEAR_BADGE,AEROGEAR_TTL,AEROGEAR_VARIANTS,AEROGEAR_ALIASES and AEROGEAR_DEVICE_TYPES</p>
-  </body>
-</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java b/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java
deleted file mode 100644
index 7d1a662..0000000
--- a/examples/features/sub-modules/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-
-/**
- * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
- */
-public class AerogearExample {
-
-   public static void main(final String[] args) throws Exception {
-      Connection connection = null;
-      InitialContext initialContext = null;
-      try {
-         // Step 1. Create an initial context to perform the JNDI lookup.
-         initialContext = new InitialContext();
-
-         // Step 2. Perfom a lookup on the queue
-         Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
-         // Step 3. Perform a lookup on the Connection Factory
-         ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
-
-         // Step 4.Create a JMS Connection
-         connection = cf.createConnection();
-
-         // Step 5. Create a JMS Session
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         // Step 6. Create a JMS Message Producer
-         MessageProducer producer = session.createProducer(queue);
-
-         // Step 7. Create a Text Message
-         Message message = session.createMessage();
-
-         message.setStringProperty("AEROGEAR_ALERT", "Hello this is a notification from ActiveMQ");
-
-         producer.send(message);
-
-         System.out.println("Sent message");
-
-         System.out.println("now check your mobile app and press enter");
-
-         System.in.read();
-      } finally {
-         // Step 12. Be sure to close our JMS resources!
-         if (initialContext != null) {
-            initialContext.close();
-         }
-         if (connection != null) {
-            connection.close();
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/aerogear/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/aerogear/src/main/resources/activemq/server0/broker.xml b/examples/features/sub-modules/aerogear/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index 039e3c9..0000000
--- a/examples/features/sub-modules/aerogear/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
---><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
-
-   
-
-   <core xmlns="urn:activemq:core">
-
-      <bindings-directory>./data/bindings</bindings-directory>
-
-      <journal-directory>./data/journal</journal-directory>
-
-      <large-messages-directory>./data/largemessages</large-messages-directory>
-
-      <paging-directory>./data/paging</paging-directory>
-
-      <!-- Acceptors -->
-      <acceptors>
-         <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
-      </acceptors>
-
-      <!-- We need to create a core queue for the JMS queue explicitly because the connector will be deployed
-       before the JMS queue is deployed, so the first time, it otherwise won't find the queue -->
-      
-
-      <connector-services>
-         <connector-service name="aerogear-connector">
-            <factory-class>org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory</factory-class>
-            <param key="endpoint" value="${endpoint}"/>
-            <param key="queue" value="exampleQueue"/>
-            <param key="application-id" value="${applicationid}"/>
-            <param key="master-secret" value="${mastersecret}"/>
-         </connector-service>
-      </connector-services>
-
-      <!-- Other config -->
-
-      <security-settings>
-         <!--security for example queue-->
-         <security-setting match="exampleQueue">
-            <permission roles="guest" type="createDurableQueue"/>
-            <permission roles="guest" type="deleteDurableQueue"/>
-            <permission roles="guest" type="createNonDurableQueue"/>
-            <permission roles="guest" type="deleteNonDurableQueue"/>
-            <permission roles="guest" type="consume"/>
-            <permission roles="guest" type="send"/>
-         </security-setting>
-      </security-settings>
-   <addresses>
-         <address name="exampleQueue">
-            <multicast>
-               <queue name="exampleQueue"/>
-            </multicast>
-            <anycast>
-               <queue name="jms.queue.exampleQueue"/>
-            </anycast>
-         </address>
-      </addresses>
-   </core>
-</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/aerogear/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/aerogear/src/main/resources/jndi.properties b/examples/features/sub-modules/aerogear/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/features/sub-modules/aerogear/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/features/sub-modules/pom.xml
----------------------------------------------------------------------
diff --git a/examples/features/sub-modules/pom.xml b/examples/features/sub-modules/pom.xml
index ef47365..dbbd36a 100644
--- a/examples/features/sub-modules/pom.xml
+++ b/examples/features/sub-modules/pom.xml
@@ -49,7 +49,6 @@ under the License.
       <profile>
          <id>release</id>
          <modules>
-            <module>aerogear</module>
             <module>artemis-ra-rar</module>
          </modules>
       </profile>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.css
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.css b/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.css
deleted file mode 100644
index 1a75b9f..0000000
--- a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.css
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-* {
-    margin: 0;
-    padding: 0;
-}
-
-body {
-    font-family: 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif;
-    padding: 10px;
-}
-
-#disconnect {
-    display: none;
-}
-
-#unsubscribe {
-    display: none;
-}
-
-#subscribe {
-    display: none;
-}
-
-#debug {
-    background-color: #F0F0F0;
-    font-size: 12px;
-    height: 75%;
-    overflow: auto;
-    padding: 10px;
-    position: absolute;
-    right: 10px;
-    top: 10px;
-    width: 250px;
-    z-index: 100;
-}
-
-#send_form {
-    bottom: 5px;
-    position: absolute;
-    width: 99%;
-}
-
-#send_form #send_form_input {
-    border: 1px solid #CCC;
-    font-size: 16px;
-    height: 20px;
-    padding: 5px;
-    width: 98%;
-}
-
-#send_form input[disabled] {
-    background-color: #EEE;
-}
-
-#messages {
-    bottom: 25px;
-    left: 0;
-    overflow: auto;
-    padding: 5px;
-    right: 0;
-    top: 2em;
-    z-index: -1;
-}
-
-.message {
-    width: 95%;
-}
-
-form dt {
-    clear:both;
-    width:19%;
-    float:left;
-    text-align:right;
-}
-
-form dd {
-    float:left;
-    width:80%;
-    margin:0 0 0.5em 0.25em;
-}
-
-input {
-    width: 320px;
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.js
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.js b/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.js
deleted file mode 100644
index a4fe2e8..0000000
--- a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-chat.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-$( document ).ready( function () {
-
-    var client,
-        destination;
-
-    $( '#connect_form' ).submit( function ( e ) {
-
-        e.preventDefault();
-
-        var url = $( '#connect_url' ).val(),
-            loginName = $( '#connect_login' ).val(),
-            passcode = $( '#connect_passcode' ).val();
-        
-        destination = $( '#destination' ).val();
-
-        client = AeroGear.Notifier({
-            name: 'stomp',
-            type: 'stompws',
-            settings: {
-                connectURL: url
-            }
-        }).clients.stomp;
-
-        var debug = function ( str ) {
-                $( '#debug' ).append( str + "\n" );
-            },
-            onconnect = function () {
-                debug( 'connected to Stomp');
-                $( '#connect' ).fadeOut({
-                    duration: 'fast'
-                });
-                $( '#disconnect' ).fadeIn();
-                $( '#send_form_input' ).removeAttr( 'disabled' );
-                $( '#unsubscribe' ).fadeIn();
-
-                client.debug( debug );
-            
-                var onsubscribe = function ( message ) {
-                    $( '#messages' ).append( "<p>" + message.body + "</p>\n" );
-                };
-            
-                client.subscribe({
-                    address: destination,
-                    callback: onsubscribe
-                });
-            };
-
-        client.connect({
-            login: loginName,
-            password: passcode,
-            onConnect: onconnect
-        });
-    });
-
-    $( '#disconnect_form' ).submit( function ( e ) {
-        
-        e.preventDefault();
-
-        var ondisconnect = function () {
-            $( '#disconnect' ).fadeOut({
-                duration: 'fast'
-            });
-            $( '#unsubscribe' ).fadeOut({
-                duration: 'fast'
-            });
-            $( '#connect' ).fadeIn();
-            $( '#send_form_input' ).attr( 'disabled', 'disabled' );
-            $( '#messages' ).empty();
-            $( '#debug' ).empty();
-        };
-            
-        client.disconnect( ondisconnect );
-    });
-    
-    $( '#unsubscribe_form' ).submit( function ( e ) {
-
-        e.preventDefault();
-
-        client.unsubscribe( [{ address: destination }] );
-        
-        $( '#unsubscribe' ).fadeOut({
-            duration: 'fast'
-        });
-    });
-
-    $( '#send_form' ).submit( function ( e ) {
-        
-        e.preventDefault();
-
-        var text = $( '#send_form_input' ).val();
-        if (text) {
-            client.send( destination, text );
-            $('#send_form_input').val( '' );
-        }
-    });
-
-});

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-index.html
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-index.html b/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-index.html
deleted file mode 100644
index 434be6b..0000000
--- a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear-index.html
+++ /dev/null
@@ -1,97 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<!DOCTYPE html>
-<html>
-
-<head>
-    <title>Chat Example Using Stomp Over Web Sockets</title>
-    <link rel="stylesheet" href="aerogear-chat.css" />
-    <script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
-    <script src='stomp.js'></script>
-    <script src='aerogear.min.js'></script>
-    <script src='aerogear-chat.js'></script>
-    <script>
-        $(document).ready(function() {
-            var supported = ("WebSocket" in window);
-            if(!supported) {
-                var msg = "Your browser does not support Web Sockets. This example will not work properly.<br>";
-                msg += "Please use a Web Browser with Web Sockets support (WebKit or Google Chrome).";
-                $("#connect").html(msg);
-            }
-        });
-    </script>
-</head>
-<body>
-
-    <div id='connect'>
-        <form id='connect_form'>
-            <dl>
-                <dt>
-                    <label for=connect_url>Server URL</label>
-                </dt>
-                <dd>
-                    <input name=url id='connect_url' value='ws://localhost:61614/stomp'>
-                </dd>
-                <dt>
-                    <label for=connect_login>Login</label>
-                </dt>
-                <dd>
-                    <input id='connect_login' placeholder="User Login" value="guest">
-                </dd>
-                <dt>
-                    <label for=connect_passcode>Password</label>
-                </dt>
-                <dd>
-                    <input id='connect_passcode' type=password placeholder="User Password" value="guest">
-                </dd>
-                <dt>
-                    <label for=destination>Destination</label>
-                </dt>
-                <dd>
-                    <input id='destination' placeholder="Destination" value="jms.topic.chat">
-                </dd>
-                <dt>&nbsp;</dt>
-                <dd>
-                    <input type="submit" id='connect_submit' value="Connect">
-                </dd>
-            </dl>
-        </form>
-
-        <p>Use the form above to connect to the Stomp server and subscribe to the destination.</p>
-        <p>Once connected, you can send messages to the destination with the text field at the bottom of this page</p>
-    </div>
-    <div id="disconnect">
-        <form id='disconnect_form'>
-            <input type="submit" id='disconnect_submit' value="Disconnect">
-        </form>
-    </div>
-    <div id="unsubscribe">
-        <form id='unsubscribe_form'>
-            <input type="submit" id='unsubscribe_submit' value="Unsubscribe">
-        </form>
-    </div>
-    <pre id="debug"></pre>
-    <div id="messages"></div>
-    <form id='send_form'>
-        <input id='send_form_input' placeholder="Type your message here" disabled />
-    </form>
-</body>
-</html>
-


[12/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
index 622f042..4da2e63 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.activemq.artemis.core.server.impl;
 
-import java.io.InputStream;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -31,27 +30,30 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.Message;
+
+import org.apache.activemq.artemis.api.core.RefCountMessage;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.encode.BodyType;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.core.paging.PagingStore;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.server.Consumer;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.apache.activemq.artemis.utils.ReferenceCounter;
-import org.apache.activemq.artemis.utils.TypedProperties;
 import org.apache.activemq.artemis.utils.UUID;
 import org.junit.Assert;
 import org.junit.Test;
@@ -283,110 +285,91 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
    }
 
-   class FakeMessage implements ServerMessage {
+   class FakeMessage extends RefCountMessage {
 
-      final long id;
+      @Override
+      public void persist(ActiveMQBuffer targetRecord) {
 
-      FakeMessage(final long id) {
-         this.id = id;
       }
 
       @Override
-      public FakeMessage setMessageID(long id) {
-         return this;
-      }
+      public void reloadPersistence(ActiveMQBuffer record) {
 
-      @Override
-      public long getMessageID() {
-         return id;
       }
 
       @Override
-      public MessageReference createReference(Queue queue) {
+      public Persister<Message> getPersister() {
          return null;
       }
 
       @Override
-      public void forceAddress(SimpleString address) {
-
-      }
-
-      @Override
-      public int incrementRefCount() throws Exception {
+      public int getPersistSize() {
          return 0;
       }
+      final long id;
 
       @Override
-      public int decrementRefCount() throws Exception {
-         return 0;
+      public Message toCore() {
+         return this;
       }
 
       @Override
-      public int incrementDurableRefCount() {
-         return 0;
+      public ActiveMQBuffer getReadOnlyBodyBuffer() {
+         return null;
       }
 
-      @Override
-      public int decrementDurableRefCount() {
-         return 0;
+      FakeMessage(final long id) {
+         this.id = id;
       }
 
       @Override
-      public ServerMessage copy(long newID) {
-         return null;
+      public FakeMessage setMessageID(long id) {
+         return this;
       }
 
       @Override
-      public ServerMessage copy() {
-         return null;
+      public long getMessageID() {
+         return id;
       }
 
       @Override
-      public int getMemoryEstimate() {
+      public int incrementRefCount() throws Exception {
          return 0;
       }
 
       @Override
-      public int getRefCount() {
+      public int decrementRefCount() throws Exception {
          return 0;
       }
 
       @Override
-      public ServerMessage makeCopyForExpiryOrDLA(long newID,
-                                                  MessageReference originalReference,
-                                                  boolean expiry,
-                                                  boolean copyOriginalHeaders) throws Exception {
-         return null;
-      }
-
-      @Override
-      public void setOriginalHeaders(ServerMessage other, MessageReference originalReference, boolean expiry) {
-
+      public int incrementDurableRefCount() {
+         return 0;
       }
 
       @Override
-      public void setPagingStore(PagingStore store) {
-
+      public int decrementDurableRefCount() {
+         return 0;
       }
 
       @Override
-      public PagingStore getPagingStore() {
+      public Message copy(long newID) {
          return null;
       }
 
       @Override
-      public boolean hasInternalProperties() {
-         return false;
+      public Message copy() {
+         return null;
       }
 
       @Override
-      public boolean storeIsPaging() {
-         return false;
+      public int getMemoryEstimate() {
+         return 0;
       }
 
       @Override
-      public void encodeMessageIDToBuffer() {
-
+      public int getRefCount() {
+         return 0;
       }
 
       @Override
@@ -400,97 +383,66 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
-      public void encode(ActiveMQBuffer buffer) {
+      public void messageChanged() {
 
       }
-
       @Override
-      public void decode(ActiveMQBuffer buffer) {
-
-      }
-
-      @Override
-      public void decodeFromBuffer(ActiveMQBuffer buffer) {
-
-      }
-
-      @Override
-      public int getEndOfMessagePosition() {
-         return 0;
-      }
-
-      @Override
-      public int getEndOfBodyPosition() {
-         return 0;
-      }
-
-      @Override
-      public void bodyChanged() {
-
-      }
-
-      @Override
-      public boolean isServerMessage() {
-         return false;
-      }
-
-      @Override
-      public ActiveMQBuffer getEncodedBuffer() {
+      public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
          return null;
       }
 
       @Override
-      public int getHeadersAndPropertiesEncodeSize() {
-         return 0;
+      public UUID getUserID() {
+         return null;
       }
 
       @Override
-      public ActiveMQBuffer getWholeBuffer() {
+      public String getAddress() {
          return null;
       }
 
       @Override
-      public void encodeHeadersAndProperties(ActiveMQBuffer buffer) {
-
+      public SimpleString getAddressSimpleString() {
+         return null;
       }
 
       @Override
-      public void decodeHeadersAndProperties(ActiveMQBuffer buffer) {
-
+      public Message setBuffer(ByteBuf buffer) {
+         return null;
       }
 
       @Override
-      public BodyEncoder getBodyEncoder() throws ActiveMQException {
+      public ByteBuf getBuffer() {
          return null;
       }
 
       @Override
-      public InputStream getBodyInputStream() {
+      public Object getProtocol() {
          return null;
       }
 
       @Override
-      public void setAddressTransient(SimpleString address) {
-
+      public Message setProtocol(Object protocol) {
+         return null;
       }
 
       @Override
-      public TypedProperties getTypedProperties() {
+      public Object getBody() {
          return null;
       }
 
       @Override
-      public UUID getUserID() {
+      public BodyType getBodyType() {
          return null;
       }
 
       @Override
-      public FakeMessage setUserID(UUID userID) {
-         return this;
+      public Message setBody(BodyType type, Object body) {
+         return null;
       }
 
       @Override
-      public SimpleString getAddress() {
+      public Message setAddress(String address) {
          return null;
       }
 
@@ -565,11 +517,6 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
-      public ActiveMQBuffer getBodyBufferDuplicate() {
-         return null;
-      }
-
-      @Override
       public Message putBooleanProperty(SimpleString key, boolean value) {
          return null;
       }
@@ -825,13 +772,28 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
-      public FakeMessage writeBodyBufferBytes(byte[] bytes) {
-         return this;
+      public Message setUserID(Object userID) {
+         return null;
       }
 
       @Override
-      public FakeMessage writeBodyBufferString(String string) {
-         return this;
+      public void copyHeadersAndProperties(Message msg) {
+
+      }
+
+      @Override
+      public Message setType(byte type) {
+         return null;
+      }
+
+      @Override
+      public void receiveBuffer(ByteBuf buffer) {
+
+      }
+
+      @Override
+      public void sendBuffer(ByteBuf buffer, int count) {
+
       }
    }
 
@@ -1221,7 +1183,7 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
-      public boolean hasMatchingConsumer(ServerMessage message) {
+      public boolean hasMatchingConsumer(Message message) {
          return false;
       }
 
@@ -1338,12 +1300,12 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
-      public void route(ServerMessage message, RoutingContext context) throws Exception {
+      public void route(Message message, RoutingContext context) throws Exception {
 
       }
 
       @Override
-      public void routeWithAck(ServerMessage message, RoutingContext context) {
+      public void routeWithAck(Message message, RoutingContext context) {
 
       }
 
@@ -1366,5 +1328,9 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       public void decDelivering(int size) {
 
       }
+
+
+
+
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java
index ee80054..b1ea206 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImplTest.java
@@ -26,13 +26,13 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
@@ -53,7 +53,6 @@ import org.apache.activemq.artemis.core.replication.ReplicationManager;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 import org.apache.activemq.artemis.core.server.group.impl.GroupBinding;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
@@ -323,7 +322,7 @@ public class TransactionImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void storeMessage(ServerMessage message) throws Exception {
+      public void storeMessage(Message message) throws Exception {
 
       }
 
@@ -368,7 +367,7 @@ public class TransactionImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void storeMessageTransactional(long txID, ServerMessage message) throws Exception {
+      public void storeMessageTransactional(long txID, Message message) throws Exception {
 
       }
 
@@ -439,7 +438,7 @@ public class TransactionImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public LargeServerMessage createLargeMessage(long id, MessageInternal message) throws Exception {
+      public LargeServerMessage createLargeMessage(long id, Message message) throws Exception {
          return null;
       }
 
@@ -489,11 +488,6 @@ public class TransactionImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void updatePageTransaction(PageTransactionInfo pageTransaction, int depage) throws Exception {
-
-      }
-
-      @Override
       public void deletePageTransactional(long recordID) throws Exception {
 
       }
@@ -643,7 +637,7 @@ public class TransactionImplTest extends ActiveMQTestBase {
 
       @Override
       public boolean addToPage(PagingStore store,
-                               ServerMessage msg,
+                               Message msg,
                                Transaction tx,
                                RouteContextList listCtx) throws Exception {
          return false;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index 2f12b05..aa64d9f 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -94,6 +94,7 @@ import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
 import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.postoffice.Binding;
@@ -117,14 +118,12 @@ import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
 import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.core.server.impl.Activation;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
@@ -855,7 +854,7 @@ public abstract class ActiveMQTestBase extends Assert {
       return testDir1 + "/journal";
    }
 
-   protected String getJournalDir(final int index, final boolean backup) {
+   public String getJournalDir(final int index, final boolean backup) {
       return getJournalDir(getTestDir(), index, backup);
    }
 
@@ -2079,8 +2078,8 @@ public abstract class ActiveMQTestBase extends Assert {
       }
    }
 
-   protected ServerMessage generateMessage(final long id) {
-      ServerMessage message = new ServerMessageImpl(id, 1000);
+   protected Message generateMessage(final long id) {
+      Message message = new CoreMessage(id, 1000);
 
       message.setMessageID(id);
 
@@ -2092,9 +2091,9 @@ public abstract class ActiveMQTestBase extends Assert {
    }
 
    protected MessageReference generateReference(final Queue queue, final long id) {
-      ServerMessage message = generateMessage(id);
+      Message message = generateMessage(id);
 
-      return message.createReference(queue);
+      return MessageReference.Factory.createReference(message, queue);
    }
 
    protected int calculateRecordSize(final int size, final int alignment) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 9ed5584..0691e95 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -231,8 +231,6 @@
       <journal-compact-percentage>33</journal-compact-percentage>
       <journal-compact-min-files>123</journal-compact-min-files>
       <journal-max-io>56546</journal-max-io>
-      <perf-blast-pages>5</perf-blast-pages>
-      <run-sync-speed-test>true</run-sync-speed-test>
       <server-dump-interval>5000</server-dump-interval>
       <memory-warning-threshold>95</memory-warning-threshold>
       <memory-measure-interval>54321</memory-measure-interval>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-tools/src/test/resources/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-tools/src/test/resources/artemis-configuration.xsd b/artemis-tools/src/test/resources/artemis-configuration.xsd
index fcb7a20..090f968 100644
--- a/artemis-tools/src/test/resources/artemis-configuration.xsd
+++ b/artemis-tools/src/test/resources/artemis-configuration.xsd
@@ -673,22 +673,6 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="perf-blast-pages" type="xsd:int" default="-1" maxOccurs="1" minOccurs="0">
-            <xsd:annotation>
-               <xsd:documentation>
-                  XXX Only meant to be used by project developers
-               </xsd:documentation>
-            </xsd:annotation>
-         </xsd:element>
-
-         <xsd:element name="run-sync-speed-test" type="xsd:boolean" default="false" maxOccurs="1" minOccurs="0">
-            <xsd:annotation>
-               <xsd:documentation>
-                  XXX Only meant to be used by project developers
-               </xsd:documentation>
-            </xsd:annotation>
-         </xsd:element>
-
          <xsd:element name="server-dump-interval" type="xsd:long" default="-1" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
index d7a7bdc..91fe808 100644
--- a/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
+++ b/examples/features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
@@ -17,7 +17,7 @@
 package org.apache.activemq.artemis.jms.example;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 
 public class HatColourChangeTransformer implements Transformer {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
----------------------------------------------------------------------
diff --git a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
index 22272d0..32035e7 100644
--- a/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
+++ b/examples/features/standard/divert/src/main/java/org/apache/activemq/artemis/jms/example/AddForwardingTimeTransformer.java
@@ -17,7 +17,7 @@
 package org.apache.activemq.artemis.jms.example;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 
 public class AddForwardingTimeTransformer implements Transformer {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5b056ad..7388068 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,7 +83,7 @@
       <jgroups.version>3.6.9.Final</jgroups.version>
       <maven.assembly.plugin.version>2.4</maven.assembly.plugin.version>
       <netty.version>4.1.5.Final</netty.version>
-      <proton.version>0.16.0</proton.version>
+      <proton.version>0.17.0</proton.version>
       <resteasy.version>3.0.19.Final</resteasy.version>
       <slf4j.version>1.7.21</slf4j.version>
       <qpid.jms.version>0.11.0</qpid.jms.version>
@@ -1006,6 +1006,7 @@
                     <arg>-Xep:StaticAccessedFromInstance:ERROR</arg>
                     <arg>-Xep:SynchronizeOnNonFinalField:ERROR</arg>
                     <arg>-Xep:WaitNotInLoop:ERROR</arg>
+                    <arg>-Xdiags:verbose</arg>
                  </compilerArgs>
                </configuration>
                <dependencies>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
index dea8602..d7d7f9d 100644
--- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/UnmodifiableDelivery.java
@@ -52,6 +52,11 @@ public class UnmodifiableDelivery implements Delivery {
    }
 
    @Override
+   public int getDataLength() {
+      return delivery.getDataLength();
+   }
+
+   @Override
    public DeliveryState getLocalState() {
       return delivery.getLocalState();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/EncodersBench.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/EncodersBench.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/EncodersBench.java
index 833302d..162a512 100644
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/EncodersBench.java
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/benchmarks/journal/gcfree/EncodersBench.java
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
 import io.netty.buffer.Unpooled;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
+import org.apache.activemq.artemis.core.journal.EncoderPersister;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord;
@@ -61,7 +62,7 @@ public class EncodersBench {
       this.byteBuffer.order(ByteOrder.nativeOrder());
       this.addJournalRecordEncoder = new AddJournalRecordEncoder();
 
-      this.record = new JournalAddRecord(true, 1, (byte) 1, ZeroEncodingSupport.Instance);
+      this.record = new JournalAddRecord(true, 1, (byte) 1, EncoderPersister.getInstance(), ZeroEncodingSupport.Instance);
       this.record.setFileID(1);
       this.record.setCompactCount((short) 1);
       this.outBuffer = new ChannelBufferWrapper(Unpooled.directBuffer(this.record.getEncodeSize(), this.record.getEncodeSize()).order(ByteOrder.nativeOrder()));
@@ -86,7 +87,7 @@ public class EncodersBench {
    @Benchmark
    public int encodeUnalignedWithGarbage() {
       outBuffer.clear();
-      final JournalAddRecord addRecord = new JournalAddRecord(true, 1, (byte) 1, ZeroEncodingSupport.Instance);
+      final JournalAddRecord addRecord = new JournalAddRecord(true, 1, (byte) 1, EncoderPersister.getInstance(), ZeroEncodingSupport.Instance);
       addRecord.setFileID(1);
       addRecord.setCompactCount((short) 1);
       addRecord.encode(outBuffer);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java
index ef71e89..03e2ddc 100644
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/JMSBridgeReconnectionTest.java
@@ -19,8 +19,8 @@ package org.apache.activemq.artemis.tests.extras.byteman;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.client.impl.ClientProducerCredits;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
@@ -111,7 +111,7 @@ public class JMSBridgeReconnectionTest extends BridgeTestBase {
    static int count = 20;
    static CountDownLatch stopLatch = new CountDownLatch(1);
 
-   public static void pause2(MessageInternal msgI, boolean sendBlocking, final ClientProducerCredits theCredits) {
+   public static void pause2(Message msgI, boolean sendBlocking, final ClientProducerCredits theCredits) {
       if (msgI.containsProperty("__AMQ_CID")) {
          count--;
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java
deleted file mode 100644
index 1ff58cd..0000000
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/MessageCopyTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.tests.extras.byteman;
-
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
-import org.apache.activemq.artemis.utils.RandomUtil;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class MessageCopyTest {
-
-   @Test
-   @BMRules(
-
-      rules = {@BMRule(
-         name = "message-copy0",
-         targetClass = "org.apache.activemq.artemis.core.server.impl.ServerMessageImpl",
-         targetMethod = "copy()",
-         targetLocation = "ENTRY",
-         action = "System.out.println(\"copy\"), waitFor(\"encode-done\")"), @BMRule(
-         name = "message-copy-done",
-         targetClass = "org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage",
-         targetMethod = "encode(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)",
-         targetLocation = "EXIT",
-         action = "System.out.println(\"encodeDone\"), signalWake(\"encode-done\", true)"), @BMRule(
-         name = "message-copy1",
-         targetClass = "org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper",
-         targetMethod = "copy(int, int)",
-         condition = "Thread.currentThread().getName().equals(\"T1\")",
-         targetLocation = "EXIT",
-         action = "System.out.println(\"setIndex at \" + Thread.currentThread().getName()), waitFor(\"finish-read\")"), @BMRule(
-         name = "JMSServer.stop wait-init",
-         targetClass = "org.apache.activemq.artemis.tests.extras.byteman.MessageCopyTest",
-         targetMethod = "simulateRead",
-         targetLocation = "EXIT",
-         action = "signalWake(\"finish-read\", true)")})
-   public void testMessageCopyIssue() throws Exception {
-      final long RUNS = 1;
-      final ServerMessageImpl msg = new ServerMessageImpl(123, 18);
-
-      msg.setMessageID(RandomUtil.randomLong());
-      msg.encodeMessageIDToBuffer();
-      msg.setAddress(new SimpleString("Batatantkashf aksjfh aksfjh askfdjh askjfh "));
-
-      final AtomicInteger errors = new AtomicInteger(0);
-
-      int T1_number = 1;
-      int T2_number = 1;
-
-      final CountDownLatch latchAlign = new CountDownLatch(T1_number + T2_number);
-      final CountDownLatch latchReady = new CountDownLatch(1);
-      class T1 extends Thread {
-
-         T1() {
-            super("T1");
-         }
-
-         @Override
-         public void run() {
-            latchAlign.countDown();
-            try {
-               latchReady.await();
-            } catch (Exception ignored) {
-            }
-
-            for (int i = 0; i < RUNS; i++) {
-               try {
-                  ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy();
-               } catch (Throwable e) {
-                  e.printStackTrace();
-                  errors.incrementAndGet();
-               }
-            }
-         }
-      }
-
-      class T2 extends Thread {
-
-         T2() {
-            super("T2");
-         }
-
-         @Override
-         public void run() {
-            latchAlign.countDown();
-            try {
-               latchReady.await();
-            } catch (Exception ignored) {
-            }
-
-            for (int i = 0; i < RUNS; i++) {
-               try {
-                  SessionSendMessage ssm = new SessionSendMessage(msg);
-                  ActiveMQBuffer buf = ssm.encode(null);
-                  System.out.println("reading at buf = " + buf);
-                  simulateRead(buf);
-               } catch (Throwable e) {
-                  e.printStackTrace();
-                  errors.incrementAndGet();
-               }
-            }
-         }
-      }
-
-      ArrayList<Thread> threads = new ArrayList<>();
-
-      for (int i = 0; i < T1_number; i++) {
-         T1 t = new T1();
-         threads.add(t);
-         t.start();
-      }
-
-      for (int i = 0; i < T2_number; i++) {
-         T2 t2 = new T2();
-         threads.add(t2);
-         t2.start();
-      }
-
-      latchAlign.await();
-
-      latchReady.countDown();
-
-      for (Thread t : threads) {
-         t.join();
-      }
-
-      Assert.assertEquals(0, errors.get());
-   }
-
-   private void simulateRead(ActiveMQBuffer buf) {
-      buf.setIndex(buf.capacity() / 2, buf.capacity() / 2);
-
-      // ok this is not actually happening during the read process, but changing this shouldn't affect the buffer on copy
-      buf.writeBytes(new byte[1024]);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java
index 8456765..0860e97 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java
@@ -33,7 +33,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.config.Configuration;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
@@ -191,13 +191,13 @@ public class DuplicateDetectionTest extends ActiveMQTestBase {
          Assert.assertNull(message2);
 
          message = createMessage(session, 3);
-         message.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, dupID.getData());
+         message.putBytesProperty(Message.HDR_BRIDGE_DUPLICATE_ID, dupID.getData());
          producer.send(message);
          message2 = consumer.receive(1000);
          Assert.assertEquals(3, message2.getObjectProperty(propKey));
 
          message = createMessage(session, 4);
-         message.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, dupID.getData());
+         message.putBytesProperty(Message.HDR_BRIDGE_DUPLICATE_ID, dupID.getData());
          producer.send(message);
          message2 = consumer.receiveImmediate();
          Assert.assertNull(message2);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
index 7962005..aa1bdc4 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
@@ -224,6 +224,7 @@ public class ProtonTest extends ProtonTestBase {
 
          TextMessage message = session.createTextMessage("test-message");
          producer.send(message);
+
          producer.close();
 
          connection.start();
@@ -827,12 +828,7 @@ public class ProtonTest extends ProtonTestBase {
          AmqpReceiver receiver = session.createReceiver(coreAddress);
          server.destroyQueue(new SimpleString(coreAddress), null, false, true);
 
-         Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisfied() throws Exception {
-               return receiver.isClosed();
-            }
-         });
+         Wait.waitFor(receiver::isClosed);
          assertTrue(receiver.isClosed());
       } finally {
          amqpConnection.close();
@@ -851,12 +847,7 @@ public class ProtonTest extends ProtonTestBase {
             connection.disconnect(true);
          }
 
-         Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisfied() throws Exception {
-               return amqpConnection.isClosed();
-            }
-         });
+         Wait.waitFor(amqpConnection::isClosed);
 
          assertTrue(amqpConnection.isClosed());
          assertEquals(AmqpSupport.CONNECTION_FORCED, amqpConnection.getConnection().getRemoteCondition().getCondition());
@@ -1001,12 +992,7 @@ public class ProtonTest extends ProtonTestBase {
       final ActiveMQServer remote = createAMQPServer(5673);
       remote.start();
       try {
-         Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisfied() throws Exception {
-               return remote.isActive();
-            }
-         });
+         Wait.waitFor(remote::isActive);
       } catch (Exception e) {
          remote.stop();
          throw e;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java
index beac414..847b69e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AckBatchSizeTest.java
@@ -63,7 +63,8 @@ public class AckBatchSizeTest extends ActiveMQTestBase {
       ActiveMQServer server = createServer(false);
       server.start();
       int numMessages = 100;
-      ServerLocator locator = createInVMNonHALocator().setAckBatchSize(numMessages * getMessageEncodeSize(addressA)).setBlockOnAcknowledge(true);
+      int originalSize = getMessageEncodeSize(addressA);
+      ServerLocator locator = createInVMNonHALocator().setAckBatchSize(numMessages * originalSize).setBlockOnAcknowledge(true);
       ClientSessionFactory cf = createSessionFactory(locator);
       ClientSession sendSession = cf.createSession(false, true, true);
 
@@ -71,20 +72,25 @@ public class AckBatchSizeTest extends ActiveMQTestBase {
       session.createQueue(addressA, queueA, false);
       ClientProducer cp = sendSession.createProducer(addressA);
       for (int i = 0; i < numMessages; i++) {
-         cp.send(sendSession.createMessage(false));
+         ClientMessage message = (ClientMessage)sendSession.createMessage(false).setAddress(addressA);
+         Assert.assertEquals(originalSize, message.getEncodeSize());
+         cp.send(message);
+         Assert.assertEquals(originalSize, message.getEncodeSize());
       }
 
       ClientConsumer consumer = session.createConsumer(queueA);
       session.start();
       for (int i = 0; i < numMessages - 1; i++) {
+         System.out.println("Receive ");
          ClientMessage m = consumer.receive(5000);
-
+         Assert.assertEquals(0, m.getPropertyNames().size());
+         Assert.assertEquals("expected to be " + originalSize, originalSize, m.getEncodeSize());
          m.acknowledge();
       }
 
       ClientMessage m = consumer.receive(5000);
       Queue q = (Queue) server.getPostOffice().getBinding(queueA).getBindable();
-      Assert.assertEquals(100, q.getDeliveringCount());
+      Assert.assertEquals(numMessages, q.getDeliveringCount());
       m.acknowledge();
       Assert.assertEquals(0, q.getDeliveringCount());
       sendSession.close();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
index 0597dd5..442d6e9 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
@@ -21,10 +21,12 @@ import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RefCountMessage;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -33,7 +35,10 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.MessageHandler;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.encode.BodyType;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQConsumerContext;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.Queue;
@@ -332,10 +337,124 @@ public class AcknowledgeTest extends ActiveMQTestBase {
       }
    }
 
-   class FakeMessageWithID implements Message {
+   class FakeMessageWithID extends RefCountMessage {
+
+      @Override
+      public int getPersistSize() {
+         return 0;
+      }
+
+      @Override
+      public void persist(ActiveMQBuffer targetRecord) {
+      }
+
+      @Override
+      public Persister<Message> getPersister() {
+         return null;
+      }
+
+      @Override
+      public Message setProtocol(Object protocol) {
+         return this;
+      }
+
+      @Override
+      public void reloadPersistence(ActiveMQBuffer record) {
+
+      }
+
+      @Override
+      public Message toCore() {
+         return this;
+      }
+
+      @Override
+      public void receiveBuffer(ByteBuf buffer) {
+
+      }
+
+      @Override
+      public void sendBuffer(ByteBuf buffer, int count) {
+
+      }
+
+      @Override
+      public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
+         return null;
+      }
+
+      @Override
+      public Message setUserID(Object userID) {
+         return null;
+      }
+
+      @Override
+      public void copyHeadersAndProperties(Message msg) {
+
+      }
+
+      @Override
+      public void messageChanged() {
+
+      }
+
+      @Override
+      public ActiveMQBuffer getReadOnlyBodyBuffer() {
+         return null;
+      }
 
       final long id;
 
+      @Override
+      public Message setType(byte type) {
+         return null;
+      }
+
+      @Override
+      public Message copy() {
+         return null;
+      }
+
+      @Override
+      public Message copy(long newID) {
+         return null;
+      }
+
+      @Override
+      public Message setMessageID(long id) {
+         return null;
+      }
+
+      @Override
+      public int getRefCount() {
+         return 0;
+      }
+
+      @Override
+      public int incrementRefCount() throws Exception {
+         return 0;
+      }
+
+      @Override
+      public int decrementRefCount() throws Exception {
+         return 0;
+      }
+
+      @Override
+      public int incrementDurableRefCount() {
+         return 0;
+      }
+
+      @Override
+      public int decrementDurableRefCount() {
+         return 0;
+      }
+
+      @Override
+      public int getMemoryEstimate() {
+         return 0;
+      }
+
       FakeMessageWithID(final long id) {
          this.id = id;
       }
@@ -351,12 +470,47 @@ public class AcknowledgeTest extends ActiveMQTestBase {
       }
 
       @Override
-      public FakeMessageWithID setUserID(UUID userID) {
-         return this;
+      public String getAddress() {
+         return null;
+      }
+
+      @Override
+      public SimpleString getAddressSimpleString() {
+         return null;
+      }
+
+      @Override
+      public Message setBuffer(ByteBuf buffer) {
+         return null;
+      }
+
+      @Override
+      public ByteBuf getBuffer() {
+         return null;
+      }
+
+      @Override
+      public Object getProtocol() {
+         return null;
+      }
+
+      @Override
+      public Object getBody() {
+         return null;
+      }
+
+      @Override
+      public BodyType getBodyType() {
+         return null;
       }
 
       @Override
-      public SimpleString getAddress() {
+      public Message setBody(BodyType type, Object body) {
+         return null;
+      }
+
+      @Override
+      public Message setAddress(String address) {
          return null;
       }
 
@@ -431,11 +585,6 @@ public class AcknowledgeTest extends ActiveMQTestBase {
       }
 
       @Override
-      public ActiveMQBuffer getBodyBufferDuplicate() {
-         return null;
-      }
-
-      @Override
       public Message putBooleanProperty(SimpleString key, boolean value) {
          return null;
       }
@@ -689,15 +838,5 @@ public class AcknowledgeTest extends ActiveMQTestBase {
       public Map<String, Object> toPropertyMap() {
          return null;
       }
-
-      @Override
-      public FakeMessageWithID writeBodyBufferBytes(byte[] bytes) {
-         return this;
-      }
-
-      @Override
-      public FakeMessageWithID writeBodyBufferString(String string) {
-         return this;
-      }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
index 8f00b2a..e2cf2a0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
@@ -16,6 +16,13 @@
  */
 package org.apache.activemq.artemis.tests.integration.client;
 
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Set;
@@ -27,6 +34,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
 import org.apache.activemq.artemis.api.core.Interceptor;
 import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -41,10 +49,13 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.tests.util.Wait;
+import org.apache.activemq.artemis.utils.ByteUtil;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
+import org.apache.qpid.jms.JmsConnectionFactory;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -54,15 +65,17 @@ import org.junit.runners.Parameterized;
 @RunWith(value = Parameterized.class)
 public class ConsumerTest extends ActiveMQTestBase {
 
-   @Parameterized.Parameters(name = "isNetty={0}")
+   @Parameterized.Parameters(name = "isNetty={0}, persistent={1}")
    public static Collection getParameters() {
-      return Arrays.asList(new Object[][]{{true}, {false}});
+      return Arrays.asList(new Object[][]{{true, true}, {false, false}, {false, true}, {true, false}});
    }
 
-   public ConsumerTest(boolean netty) {
+   public ConsumerTest(boolean netty, boolean durable) {
       this.netty = netty;
+      this.durable = durable;
    }
 
+   private final boolean durable;
    private final boolean netty;
    private ActiveMQServer server;
 
@@ -79,13 +92,31 @@ public class ConsumerTest extends ActiveMQTestBase {
    public void setUp() throws Exception {
       super.setUp();
 
-      server = createServer(false, isNetty());
+      server = createServer(durable, isNetty());
 
       server.start();
 
       locator = createFactory(isNetty());
    }
 
+   @Before
+   public void createQueue() throws Exception {
+
+      ServerLocator locator = createFactory(isNetty());
+
+      ClientSessionFactory sf = createSessionFactory(locator);
+
+      ClientSession session = sf.createSession(false, true, true, true);
+
+      server.createQueue(QUEUE, RoutingType.ANYCAST, QUEUE, null, true, false);
+
+      session.close();
+
+      sf.close();
+
+      locator.close();
+   }
+
    @Test
    public void testStressConnection() throws Exception {
 
@@ -113,34 +144,123 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true, false);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
-      ClientConsumer consumer = session.createConsumer(QUEUE);
-
       ClientProducer producer = session.createProducer(QUEUE);
       ClientMessage message = session.createMessage(Message.TEXT_TYPE, true, 0, System.currentTimeMillis(), (byte) 4);
       message.getBodyBuffer().writeString("hi");
       message.putStringProperty("hello", "elo");
       producer.send(message);
 
+      session.commit();
+
+      session.close();
+      if (durable) {
+         server.stop();
+         server.start();
+      }
+      sf = createSessionFactory(locator);
+      session = sf.createSession(false, true, true, false);
+      ClientConsumer consumer = session.createConsumer(QUEUE);
+
       session.start();
 
       if (cancelOnce) {
-         final ClientConsumerInternal consumerInternal = (ClientConsumerInternal)consumer;
+         final ClientConsumerInternal consumerInternal = (ClientConsumerInternal) consumer;
          Wait.waitFor(() -> consumerInternal.getBufferSize() > 0);
          consumer.close();
          consumer = session.createConsumer(QUEUE);
       }
       ClientMessage message2 = consumer.receive(1000);
 
+      Assert.assertNotNull(message2);
+
       System.out.println("Id::" + message2.getMessageID());
 
       System.out.println("Received " + message2);
 
+      System.out.println("Clie:" + ByteUtil.bytesToHex(message2.getBuffer().array(), 4));
+
+      System.out.println("String::" + message2.getReadOnlyBodyBuffer().readString());
+
+      Assert.assertEquals("elo", message2.getStringProperty("hello"));
+
+      Assert.assertEquals("hi", message2.getReadOnlyBodyBuffer().readString());
+
       session.close();
    }
 
+   @Test
+   public void testSendReceiveAMQP() throws Throwable {
+
+      if (!isNetty()) {
+         // no need to run the test, there's no AMQP support
+         return;
+      }
+
+      internalSend(true);
+   }
+
+   @Test
+   public void testSendReceiveCore() throws Throwable {
+
+      if (!isNetty()) {
+         // no need to run the test, there's no AMQP support
+         return;
+      }
+
+      internalSend(false);
+   }
+
+   public void internalSend(boolean amqp) throws Throwable {
+
+      ConnectionFactory factory;
+
+      if (amqp) {
+         factory = new JmsConnectionFactory("amqp://localhost:61616");
+      } else {
+         factory = new ActiveMQConnectionFactory();
+      }
+
+
+      Connection connection = factory.createConnection();
+
+      try {
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         javax.jms.Queue queue = session.createQueue(QUEUE.toString());
+         MessageProducer producer = session.createProducer(queue);
+         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+         long time = System.currentTimeMillis();
+         int NUMBER_OF_MESSAGES = 100;
+         for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
+            producer.send(session.createTextMessage("hello " + i));
+         }
+         long end = System.currentTimeMillis();
+
+         System.out.println("Time = " + (end - time));
+
+         connection.close();
+
+         if (this.durable) {
+            server.stop();
+            server.start();
+         }
 
+         connection = factory.createConnection();
+         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         connection.start();
+
+         MessageConsumer consumer = session.createConsumer(queue);
+
+         for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
+            TextMessage message = (TextMessage) consumer.receive(1000);
+            Assert.assertNotNull(message);
+            Assert.assertEquals("hello " + i, message.getText());
+         }
+      } finally {
+         connection.close();
+      }
+   }
 
    @Test
    public void testConsumerAckImmediateAutoCommitTrue() throws Exception {
@@ -148,8 +268,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;
@@ -180,8 +298,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, false, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;
@@ -212,8 +328,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;
@@ -247,8 +361,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;
@@ -284,11 +396,9 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
-      final int numMessages = 10000;
+      final int numMessages = 100;
 
       for (int i = 0; i < numMessages; i++) {
          ClientMessage message = createTextMessage(session, "m" + i);
@@ -338,8 +448,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       session.start();
 
       ClientProducer producer = session.createProducer(QUEUE);
@@ -372,8 +480,6 @@ public class ConsumerTest extends ActiveMQTestBase {
       ClientSession session = sf.createSession(false, true, true);
       session.start();
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientConsumer consumer = session.createConsumer(QUEUE);
 
       consumer.setMessageHandler(new MessageHandler() {
@@ -394,8 +500,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createSession(false, true, true);
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientConsumer consumer = session.createConsumer(QUEUE);
 
       consumer.setMessageHandler(new MessageHandler() {
@@ -436,7 +540,7 @@ public class ConsumerTest extends ActiveMQTestBase {
 
          sessions.add(session);
 
-         session.createQueue(QUEUE, QUEUE.concat("" + i), null, false);
+         session.createQueue(QUEUE, QUEUE.concat("" + i), null, true);
 
          if (i == 0) {
             session.createQueue(QUEUE_RESPONSE, QUEUE_RESPONSE);
@@ -550,8 +654,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createTransactedSession();
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;
@@ -598,7 +700,6 @@ public class ConsumerTest extends ActiveMQTestBase {
       ServerLocator locator = addServerLocator(ServerLocatorImpl.newLocator("vm:/1"));
       ClientSessionFactory factory = locator.createSessionFactory();
       ClientSession session = factory.createSession();
-      session.createQueue(QUEUE, QUEUE);
       ClientProducer producer = session.createProducer(QUEUE);
       producer.send(session.createMessage(true));
 
@@ -620,8 +721,6 @@ public class ConsumerTest extends ActiveMQTestBase {
 
       ClientSession session = sf.createTransactedSession();
 
-      session.createQueue(QUEUE, QUEUE, null, false);
-
       ClientProducer producer = session.createProducer(QUEUE);
 
       final int numMessages = 100;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java
index 81e0ca4..201a96b 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java
@@ -28,6 +28,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.Interceptor;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -56,7 +58,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueConfig;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.core.server.impl.QueueFactoryImpl;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
@@ -519,7 +520,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
        * @see SessionCallback#sendJmsMessage(org.apache.activemq.artemis.core.server.ServerMessage, long, int)
        */
       @Override
-      public int sendMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, int deliveryCount) {
+      public int sendMessage(MessageReference ref, Message message, ServerConsumer consumer, int deliveryCount) {
          inCall.countDown();
          try {
             callbackSemaphore.acquire();
@@ -541,7 +542,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
        */
       @Override
       public int sendLargeMessage(MessageReference reference,
-                                  ServerMessage message,
+                                  Message message,
                                   ServerConsumer consumer,
                                   long bodySize,
                                   int deliveryCount) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java
index 450a361..d35f436 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InVMNonPersistentMessageBufferTest.java
@@ -16,13 +16,13 @@
  */
 package org.apache.activemq.artemis.tests.integration.client;
 
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -130,9 +130,9 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
 
          message.getBodyBuffer().clear();
 
-         Assert.assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().writerIndex());
+         Assert.assertEquals(DataConstants.SIZE_INT, message.getBodyBuffer().writerIndex());
 
-         Assert.assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+         Assert.assertEquals(DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
       }
    }
 
@@ -148,6 +148,18 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
 
       Assert.assertNotNull(received);
 
+      ActiveMQBuffer buffer = received.getReadOnlyBodyBuffer();
+
+      Assert.assertEquals(body, buffer.readString());
+
+      try {
+         buffer.readByte();
+         Assert.fail("Should throw exception");
+      } catch (IndexOutOfBoundsException e) {
+         // OK
+      }
+
+
       Assert.assertEquals(body, received.getBodyBuffer().readString());
 
       try {
@@ -157,6 +169,18 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
       } catch (IndexOutOfBoundsException e) {
          // OK
       }
+
+      buffer = received.getReadOnlyBodyBuffer();
+
+      Assert.assertEquals(body, buffer.readString());
+
+      try {
+         buffer.readByte();
+         Assert.fail("Should throw exception");
+      } catch (IndexOutOfBoundsException e) {
+         // OK
+      }
+
    }
 
    @Test
@@ -167,7 +191,7 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
 
       message.getBodyBuffer().writeString(body);
 
-      Assert.assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+      Assert.assertEquals(DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
 
       String body2 = message.getBodyBuffer().readString();
 
@@ -175,7 +199,7 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
 
       message.getBodyBuffer().resetReaderIndex();
 
-      Assert.assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
+      Assert.assertEquals(DataConstants.SIZE_INT, message.getBodyBuffer().readerIndex());
 
       String body3 = message.getBodyBuffer().readString();
 
@@ -189,7 +213,7 @@ public class InVMNonPersistentMessageBufferTest extends ActiveMQTestBase {
 
       received.getBodyBuffer().resetReaderIndex();
 
-      Assert.assertEquals(PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, received.getBodyBuffer().readerIndex());
+      Assert.assertEquals(DataConstants.SIZE_INT, received.getBodyBuffer().readerIndex());
 
       String body4 = received.getBodyBuffer().readString();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java
index 1950e12..540baf6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java
@@ -53,10 +53,8 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueConfig;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
@@ -125,10 +123,10 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase {
       producer.send(clientFile);
 
       Thread.sleep(500);
-
-      for (ServerSession srvSession : server.getSessions()) {
-         ((ServerSessionImpl) srvSession).clearLargeMessage();
-      }
+//
+//      for (ServerSession srvSession : server.getSessions()) {
+//         ((ServerSessionImpl) srvSession).clearLargeMessage();
+//      }
 
       server.stop(false);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
index 3577a87..5e822eb 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java
@@ -40,7 +40,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.StoreConfiguration;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
@@ -890,7 +890,7 @@ public class LargeMessageTest extends LargeMessageTestBase {
             Message clientFile = createLargeClientMessageStreaming(session, messageSize, true);
 
             if (isSimulateBridge) {
-               clientFile.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, someDuplicateInfo.getBytes());
+               clientFile.putBytesProperty(Message.HDR_BRIDGE_DUPLICATE_ID, someDuplicateInfo.getBytes());
             } else {
                clientFile.putBytesProperty(Message.HDR_DUPLICATE_DETECTION_ID, someDuplicateInfo.getBytes());
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
index 87f9255..b0f03d4 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java
@@ -38,6 +38,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.Interceptor;
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
@@ -68,7 +69,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 import org.apache.activemq.artemis.core.server.cluster.impl.BridgeImpl;
@@ -1885,12 +1885,8 @@ public class BridgeTest extends ActiveMQTestBase {
       final String BRIDGE = "myBridge";
 
       ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl();
-      Transformer transformer = new Transformer() {
-         @Override
-         public ServerMessage transform(ServerMessage message) {
-            return null;
-         }
-      };
+      Transformer transformer = (Message encode) -> null;
+
       serviceRegistry.addBridgeTransformer(BRIDGE, transformer);
       Configuration config = createDefaultInVMConfig().addConnectorConfiguration("in-vm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
       ActiveMQServer server = addServer(new ActiveMQServerImpl(config, null, null, null, serviceRegistry));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/SimpleTransformer.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/SimpleTransformer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/SimpleTransformer.java
index d9a817e..c0487d0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/SimpleTransformer.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/SimpleTransformer.java
@@ -16,40 +16,43 @@
  */
 package org.apache.activemq.artemis.tests.integration.cluster.bridge;
 
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 
 public class SimpleTransformer implements Transformer {
 
    @Override
-   public ServerMessage transform(final ServerMessage message) {
-      SimpleString oldProp = (SimpleString) message.getObjectProperty(new SimpleString("wibble"));
-
-      if (!oldProp.equals(new SimpleString("bing"))) {
-         throw new IllegalStateException("Wrong property value!!");
-      }
-
-      // Change a property
-      message.putStringProperty(new SimpleString("wibble"), new SimpleString("bong"));
-
-      // Change the body
-      ActiveMQBuffer buffer = message.getBodyBuffer();
-
-      buffer.readerIndex(0);
-
-      String str = buffer.readString();
-
-      if (!str.equals("doo be doo be doo be doo")) {
-         throw new IllegalStateException("Wrong body!!");
-      }
-
-      buffer.clear();
-
-      buffer.writeString("dee be dee be dee be dee");
-
-      return message;
+   public Message transform(final Message message) {
+
+      // TODO-now: fix this test!!!
+
+      throw new RuntimeException(("Fix me"));
+//      SimpleString oldProp = (SimpleString) message.getObjectProperty(new SimpleString("wibble"));
+//
+//      if (!oldProp.equals(new SimpleString("bing"))) {
+//         throw new IllegalStateException("Wrong property value!!");
+//      }
+//
+//      // Change a property
+//      message.putStringProperty(new SimpleString("wibble"), new SimpleString("bong"));
+//
+//      // Change the body
+//      ActiveMQBuffer buffer = message.getBodyBuffer();
+//
+//      buffer.readerIndex(0);
+//
+//      String str = buffer.readString();
+//
+//      if (!str.equals("doo be doo be doo be doo")) {
+//         throw new IllegalStateException("Wrong body!!");
+//      }
+//
+//      buffer.clear();
+//
+//      buffer.writeString("dee be dee be dee be dee");
+//
+//      return message;
    }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java
index 26bcb43..8766057 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterHeadersRemovedTest.java
@@ -16,12 +16,13 @@
  */
 package org.apache.activemq.artemis.tests.integration.cluster.distribution;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.junit.Before;
 import org.junit.Test;
@@ -83,7 +84,7 @@ public class ClusterHeadersRemovedTest extends ClusterTestBase {
 
          assertNotNull(message);
 
-         assertFalse(message.containsProperty(MessageImpl.HDR_ROUTE_TO_IDS));
+         assertFalse(message.containsProperty(Message.HDR_ROUTE_TO_IDS));
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java
index de5fe33..0b0fa00 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionTest.java
@@ -28,7 +28,7 @@ import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.core.server.cluster.impl.Redistributor;
@@ -474,7 +474,7 @@ public class MessageRedistributionTest extends ClusterTestBase {
 
          bb.putLong(i);
 
-         msg.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, bytes);
+         msg.putBytesProperty(Message.HDR_BRIDGE_DUPLICATE_ID, bytes);
 
          prod0.send(msg);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java
index 510fa68..69a360e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -35,7 +36,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl;
@@ -1301,7 +1302,7 @@ public class DivertTest extends ActiveMQTestBase {
       ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl();
       Transformer transformer = new Transformer() {
          @Override
-         public ServerMessage transform(ServerMessage message) {
+         public Message transform(Message message) {
             return null;
          }
       };

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java
index 43a4ad9..eff1615 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java
@@ -50,7 +50,7 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionRec
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
@@ -88,7 +88,7 @@ public class InterceptorTest extends ActiveMQTestBase {
          if (packet.getType() == PacketImpl.SESS_SEND) {
             SessionSendMessage p = (SessionSendMessage) packet;
 
-            ServerMessage sm = (ServerMessage) p.getMessage();
+            Message sm = p.getMessage();
 
             sm.putStringProperty(InterceptorTest.key, "orange");
          }
@@ -165,7 +165,7 @@ public class InterceptorTest extends ActiveMQTestBase {
          if (packet.getType() == PacketImpl.SESS_RECEIVE_MSG) {
             SessionReceiveMessage p = (SessionReceiveMessage) packet;
 
-            ServerMessage sm = (ServerMessage) p.getMessage();
+            Message sm = p.getMessage();
 
             sm.putStringProperty(InterceptorTest.key, "orange");
          }
@@ -319,7 +319,7 @@ public class InterceptorTest extends ActiveMQTestBase {
          if (packet.getType() == PacketImpl.SESS_SEND) {
             SessionSendMessage p = (SessionSendMessage) packet;
 
-            ServerMessage sm = (ServerMessage) p.getMessage();
+            Message sm = p.getMessage();
 
             sm.putIntProperty(key, num);
 


[06/29] activemq-artemis git commit: removing dead code and docs

Posted by cl...@apache.org.
removing dead code and docs


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a3330457
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a3330457
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a3330457

Branch: refs/heads/artemis-1009
Commit: a3330457e7e68f39caf3018115885ccb45e7f342
Parents: 03fdc20
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 10:54:40 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/api/core/Message.java       |  6 ------
 .../artemis/core/message/impl/CoreMessage.java   | 19 -------------------
 .../protocol/amqp/broker/AMQPMessage.java        |  3 ---
 .../converter/message/InboundTransformer.java    |  2 --
 4 files changed, 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3330457/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
index a6ef408..d96f232 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
@@ -69,12 +69,6 @@ import org.apache.activemq.artemis.core.persistence.Persister;
  * size = encode.getEncodeSize();
  * encode.encodeDirectly(bufferOutput);
  *
- *
- * Disabling temporary buffer:
- *
- * // This will make the message to only be encoded directly to the output stream, useful on client core API
- * encode.disableInternalBuffer();
-
  */
 public interface Message {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3330457/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index edbcaa9..973c1de 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -541,25 +541,6 @@ public class CoreMessage extends RefCountMessage {
       return false;
    }
 
-   private void encodeBody(ByteBuf intoBuffer) {
-      intoBuffer.writerIndex(DataConstants.SIZE_INT);
-
-      switch (getBodyType()) {
-
-         // TODO-now implement other types
-         case Text:
-            SimpleString.writeNullableSimpleString(intoBuffer, SimpleString.toSimpleString(body == null ? null : body.toString()));
-            break;
-
-         default:
-            break;
-      }
-
-
-      endOfBodyPosition = buffer.writerIndex() + BUFFER_HEADER_SPACE;
-      buffer.setInt(0, endOfBodyPosition);
-   }
-
    @Override
    public String getAddress() {
       if (address == null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3330457/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index c963061..7fabefd 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -488,9 +488,6 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public void sendBuffer(ByteBuf buffer, int deliveryCount) {
-      // TODO: do I need to change the Header with deliveryCount?
-      //       I would send a new instance of Header with a new delivery count, and only send partial of the buffer
-      //       previously received
       checkBuffer();
       Header header = getHeader();
       if (header != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3330457/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
index cec34ef..1e83959 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
@@ -58,8 +58,6 @@ public abstract class InboundTransformer {
 
    protected IDGenerator idGenerator;
 
-   public static final String TRANSFORMER_NATIVE = "native";
-   public static final String TRANSFORMER_RAW = "raw";
    public static final String TRANSFORMER_JMS = "jms";
 
    public InboundTransformer(IDGenerator idGenerator) {


[28/29] activemq-artemis git commit: Fixing Scheduled Message

Posted by cl...@apache.org.
Fixing Scheduled Message


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/062ab57a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/062ab57a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/062ab57a

Branch: refs/heads/artemis-1009
Commit: 062ab57a8c26e5f2cfa04cd5f9d7f3488022cff9
Parents: 99ee2cc
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 17:43:51 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/api/core/Message.java      |  3 +
 .../artemis/core/message/impl/CoreMessage.java  | 11 ++++
 .../protocol/amqp/broker/AMQPMessage.java       | 69 ++++++++++++--------
 .../core/postoffice/impl/PostOfficeImpl.java    | 18 +++--
 .../management/impl/ManagementServiceImpl.java  |  3 +-
 .../impl/ScheduledDeliveryHandlerTest.java      |  9 ++-
 .../tests/integration/amqp/ProtonTest.java      | 49 +++++++-------
 .../integration/client/AcknowledgeTest.java     |  5 ++
 8 files changed, 99 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
index d96f232..b08202d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
@@ -169,6 +169,9 @@ public interface Message {
 
    void messageChanged();
 
+   /** Used to calculate what is the delivery time.
+    *  Return null if not scheduled. */
+   Long getScheduledDeliveryTime();
 
    /** Used for Large messages on Core.
     *  Do not use this, it will go away

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index 513b758..f620a1d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -153,6 +153,17 @@ public class CoreMessage extends RefCountMessage {
       }
    }
 
+   @Override
+   public Long getScheduledDeliveryTime() {
+      Object property = getObjectProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
+
+      if (property != null && property instanceof Number) {
+         return ((Number) property).longValue();
+      }
+
+      return null;
+   }
+
    /**
     * {@inheritDoc}
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index d39bf9d..772f2cd 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -37,6 +37,7 @@ import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.activemq.artemis.protocol.amqp.util.TLSEncode;
 import org.apache.activemq.artemis.utils.DataConstants;
+import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedInteger;
 import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
 import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
@@ -63,6 +64,7 @@ public class AMQPMessage extends RefCountMessage {
    private long expiration = 0;
    // this can be used to encode the header again and the rest of the message buffer
    private int headerEnd = -1;
+   private boolean parsedHeaders = false;
    private Header _header;
    private DeliveryAnnotations _deliveryAnnotations;
    private MessageAnnotations _messageAnnotations;
@@ -142,39 +144,55 @@ public class AMQPMessage extends RefCountMessage {
    }
 
    private ApplicationProperties getApplicationProperties() {
-      if (applicationProperties == null) {
-         if (data != null) {
-            partialDecode(data.nioBuffer(), true);
-         } else {
-            initalizeObjects();
-         }
-      }
-
+      parseHeaders();
       return applicationProperties;
    }
 
-   public Header getHeader() {
-      if (_header == null) {
+   private void parseHeaders() {
+      if (!parsedHeaders) {
          if (data == null) {
             initalizeObjects();
          } else {
-            partialDecode(this.data.nioBuffer(), false);
+            partialDecode(data.nioBuffer());
          }
+         parsedHeaders = true;
       }
+   }
 
+   public MessageAnnotations getMessageAnnotations() {
+      parseHeaders();
+      return _messageAnnotations;
+   }
+
+   public Header getHeader() {
+      parseHeaders();
       return _header;
    }
 
    public Properties getProperties() {
-      if (_properties == null) {
-         if (data == null) {
-            initalizeObjects();
-         } else {
-            partialDecode(this.data.nioBuffer(), true);
-         }
+      parseHeaders();
+      return _properties;
+   }
+
+   private Object getSymbol(String symbol) {
+      MessageAnnotations annotations = getMessageAnnotations();
+      Map mapAnnotations = annotations != null ? annotations.getValue() : null;
+      if (mapAnnotations != null) {
+         return mapAnnotations.get(Symbol.getSymbol("x-opt-delivery-time"));
       }
 
-      return _properties;
+      return null;
+   }
+
+   @Override
+   public Long getScheduledDeliveryTime() {
+
+      Object scheduledTime = getSymbol("x-opt-delivery-time");
+      if (scheduledTime != null && scheduledTime instanceof Number) {
+         return ((Number)scheduledTime).longValue();
+      }
+
+      return null;
    }
 
    @Override
@@ -182,7 +200,7 @@ public class AMQPMessage extends RefCountMessage {
       return AMQPMessagePersister.getInstance();
    }
 
-   private synchronized void partialDecode(ByteBuffer buffer, boolean readApplicationProperties) {
+   private synchronized void partialDecode(ByteBuffer buffer) {
       DecoderImpl decoder = TLSEncode.getDecoder();
       decoder.setByteBuffer(buffer);
       buffer.position(0);
@@ -207,11 +225,7 @@ public class AMQPMessage extends RefCountMessage {
                this.expiration = System.currentTimeMillis() + _header.getTtl().intValue();
             }
 
-            if (!readApplicationProperties) {
-               return;
-            }
-
-            if (buffer.hasRemaining() && readApplicationProperties) {
+            if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
             } else {
                section = null;
@@ -220,10 +234,6 @@ public class AMQPMessage extends RefCountMessage {
             // meaning there is no header
             headerEnd = 0;
          }
-
-         if (!readApplicationProperties) {
-            return;
-         }
          if (section instanceof DeliveryAnnotations) {
             _deliveryAnnotations = (DeliveryAnnotations) section;
 
@@ -254,6 +264,7 @@ public class AMQPMessage extends RefCountMessage {
             }
 
          }
+
          if (section instanceof ApplicationProperties) {
             applicationProperties = (ApplicationProperties) section;
          }
@@ -785,7 +796,7 @@ public class AMQPMessage extends RefCountMessage {
    @Override
    public org.apache.activemq.artemis.api.core.Message toCore() {
       MessageImpl protonMessage = getProtonMessage();
-      return null;
+      throw new IllegalStateException("conversion between AMQP and Core not implemented yet!");
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
index 81a83ac..d23185e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
@@ -1079,6 +1079,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
 
       Transaction tx = context.getTransaction();
 
+      Long deliveryTime = message.getScheduledDeliveryTime();
+
       for (Map.Entry<SimpleString, RouteContextList> entry : context.getContexListing().entrySet()) {
          PagingStore store = pagingManager.getPageStore(entry.getKey());
 
@@ -1095,12 +1097,10 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
          for (Queue queue : entry.getValue().getNonDurableQueues()) {
             MessageReference reference = MessageReference.Factory.createReference(message, queue);
 
-            refs.add(reference);
-            if (message.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) {
-               Long scheduledDeliveryTime = message.getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
-
-               reference.setScheduledDeliveryTime(scheduledDeliveryTime);
+            if (deliveryTime != null) {
+               reference.setScheduledDeliveryTime(deliveryTime);
             }
+            refs.add(reference);
 
             message.incrementRefCount();
          }
@@ -1119,13 +1119,11 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
                }
             }
 
-            refs.add(reference);
-
-            if (message.containsProperty(Message.HDR_SCHEDULED_DELIVERY_TIME)) {
-               Long scheduledDeliveryTime = message.getLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
 
-               reference.setScheduledDeliveryTime(scheduledDeliveryTime);
+            if (deliveryTime != null) {
+               reference.setScheduledDeliveryTime(deliveryTime);
             }
+            refs.add(reference);
 
             if (message.isDurable()) {
                int durableRefCount = message.incrementDurableRefCount();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 002b2c7..5b2bf28 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -365,7 +365,8 @@ public class ManagementServiceImpl implements ManagementService {
    }
 
    @Override
-   public Message handleMessage(final Message message) throws Exception {
+   public Message handleMessage(Message message) throws Exception {
+      message = message.toCore();
       // a reply message is sent with the result stored in the message body.
       Message reply = new CoreMessage(storageManager.generateID(), 512);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
index 4da2e63..5b44572 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java
@@ -35,8 +35,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.Message;
-
 import org.apache.activemq.artemis.api.core.RefCountMessage;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.encode.BodyType;
 import org.apache.activemq.artemis.core.filter.Filter;
@@ -47,8 +47,6 @@ import org.apache.activemq.artemis.core.server.Consumer;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.api.core.RoutingType;
-
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
@@ -293,6 +291,11 @@ public class ScheduledDeliveryHandlerTest extends Assert {
       }
 
       @Override
+      public Long getScheduledDeliveryTime() {
+         return null;
+      }
+
+      @Override
       public void reloadPersistence(ActiveMQBuffer record) {
 
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
index aa1bdc4..4640c33 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
@@ -16,28 +16,6 @@
  */
 package org.apache.activemq.artemis.tests.integration.amqp;
 
-import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.DELAYED_DELIVERY;
-import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.PRODUCT;
-import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.VERSION;
-import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.contains;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -61,7 +39,24 @@ import javax.jms.Topic;
 import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.core.config.Configuration;
@@ -71,14 +66,13 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
 import org.apache.activemq.artemis.protocol.amqp.client.AMQPClientConnectionFactory;
 import org.apache.activemq.artemis.protocol.amqp.client.ProtonClientConnectionManager;
 import org.apache.activemq.artemis.protocol.amqp.client.ProtonClientProtocolManager;
-import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
 import org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport;
 import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerReceiverContext;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -105,6 +99,11 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.DELAYED_DELIVERY;
+import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.PRODUCT;
+import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.VERSION;
+import static org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport.contains;
+
 @RunWith(Parameterized.class)
 public class ProtonTest extends ProtonTestBase {
 
@@ -379,7 +378,7 @@ public class ProtonTest extends ProtonTestBase {
          receiver.flow(1);
 
          // Shouldn't get this since we delayed the message.
-         assertNull(receiver.receive(5, TimeUnit.SECONDS));
+         assertNull(receiver.receive(1, TimeUnit.SECONDS));
       } finally {
          connection.close();
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/062ab57a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
index 442d6e9..40f2ebd 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java
@@ -364,6 +364,11 @@ public class AcknowledgeTest extends ActiveMQTestBase {
       }
 
       @Override
+      public Long getScheduledDeliveryTime() {
+         return null;
+      }
+
+      @Override
       public Message toCore() {
          return this;
       }


[23/29] activemq-artemis git commit: fixing Proton tests

Posted by cl...@apache.org.
fixing Proton tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7174b536
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7174b536
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7174b536

Branch: refs/heads/artemis-1009
Commit: 7174b5363b016f8425f1ee4543e81e7ecba41740
Parents: e85f755
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 28 22:12:13 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../protocol/amqp/broker/AMQPMessage.java       | 149 +++++++++++--------
 .../amqp/broker/AMQPSessionCallback.java        |   2 +-
 .../artemis/core/filter/impl/FilterImpl.java    |   7 +-
 .../impl/journal/LargeServerMessageImpl.java    |   2 +-
 .../core/server/impl/ServerSessionImpl.java     |   2 +-
 5 files changed, 100 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7174b536/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index c530c94..1cb85ea 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -19,6 +19,8 @@ package org.apache.activemq.artemis.protocol.amqp.broker;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import io.netty.buffer.ByteBuf;
@@ -49,16 +51,15 @@ import org.apache.qpid.proton.util.TLSEncoder;
 // see https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
 public class AMQPMessage extends RefCountMessage {
 
-   private volatile int memoryEstimate = -1;
-
    final long messageFormat;
-   private ProtonProtocolManager protocolManager;
    ByteBuf data;
    boolean bufferValid;
    byte type;
    long messageID;
    String address;
    MessageImpl protonMessage;
+   private volatile int memoryEstimate = -1;
+   private ProtonProtocolManager protocolManager;
    private long expiration = 0;
    // this can be used to encode the header again and the rest of the message buffer
    private int headerEnd = -1;
@@ -124,6 +125,22 @@ public class AMQPMessage extends RefCountMessage {
       }
    }
 
+   private Map getApplicationPropertiesMap() {
+
+      ApplicationProperties appMap = getApplicationProperties();
+      Map map = null;
+
+      if (appMap != null) {
+         map = appMap.getValue();
+      }
+
+      if (map == null) {
+         return Collections.emptyMap();
+      } else {
+         return map;
+      }
+   }
+
    private ApplicationProperties getApplicationProperties() {
       if (applicationProperties == null) {
          if (data != null) {
@@ -347,7 +364,7 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public Object getUserID() {
-      return null;
+      return getProperties().getMessageId();
    }
 
    @Override
@@ -415,17 +432,17 @@ public class AMQPMessage extends RefCountMessage {
    }
 
    @Override
-   public AMQPMessage setAddress(SimpleString address) {
-      return setAddress(address.toString());
-   }
-
-   @Override
    public AMQPMessage setAddress(String address) {
       this.address = address;
       return this;
    }
 
    @Override
+   public AMQPMessage setAddress(SimpleString address) {
+      return setAddress(address.toString());
+   }
+
+   @Override
    public SimpleString getAddressSimpleString() {
       return SimpleString.toSimpleString(getAddress());
    }
@@ -492,244 +509,256 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putBooleanProperty(String key, boolean value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Boolean.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putByteProperty(String key, byte value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Byte.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putBytesProperty(String key, byte[] value) {
-      return null;
+      getApplicationPropertiesMap().put(key, value);
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putShortProperty(String key, short value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Short.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putCharProperty(String key, char value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Character.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putIntProperty(String key, int value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Integer.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putLongProperty(String key, long value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Long.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putFloatProperty(String key, float value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Float.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putDoubleProperty(String key, double value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Double.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putBooleanProperty(SimpleString key, boolean value) {
-      return null;
+      getApplicationPropertiesMap().put(key, Boolean.valueOf(value));
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putByteProperty(SimpleString key, byte value) {
-      return null;
+      return putByteProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putBytesProperty(SimpleString key, byte[] value) {
-      return null;
+      return putBytesProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putShortProperty(SimpleString key, short value) {
-      return null;
+      return putShortProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putCharProperty(SimpleString key, char value) {
-      return null;
+      return putCharProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putIntProperty(SimpleString key, int value) {
-      return null;
+      return putIntProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putLongProperty(SimpleString key, long value) {
-      return null;
+      return putLongProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putFloatProperty(SimpleString key, float value) {
-      return null;
+      return putFloatProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putDoubleProperty(SimpleString key, double value) {
-      return null;
+      return putDoubleProperty(key.toString(), value);
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putStringProperty(String key, String value) {
-      return null;
+      getApplicationPropertiesMap().put(key, value);
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putObjectProperty(String key,
                                                                          Object value) throws ActiveMQPropertyConversionException {
-      return null;
+      getApplicationPropertiesMap().put(key, value);
+      return this;
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putObjectProperty(SimpleString key,
                                                                          Object value) throws ActiveMQPropertyConversionException {
-      return null;
+      return putObjectProperty(key.toString(), value);
    }
 
    @Override
    public Object removeProperty(String key) {
-      return null;
+      return getApplicationPropertiesMap().remove(key);
    }
 
    @Override
    public boolean containsProperty(String key) {
-      return false;
+      return getApplicationPropertiesMap().containsKey(key);
    }
 
    @Override
    public Boolean getBooleanProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Boolean)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Byte getByteProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Byte)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Double getDoubleProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Double)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Integer getIntProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Integer)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Long getLongProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Long)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Object getObjectProperty(String key) {
-      return null;
+      return getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Short getShortProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Short)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Float getFloatProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (Float)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public String getStringProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return (String)getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public SimpleString getSimpleStringProperty(String key) throws ActiveMQPropertyConversionException {
-      return null;
+      return SimpleString.toSimpleString((String)getApplicationPropertiesMap().get(key));
    }
 
    @Override
    public byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException {
-      return new byte[0];
+      return (byte[]) getApplicationPropertiesMap().get(key);
    }
 
    @Override
    public Object removeProperty(SimpleString key) {
-      return null;
+      return removeProperty(key.toString());
    }
 
    @Override
    public boolean containsProperty(SimpleString key) {
-      return false;
+      return containsProperty(key.toString());
    }
 
    @Override
    public Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getBooleanProperty(key.toString());
    }
 
    @Override
    public Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getByteProperty(key.toString());
    }
 
    @Override
    public Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getDoubleProperty(key.toString());
    }
 
    @Override
    public Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getIntProperty(key.toString());
    }
 
    @Override
    public Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getLongProperty(key.toString());
    }
 
    @Override
    public Object getObjectProperty(SimpleString key) {
-      return null;
+      return getObjectProperty(key.toString());
    }
 
    @Override
    public Short getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getShortProperty(key.toString());
    }
 
    @Override
    public Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getFloatProperty(key.toString());
    }
 
    @Override
    public String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getStringProperty(key.toString());
    }
 
    @Override
    public SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return null;
+      return getSimpleStringProperty(key.toString());
    }
 
    @Override
    public byte[] getBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException {
-      return new byte[0];
+      return getBytesProperty(key.toString());
    }
 
    @Override
    public org.apache.activemq.artemis.api.core.Message putStringProperty(SimpleString key, SimpleString value) {
-      return null;
+      return putStringProperty(key.toString(), value.toString());
    }
 
    @Override
@@ -739,7 +768,11 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public Set<SimpleString> getPropertyNames() {
-      return Collections.emptySet();
+      HashSet<SimpleString> values = new HashSet<>();
+      for (Object k : getApplicationPropertiesMap().keySet()) {
+         values.add(SimpleString.toSimpleString(k.toString()));
+      }
+      return values;
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7174b536/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
----------------------------------------------------------------------
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 0b02838..f34298c 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
@@ -401,7 +401,7 @@ public class AMQPSessionCallback implements SessionCallback {
                            final Receiver receiver) throws Exception {
       try {
 
-         message.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString(), receiver.getSession().getConnection().getRemoteContainer());
+//         message.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString(), receiver.getSession().getConnection().getRemoteContainer());
          serverSession.send(transaction, message, false, false);
 
          // FIXME Potential race here...

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7174b536/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
index 9d321c7..33a1187 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
@@ -158,7 +158,12 @@ public class FilterImpl implements Filter {
             }
          }
          // It's the stringified (hex) representation of a user id that can be used in a selector expression
-         return new SimpleString("ID:" + msg.getUserID());
+         String userID = msg.getUserID().toString();
+         if (userID.startsWith("ID:")) {
+            return SimpleString.toSimpleString(userID);
+         } else {
+            return new SimpleString("ID:" + msg.getUserID());
+         }
       } else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {
          return Integer.valueOf(msg.getPriority());
       } else if (FilterConstants.ACTIVEMQ_TIMESTAMP.equals(fieldName)) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7174b536/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index 817a56a..1b5c24e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -272,7 +272,7 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
          file.open();
          file.position(0);
 
-         for (; ; ) {
+         for (;;) {
             // The buffer is reused...
             // We need to make sure we clear the limits and the buffer before reusing it
             buffer.clear();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7174b536/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index 27fbdcb..6d95341 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -1661,7 +1661,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
          if (value == null) {
             // TODO-now: userID
-            targetAddressInfos.put(msg.getAddressSimpleString(), new Pair<>((UUID)msg.getUserID(), new AtomicLong(1)));
+//            targetAddressInfos.put(msg.getAddressSimpleString(), new Pair<>((UUID)msg.getUserID(), new AtomicLong(1)));
          } else {
             // TODO-now: userID
             value.setA((UUID)msg.getUserID());


[29/29] activemq-artemis git commit: Fixing replication tests

Posted by cl...@apache.org.
Fixing replication tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ea358aa1
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ea358aa1
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ea358aa1

Branch: refs/heads/artemis-1009
Commit: ea358aa12c7a0c5d739739ae2e87ddb728666434
Parents: 5acb6f5
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 16:05:17 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/core/message/impl/CoreMessage.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea358aa1/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index b1bad5a..513b758 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -990,6 +990,7 @@ public class CoreMessage extends RefCountMessage {
 
    @Override
    public void persist(ActiveMQBuffer targetRecord) {
+      checkEncode();
       targetRecord.writeInt(buffer.writerIndex());
       targetRecord.writeBytes(buffer, 0, buffer.writerIndex());
    }


[08/29] activemq-artemis git commit: Removing Aeroegear

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear.min.js
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear.min.js b/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear.min.js
deleted file mode 100644
index f45dfa0..0000000
--- a/examples/protocols/stomp/stomp-websockets/aerogear-chat/aerogear.min.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*! Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-(function(e,t){function r(e,t,r){if(4!==t.length)throw new h.exception.invalid("invalid aes block size");var n=e.c[r],a=t[0]^n[0],i=t[r?3:1]^n[1],s=t[2]^n[2];t=t[r?1:3]^n[3];var o,c,u,f,l=n.length/4-2,d=4,p=[0,0,0,0];o=e.n[r],e=o[0];var g=o[1],m=o[2],y=o[3],b=o[4];for(f=0;l>f;f++)o=e[a>>>24]^g[255&i>>16]^m[255&s>>8]^y[255&t]^n[d],c=e[i>>>24]^g[255&s>>16]^m[255&t>>8]^y[255&a]^n[d+1],u=e[s>>>24]^g[255&t>>16]^m[255&a>>8]^y[255&i]^n[d+2],t=e[t>>>24]^g[255&a>>16]^m[255&i>>8]^y[255&s]^n[d+3],d+=4,a=o,i=c,s=u;for(f=0;4>f;f++)p[r?3&-f:f]=b[a>>>24]<<24^b[255&i>>16]<<16^b[255&s>>8]<<8^b[255&t]^n[d++],o=a,a=i,i=s,s=t,t=o;return p}function n(e,t){var r,n,a,i=t.slice(0),s=e.u,o=e.c,c=s[0],u=s[1],h=s[2],f=s[3],l=s[4],d=s[5],p=s[6],g=s[7];for(r=0;64>r;r++)16>r?n=i[r]:(n=i[15&r+1],a=i[15&r+14],n=i[15&r]=0|(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(a>>>17^a>>>19^a>>>10^a<<15^a<<13)+i[15&r]+i[15&r+9]),n=n+g+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(p^l&(d^p))+o[r],g=p,p=d,d=l,l=0|f+n,f=h,h=u,u=c,c=0|n+(u&h^f&(u
 ^h))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10);s[0]=0|s[0]+c,s[1]=0|s[1]+u,s[2]=0|s[2]+h,s[3]=0|s[3]+f,s[4]=0|s[4]+l,s[5]=0|s[5]+d,s[6]=0|s[6]+p,s[7]=0|s[7]+g}function a(e,t){var r,n=h.random.F[e],a=[];for(r in n)n.hasOwnProperty(r)&&a.push(n[r]);for(r=0;a.length>r;r++)a[r](t)}function i(e){e.c=s(e).concat(s(e)),e.H=new h.cipher.aes(e.c)}function s(e){for(var t=0;4>t&&(e.h[t]=0|e.h[t]+1,!e.h[t]);t++);return e.H.encrypt(e.h)}this.AeroGear={},AeroGear.Core=function(){if(this instanceof AeroGear.Core)throw"Invalid instantiation of base class AeroGear.Core";this.add=function(e){var t,r,n=this[this.collectionName]||{};if(this[this.collectionName]=n,!e)return this;if("string"==typeof e)n[e]=AeroGear[this.lib].adapters[this.type](e,this.config);else if(AeroGear.isArray(e))for(t=0;e.length>t;t++)r=e[t],"string"==typeof r?n[r]=AeroGear[this.lib].adapters[this.type](r,this.config):r.name&&(r.settings=AeroGear.extend(r.settings||{},this.config),r.settings.recordId=r.settings.recordId||r.recordId
 ,n[r.name]=AeroGear[this.lib].adapters[r.type||this.type](r.name,r.settings));else{if(!e.name)return this;e.settings=AeroGear.extend(e.settings||{},this.config),e.settings.recordId=e.settings.recordId||e.recordId,n[e.name]=AeroGear[this.lib].adapters[e.type||this.type](e.name,e.settings)}return this[this.collectionName]=n,this},this.remove=function(e){var t,r,n=this[this.collectionName]||{};if("string"==typeof e)delete n[e];else if(AeroGear.isArray(e))for(t=0;e.length>t;t++)r=e[t],"string"==typeof r?delete n[r]:delete n[r.name];else e&&delete n[e.name];return this[this.collectionName]=n,this}},AeroGear.isArray=function(e){return"[object Array]"==={}.toString.call(e)},AeroGear.extend=function(e,t){var r;for(r in t)e[r]=t[r];return e},function(){function e(e,t,r){var n=t&&r||0,a=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){16>a&&(t[n+a++]=g[e])});16>a;)t[n+a++]=0;return t}function t(e,t){var r=t||0,n=p;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[
 e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}function r(e,r,n){var a=r&&n||0,i=r||[];e=e||{};var s=null!=e.clockseq?e.clockseq:v,o=null!=e.msecs?e.msecs:(new Date).getTime(),c=null!=e.nsecs?e.nsecs:x+1,u=o-A+(c-x)/1e4;if(0>u&&null==e.clockseq&&(s=16383&s+1),(0>u||o>A)&&null==e.nsecs&&(c=0),c>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");A=o,x=c,v=s,o+=122192928e5;var h=(1e4*(268435455&o)+c)%4294967296;i[a++]=255&h>>>24,i[a++]=255&h>>>16,i[a++]=255&h>>>8,i[a++]=255&h;var f=268435455&1e4*(o/4294967296);i[a++]=255&f>>>8,i[a++]=255&f,i[a++]=16|15&f>>>24,i[a++]=255&f>>>16,i[a++]=128|s>>>8,i[a++]=255&s;for(var l=e.node||b,d=0;6>d;d++)i[a+d]=l[d];return r?r:t(i)}function n(e,r,n){var a=r&&n||0;"string"==typeof e&&(r="binary"==e?new d(16):null,e=null),e=e||{};var i=e.random||(e.rng||l)();if(i[6]=64|15&i[6],i[8]=128|63&i[8],r)for(var s=0;16>s;s++)r[a+s]=i[s];return r||t(i)}var a,i,s,o=this,c=Arra
 y(16);if(a=function(){for(var e,e,t=c,r=0,r=0;16>r;r++)0==(3&r)&&(e=4294967296*Math.random()),t[r]=255&e>>>((3&r)<<3);return t},o.crypto&&crypto.getRandomValues){var u=new Uint32Array(4);s=function(){crypto.getRandomValues(u);for(var e=0;16>e;e++)c[e]=255&u[e>>2]>>>8*(3&e);return c}}try{var h=require("crypto").randomBytes;i=h&&function(){return h(16)}}catch(f){}for(var l=i||s||a,d="function"==typeof Buffer?Buffer:Array,p=[],g={},m=0;256>m;m++)p[m]=(m+256).toString(16).substr(1),g[p[m]]=m;var y=l(),b=[1|y[0],y[1],y[2],y[3],y[4],y[5]],v=16383&(y[6]<<8|y[7]),A=0,x=0,S=n;if(S.v1=r,S.v4=n,S.parse=e,S.unparse=t,S.BufferClass=d,S.mathRNG=a,S.nodeRNG=i,S.whatwgRNG=s,"undefined"!=typeof module)module.exports=S;else{var G=o.uuid;S.noConflict=function(){return o.uuid=G,S},o.uuid=S}}(),function(){var r=e!==t?e:exports,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=function(){try{document.createElement("$")}catch(e){return e}}();r.btoa||(r.btoa=function(e){for(var t,r,i=
 0,s=n,o="";e.charAt(0|i)||(s="=",i%1);o+=s.charAt(63&t>>8-8*(i%1))){if(r=e.charCodeAt(i+=.75),r>255)throw a;t=t<<8|r}return o}),r.atob||(r.atob=function(e){if(e=e.replace(/=+$/,""),1==e.length%4)throw a;for(var t,r,i=0,s=0,o="";r=e.charAt(s++);~r&&(t=i%4?64*t+r:r,i++%4)?o+=String.fromCharCode(255&t>>(6&-2*i)):0)r=n.indexOf(r);return o})}();var o=void 0,c=!0,u=!1,h={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};"undefined"!=typeof module&&module.exports&&(module.exports=h),h.cipher.aes=function(e){this.n[0][0][0]||this.K();var t,r,n,a,i=this.n[0][4],s=this.n[1];t=e.length;var o=1;if(4!==t&&6!==t&&8!
 ==t)throw new h.exception.invalid("invalid aes key size");for(this.c=[n=e.slice(0),a=[]],e=t;4*t+28>e;e++)r=n[e-1],(0===e%t||8===t&&4===e%t)&&(r=i[r>>>24]<<24^i[255&r>>16]<<16^i[255&r>>8]<<8^i[255&r],0===e%t&&(r=r<<8^r>>>24^o<<24,o=o<<1^283*(o>>7))),n[e]=n[e-t]^r;for(t=0;e;t++,e--)r=n[3&t?e:e-4],a[t]=4>=e||4>t?r:s[0][i[r>>>24]]^s[1][i[255&r>>16]]^s[2][i[255&r>>8]]^s[3][i[255&r]]},h.cipher.aes.prototype={encrypt:function(e){return r(this,e,0)},decrypt:function(e){return r(this,e,1)},n:[[[],[],[],[],[]],[[],[],[],[],[]]],K:function(){var e,t,r,n,a,i,s,o=this.n[0],c=this.n[1],u=o[4],h=c[4],f=[],l=[];for(e=0;256>e;e++)l[(f[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!u[t];t^=n||1,r=l[r]||1)for(i=r^r<<1^r<<2^r<<3^r<<4,i=99^(i>>8^255&i),u[t]=i,h[i]=t,a=f[e=f[n=f[t]]],s=16843009*a^65537*e^257*n^16843008*t,a=257*f[i]^16843008*i,e=0;4>e;e++)o[e][t]=a=a<<24^a>>>8,c[e][i]=s=s<<24^s>>>8;for(e=0;5>e;e++)o[e]=o[e].slice(0),c[e]=c[e].slice(0)}},h.bitArray={bitSlice:function(e,t,r){return e=h.bitArray.U(e.s
 lice(t/32),32-(31&t)).slice(1),r===o?e:h.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(31&-t-r);return(-32&(t+r-1^t)?e[0|t/32]<<32-n^e[0|t/32+1]>>>n:e[0|t/32]>>>n)&(1<<r)-1},concat:function(e,t){if(0===e.length||0===t.length)return e.concat(t);var r=e[e.length-1],n=h.bitArray.getPartial(r);return 32===n?e.concat(t):h.bitArray.U(t,n,0|r,e.slice(0,e.length-1))},bitLength:function(e){var t=e.length;return 0===t?0:32*(t-1)+h.bitArray.getPartial(e[t-1])},clamp:function(e,t){if(t>32*e.length)return e;e=e.slice(0,Math.ceil(t/32));var r=e.length;return t&=31,r>0&&t&&(e[r-1]=h.bitArray.partial(t,e[r-1]&2147483648>>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(h.bitArray.bitLength(e)!==h.bitArray.bitLength(t))return u;var r,n=0;for(r=0;e.length>r;r++)n|=e[r]^t[r];return 0===n},U:function(e,t,r,n){var a;for(a=0,n===o&&(n=[]);t>=32;t-=32)n.push(r),r=0;if(
 0===t)return n.concat(e);for(a=0;e.length>a;a++)n.push(r|e[a]>>>t),r=e[a]<<32-t;return a=e.length?e[e.length-1]:0,e=h.bitArray.getPartial(a),n.push(h.bitArray.partial(31&t+e,t+e>32?r:n.pop(),1)),n},ba:function(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]}},h.codec.utf8String={fromBits:function(e){var t,r,n="",a=h.bitArray.bitLength(e);for(t=0;a/8>t;t++)0===(3&t)&&(r=e[t/4]),n+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],n=0;for(t=0;e.length>t;t++)n=n<<8|e.charCodeAt(t),3===(3&t)&&(r.push(n),n=0);return 3&t&&r.push(h.bitArray.partial(8*(3&t),n)),r}},h.codec.hex={fromBits:function(e){var t,r="";for(t=0;e.length>t;t++)r+=((0|e[t])+0xf00000000000).toString(16).substr(4);return r.substr(0,h.bitArray.bitLength(e)/4)},toBits:function(e){var t,r,n=[];for(e=e.replace(/\s|0x/g,""),r=e.length,e+="00000000",t=0;e.length>t;t+=8)n.push(0^parseInt(e.substr(t,8),16));return h.bitArray.clamp(n,4*r)}},
 h.hash.sha256=function(e){this.c[0]||this.K(),e?(this.u=e.u.slice(0),this.p=e.p.slice(0),this.k=e.k):this.reset()},h.hash.sha256.hash=function(e){return(new h.hash.sha256).update(e).finalize()},h.hash.sha256.prototype={blockSize:512,reset:function(){return this.u=this.R.slice(0),this.p=[],this.k=0,this},update:function(e){"string"==typeof e&&(e=h.codec.utf8String.toBits(e));var t,r=this.p=h.bitArray.concat(this.p,e);for(t=this.k,e=this.k=t+h.bitArray.bitLength(e),t=-512&512+t;e>=t;t+=512)n(this,r.splice(0,16));return this},finalize:function(){var e,t=this.p,r=this.u,t=h.bitArray.concat(t,[h.bitArray.partial(1,1)]);for(e=t.length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this.k/4294967296)),t.push(0|this.k);t.length;)n(this,t.splice(0,16));return this.reset(),r},R:[],c:[],K:function(){function e(e){return 0|4294967296*(e-Math.floor(e))}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;n>=t*t;t++)if(0===n%t)continue e;8>r&&(this.R[r]=e(Math.pow(n,.5))),this.c[r]=e(Math.pow(n,1/3)),r++}}},h.mode
 .gcm={name:"gcm",encrypt:function(e,t,r,n,a){var i=t.slice(0);return t=h.bitArray,n=n||[],e=h.mode.gcm.O(c,e,i,n,r,a||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,n,a){var i=t.slice(0),s=h.bitArray,o=s.bitLength(i);if(a=a||128,n=n||[],o>=a?(t=s.bitSlice(i,o-a),i=s.bitSlice(i,0,o-a)):(t=i,i=[]),e=h.mode.gcm.O(u,e,i,n,r,a),!s.equal(e.tag,t))throw new h.exception.corrupt("gcm: tag doesn't match");return e.data},aa:function(e,t){var r,n,a,i,s,o=h.bitArray.ba;for(a=[0,0,0,0],i=t.slice(0),r=0;128>r;r++){for((n=0!==(e[Math.floor(r/32)]&1<<31-r%32))&&(a=o(a,i)),s=0!==(1&i[3]),n=3;n>0;n--)i[n]=i[n]>>>1|(1&i[n-1])<<31;i[0]>>>=1,s&&(i[0]^=-520093696)}return a},j:function(e,t,r){var n,a=r.length;for(t=t.slice(0),n=0;a>n;n+=4)t[0]^=4294967295&r[n],t[1]^=4294967295&r[n+1],t[2]^=4294967295&r[n+2],t[3]^=4294967295&r[n+3],t=h.mode.gcm.aa(t,e);return t},O:function(e,t,r,n,a,i){var s,o,c,u,f,l,d,p,g=h.bitArray;for(l=r.length,d=g.bitLength(r),p=g.bitLength(n),o=g.bitLength(a),s=t.encrypt([0,0,0,
 0]),96===o?(a=a.slice(0),a=g.concat(a,[1])):(a=h.mode.gcm.j(s,[0,0,0,0],a),a=h.mode.gcm.j(s,a,[0,0,Math.floor(o/4294967296),4294967295&o])),o=h.mode.gcm.j(s,[0,0,0,0],n),f=a.slice(0),n=o.slice(0),e||(n=h.mode.gcm.j(s,o,r)),u=0;l>u;u+=4)f[3]++,c=t.encrypt(f),r[u]^=c[0],r[u+1]^=c[1],r[u+2]^=c[2],r[u+3]^=c[3];return r=g.clamp(r,d),e&&(n=h.mode.gcm.j(s,o,r)),e=[Math.floor(p/4294967296),4294967295&p,Math.floor(d/4294967296),4294967295&d],n=h.mode.gcm.j(s,n,e),c=t.encrypt(a),n[0]^=c[0],n[1]^=c[1],n[2]^=c[2],n[3]^=c[3],{tag:g.bitSlice(n,0,i),data:r}}},h.misc.hmac=function(e,t){this.Q=t=t||h.hash.sha256;var r,n=[[],[]],a=t.prototype.blockSize/32;for(this.q=[new t,new t],e.length>a&&(e=t.hash(e)),r=0;a>r;r++)n[0][r]=909522486^e[r],n[1][r]=1549556828^e[r];this.q[0].update(n[0]),this.q[1].update(n[1])},h.misc.hmac.prototype.encrypt=h.misc.hmac.prototype.mac=function(e){return e=new this.Q(this.q[0]).update(e).finalize(),new this.Q(this.q[1]).update(e).finalize()},h.misc.pbkdf2=function(e,t,r,n
 ,a){if(r=r||1e3,0>n||0>r)throw h.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=h.codec.utf8String.toBits(e)),"string"==typeof t&&(t=h.codec.utf8String.toBits(t)),a=a||h.misc.hmac,e=new a(e);var i,s,o,c,u=[],f=h.bitArray;for(c=1;(n||1)>32*u.length;c++){for(a=i=e.encrypt(f.concat(t,[c])),s=1;r>s;s++)for(i=e.encrypt(i),o=0;i.length>o;o++)a[o]^=i[o];u=u.concat(a)}return n&&(u=f.clamp(u,n)),u},h.prng=function(e){this.e=[new h.hash.sha256],this.l=[0],this.L=0,this.B={},this.J=0,this.N={},this.T=this.g=this.m=this.$=0,this.c=[0,0,0,0,0,0,0,0],this.h=[0,0,0,0],this.H=o,this.I=e,this.s=u,this.F={progress:{},seeded:{}},this.o=this.Z=0,this.C=1,this.D=2,this.X=65536,this.M=[0,48,64,96,128,192,256,384,512,768,1024],this.Y=3e4,this.W=80},h.prng.prototype={randomWords:function(e,t){var r,n=[];r=this.isReady(t);var a;if(r===this.o)throw new h.exception.notReady("generator isn't seeded");if(r&this.D){r=!(r&this.C),a=[];var o,c=0;for(this.T=a[0]=(new Date).valueOf()+this.Y,o=0
 ;16>o;o++)a.push(0|4294967296*Math.random());for(o=0;this.e.length>o&&(a=a.concat(this.e[o].finalize()),c+=this.l[o],this.l[o]=0,!(!r&&this.L&1<<o));o++);for(this.L>=1<<this.e.length&&(this.e.push(new h.hash.sha256),this.l.push(0)),this.g-=c,c>this.m&&(this.m=c),this.L++,this.c=h.hash.sha256.hash(this.c.concat(a)),this.H=new h.cipher.aes(this.c),r=0;4>r&&(this.h[r]=0|this.h[r]+1,!this.h[r]);r++);}for(r=0;e>r;r+=4)0===(r+1)%this.X&&i(this),a=s(this),n.push(a[0],a[1],a[2],a[3]);return i(this),n.slice(0,e)},setDefaultParanoia:function(e){this.I=e},addEntropy:function(e,t,r){r=r||"user";var n,i,s=(new Date).valueOf(),c=this.B[r],u=this.isReady(),f=0;switch(n=this.N[r],n===o&&(n=this.N[r]=this.$++),c===o&&(c=this.B[r]=0),this.B[r]=(this.B[r]+1)%this.e.length,typeof e){case"number":t===o&&(t=1),this.e[c].update([n,this.J++,1,t,s,1,0|e]);break;case"object":if(r=Object.prototype.toString.call(e),"[object Uint32Array]"===r){for(i=[],r=0;e.length>r;r++)i.push(e[r]);e=i}else for("[object Array
 ]"!==r&&(f=1),r=0;e.length>r&&!f;r++)"number"!=typeof e[r]&&(f=1);if(!f){if(t===o)for(r=t=0;e.length>r;r++)for(i=e[r];i>0;)t++,i>>>=1;this.e[c].update([n,this.J++,2,t,s,e.length].concat(e))}break;case"string":t===o&&(t=e.length),this.e[c].update([n,this.J++,3,t,s,e.length]),this.e[c].update(e);break;default:f=1}if(f)throw new h.exception.bug("random: addEntropy only supports number, array of numbers or string");this.l[c]+=t,this.g+=t,u===this.o&&(this.isReady()!==this.o&&a("seeded",Math.max(this.m,this.g)),a("progress",this.getProgress()))},isReady:function(e){return e=this.M[e!==o?e:this.I],this.m&&this.m>=e?this.l[0]>this.W&&(new Date).valueOf()>this.T?this.D|this.C:this.C:this.g>=e?this.D|this.o:this.o},getProgress:function(e){return e=this.M[e?e:this.I],this.m>=e?1:this.g>e?1:this.g/e},startCollectors:function(){if(!this.s){if(e.addEventListener)e.addEventListener("load",this.v,u),e.addEventListener("mousemove",this.w,u);else{if(!document.attachEvent)throw new h.exception.bug("c
 an't attach event");document.attachEvent("onload",this.v),document.attachEvent("onmousemove",this.w)}this.s=c}},stopCollectors:function(){this.s&&(e.removeEventListener?(e.removeEventListener("load",this.v,u),e.removeEventListener("mousemove",this.w,u)):e.detachEvent&&(e.detachEvent("onload",this.v),e.detachEvent("onmousemove",this.w)),this.s=u)},addEventListener:function(e,t){this.F[e][this.Z++]=t},removeEventListener:function(e,t){var r,n,a=this.F[e],i=[];for(n in a)a.hasOwnProperty(n)&&a[n]===t&&i.push(n);for(r=0;i.length>r;r++)n=i[r],delete a[n]},w:function(e){h.random.addEntropy([e.x||e.clientX||e.offsetX||0,e.y||e.clientY||e.offsetY||0],2,"mouse")},v:function(){h.random.addEntropy((new Date).valueOf(),2,"loadtime")}},h.random=new h.prng(6);try{if("undefined"!=typeof module&&module.exports){var f=require("crypto").randomBytes(128);h.random.addEntropy(f,1024,"crypto['randomBytes']")}else if(e&&e.crypto&&e.crypto.getRandomValues){var l=new Uint32Array(32);e.crypto.getRandomValues
 (l),h.random.addEntropy(l,1024,"crypto['getRandomValues']")}}catch(d){}h.bn=function(e){this.initWith(e)},h.bn.prototype={radix:24,maxMul:8,d:h.bn,copy:function(){return new this.d(this)},initWith:function(e){var t,r=0;switch(typeof e){case"object":this.limbs=e.limbs.slice(0);break;case"number":this.limbs=[e],this.normalize();break;case"string":for(e=e.replace(/^0x/,""),this.limbs=[],t=this.radix/4,r=0;e.length>r;r+=t)this.limbs.push(parseInt(e.substring(Math.max(e.length-r-t,0),e.length-r),16));break;default:this.limbs=[0]}return this},equals:function(e){"number"==typeof e&&(e=new this.d(e));var t,r=0;for(this.fullReduce(),e.fullReduce(),t=0;this.limbs.length>t||e.limbs.length>t;t++)r|=this.getLimb(t)^e.getLimb(t);return 0===r},getLimb:function(e){return e>=this.limbs.length?0:this.limbs[e]},greaterEquals:function(e){"number"==typeof e&&(e=new this.d(e));var t,r,n,a=0,i=0;for(t=Math.max(this.limbs.length,e.limbs.length)-1;t>=0;t--)r=this.getLimb(t),n=e.getLimb(t),i|=n-r&~a,a|=r-n&~
 i;return(i|~a)>>>31},toString:function(){this.fullReduce();var e,t,r="",n=this.limbs;for(e=0;this.limbs.length>e;e++){for(t=n[e].toString(16);this.limbs.length-1>e&&6>t.length;)t="0"+t;r=t+r}return"0x"+r},addM:function(e){"object"!=typeof e&&(e=new this.d(e));var t=this.limbs,r=e.limbs;for(e=t.length;r.length>e;e++)t[e]=0;for(e=0;r.length>e;e++)t[e]+=r[e];return this},doubleM:function(){var e,t,r=0,n=this.radix,a=this.radixMask,i=this.limbs;for(e=0;i.length>e;e++)t=i[e],t=t+t+r,i[e]=t&a,r=t>>n;return r&&i.push(r),this},halveM:function(){var e,t,r=0,n=this.radix,a=this.limbs;for(e=a.length-1;e>=0;e--)t=a[e],a[e]=t+r>>1,r=(1&t)<<n;return a[a.length-1]||a.pop(),this},subM:function(e){"object"!=typeof e&&(e=new this.d(e));var t=this.limbs,r=e.limbs;for(e=t.length;r.length>e;e++)t[e]=0;for(e=0;r.length>e;e++)t[e]-=r[e];return this},mod:function(e){var t=!this.greaterEquals(new h.bn(0));e=new h.bn(e).normalize();var r=new h.bn(this).normalize(),n=0;for(t&&(r=new h.bn(0).subM(r).normalize(
 ));r.greaterEquals(e);n++)e.doubleM();for(t&&(r=e.sub(r).normalize());n>0;n--)e.halveM(),r.greaterEquals(e)&&r.subM(e).normalize();return r.trim()},inverseMod:function(e){var t,r=new h.bn(1),n=new h.bn(0),a=new h.bn(this),i=new h.bn(e),s=1;if(!(1&e.limbs[0]))throw new h.exception.invalid("inverseMod: p must be odd");do for(1&a.limbs[0]&&(a.greaterEquals(i)||(t=a,a=i,i=t,t=r,r=n,n=t),a.subM(i),a.normalize(),r.greaterEquals(n)||r.addM(e),r.subM(n)),a.halveM(),1&r.limbs[0]&&r.addM(e),r.normalize(),r.halveM(),t=s=0;a.limbs.length>t;t++)s|=a.limbs[t];while(s);if(!i.equals(1))throw new h.exception.invalid("inverseMod: p and x must be relatively prime");return n},add:function(e){return this.copy().addM(e)},sub:function(e){return this.copy().subM(e)},mul:function(e){"number"==typeof e&&(e=new this.d(e));var t,r,n=this.limbs,a=e.limbs,i=n.length,s=a.length,o=new this.d,c=o.limbs,u=this.maxMul;for(t=0;this.limbs.length+e.limbs.length+1>t;t++)c[t]=0;for(t=0;i>t;t++){for(r=n[t],e=0;s>e;e++)c[t+
 e]+=r*a[e];--u||(u=this.maxMul,o.cnormalize())}return o.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(e){"number"==typeof e?e=[e]:e.limbs!==o&&(e=e.normalize().limbs);var t,r,n=new this.d(1),a=this;for(t=0;e.length>t;t++)for(r=0;this.radix>r;r++)e[t]&1<<r&&(n=n.mul(a)),a=a.square();return n},mulmod:function(e,t){return this.mod(t).mul(e.mod(t)).mod(t)},powermod:function(e,t){for(var r=new h.bn(1),n=new h.bn(this),a=new h.bn(e);1&a.limbs[0]&&(r=r.mulmod(n,t)),a.halveM(),!a.equals(0);)n=n.mulmod(n,t);return r.normalize().reduce()},trim:function(){var e,t=this.limbs;do e=t.pop();while(t.length&&0===e);return t.push(e),this},reduce:function(){return this},fullReduce:function(){return this.normalize()},normalize:function(){var e,t,r=0,n=this.ipv,a=this.limbs,i=a.length,s=this.radixMask;for(e=0;i>e||0!==r&&-1!==r;e++)r=(a[e]||0)+r,t=a[e]=r&s,r=(r-t)*n;return-1===r&&(a[e-1]-=this.placeVal),this},cnormalize:function(){var e,t,r=0,n=this.ipv,a=this.limbs,i=a.
 length,s=this.radixMask;for(e=0;i-1>e;e++)r=a[e]+r,t=a[e]=r&s,r=(r-t)*n;return a[e]+=r,this},toBits:function(e){this.fullReduce(),e=e||this.exponent||this.bitLength();var t=Math.floor((e-1)/24),r=h.bitArray,n=[r.partial((-8&e+7)%this.radix||this.radix,this.getLimb(t))];for(t--;t>=0;t--)n=r.concat(n,[r.partial(Math.min(this.radix,e),this.getLimb(t))]),e-=this.radix;return n},bitLength:function(){this.fullReduce();for(var e=this.radix*(this.limbs.length-1),t=this.limbs[this.limbs.length-1];t;t>>>=1)e++;return-8&e+7}},h.bn.fromBits=function(e){var t=new this,r=[],n=h.bitArray,a=this.prototype,i=Math.min(this.bitLength||4294967296,n.bitLength(e)),s=i%a.radix||a.radix;for(r[0]=n.extract(e,0,s);i>s;s+=a.radix)r.unshift(n.extract(e,s,a.radix));return t.limbs=r,t},h.bn.prototype.ipv=1/(h.bn.prototype.placeVal=Math.pow(2,h.bn.prototype.radix)),h.bn.prototype.radixMask=(1<<h.bn.prototype.radix)-1,h.bn.pseudoMersennePrime=function(e,t){function r(e){this.initWith(e)}var n,a,i=r.prototype=new h
 .bn;for(n=i.modOffset=Math.ceil(a=e/i.radix),i.exponent=e,i.offset=[],i.factor=[],i.minOffset=n,i.fullMask=0,i.fullOffset=[],i.fullFactor=[],i.modulus=r.modulus=new h.bn(Math.pow(2,e)),i.fullMask=0|-Math.pow(2,e%i.radix),n=0;t.length>n;n++)i.offset[n]=Math.floor(t[n][0]/i.radix-a),i.fullOffset[n]=Math.ceil(t[n][0]/i.radix-a),i.factor[n]=t[n][1]*Math.pow(.5,e-t[n][0]+i.offset[n]*i.radix),i.fullFactor[n]=t[n][1]*Math.pow(.5,e-t[n][0]+i.fullOffset[n]*i.radix),i.modulus.addM(new h.bn(Math.pow(2,t[n][0])*t[n][1])),i.minOffset=Math.min(i.minOffset,-i.offset[n]);return i.d=r,i.modulus.cnormalize(),i.reduce=function(){var e,t,r,n,a=this.modOffset,i=this.limbs,s=this.offset,o=this.offset.length,c=this.factor;for(e=this.minOffset;i.length>a;){for(r=i.pop(),n=i.length,t=0;o>t;t++)i[n+s[t]]-=c[t]*r;e--,e||(i.push(0),this.cnormalize(),e=this.minOffset)}return this.cnormalize(),this},i.V=-1===i.fullMask?i.reduce:function(){var e,t,r=this.limbs,n=r.length-1;if(this.reduce(),n===this.modOffset-1){f
 or(t=r[n]&this.fullMask,r[n]-=t,e=0;this.fullOffset.length>e;e++)r[n+this.fullOffset[e]]-=this.fullFactor[e]*t;this.normalize()}},i.fullReduce=function(){var e,t;for(this.V(),this.addM(this.modulus),this.addM(this.modulus),this.normalize(),this.V(),t=this.limbs.length;this.modOffset>t;t++)this.limbs[t]=0;for(e=this.greaterEquals(this.modulus),t=0;this.limbs.length>t;t++)this.limbs[t]-=this.modulus.limbs[t]*e;return this.cnormalize(),this},i.inverse=function(){return this.power(this.modulus.sub(2))},r.fromBits=h.bn.fromBits,r};var p=h.bn.pseudoMersennePrime;h.bn.prime={p127:p(127,[[0,-1]]),p25519:p(255,[[0,-19]]),p192k:p(192,[[32,-1],[12,-1],[8,-1],[7,-1],[6,-1],[3,-1],[0,-1]]),p224k:p(224,[[32,-1],[12,-1],[11,-1],[9,-1],[7,-1],[4,-1],[1,-1],[0,-1]]),p256k:p(256,[[32,-1],[9,-1],[8,-1],[7,-1],[6,-1],[4,-1],[0,-1]]),p192:p(192,[[0,-1],[64,-1]]),p224:p(224,[[0,1],[96,-1]]),p256:p(256,[[0,-1],[96,1],[192,1],[224,-1]]),p384:p(384,[[0,-1],[32,1],[96,-1],[128,-1]]),p521:p(521,[[0,-1]])},h.b
 n.random=function(e,t){"object"!=typeof e&&(e=new h.bn(e));for(var r,n,a=e.limbs.length,i=e.limbs[a-1]+1,s=new h.bn;;){do r=h.random.randomWords(a,t),0>r[a-1]&&(r[a-1]+=4294967296);while(Math.floor(r[a-1]/i)===Math.floor(4294967296/i));for(r[a-1]%=i,n=0;a-1>n;n++)r[n]&=e.radixMask;if(s.limbs=r,!s.greaterEquals(e))return s}},h.ecc={},h.ecc.point=function(e,t,r){t===o?this.isIdentity=c:(this.x=t,this.y=r,this.isIdentity=u),this.curve=e},h.ecc.point.prototype={toJac:function(){return new h.ecc.pointJac(this.curve,this.x,this.y,new this.curve.field(1))},mult:function(e){return this.toJac().mult(e,this).toAffine()},mult2:function(e,t,r){return this.toJac().mult2(e,this,t,r).toAffine()},multiples:function(){var e,t,r;if(this.S===o)for(r=this.toJac().doubl(),e=this.S=[new h.ecc.point(this.curve),this,r.toAffine()],t=3;16>t;t++)r=r.add(this),e.push(r.toAffine());return this.S},isValid:function(){return this.y.square().equals(this.curve.b.add(this.x.mul(this.curve.a.add(this.x.square()))))},
 toBits:function(){return h.bitArray.concat(this.x.toBits(),this.y.toBits())}},h.ecc.pointJac=function(e,t,r,n){t===o?this.isIdentity=c:(this.x=t,this.y=r,this.z=n,this.isIdentity=u),this.curve=e},h.ecc.pointJac.prototype={add:function(e){var t,r,n,a;if(this.curve!==e.curve)throw"sjcl['ecc']['add'](): Points must be on the same curve to add them!";return this.isIdentity?e.toJac():e.isIdentity?this:(t=this.z.square(),r=e.x.mul(t).subM(this.x),r.equals(0)?this.y.equals(e.y.mul(t.mul(this.z)))?this.doubl():new h.ecc.pointJac(this.curve):(t=e.y.mul(t.mul(this.z)).subM(this.y),n=r.square(),e=t.square(),a=r.square().mul(r).addM(this.x.add(this.x).mul(n)),e=e.subM(a),t=this.x.mul(n).subM(e).mul(t),n=this.y.mul(r.square().mul(r)),t=t.subM(n),r=this.z.mul(r),new h.ecc.pointJac(this.curve,e,t,r)))},doubl:function(){if(this.isIdentity)return this;var e=this.y.square(),t=e.mul(this.x.mul(4)),r=e.square().mul(8),e=this.z.square(),n=""+this.curve.a==""+new h.bn(-3)?this.x.sub(e).mul(3).mul(this.x.
 add(e)):this.x.square().mul(3).add(e.square().mul(this.curve.a)),e=n.square().subM(t).subM(t),t=t.sub(e).mul(n).subM(r),r=this.y.add(this.y).mul(this.z);return new h.ecc.pointJac(this.curve,e,t,r)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new h.ecc.point(this.curve);var e=this.z.inverse(),t=e.square();return new h.ecc.point(this.curve,this.x.mul(t).fullReduce(),this.y.mul(t.mul(e)).fullReduce())},mult:function(e,t){"number"==typeof e?e=[e]:e.limbs!==o&&(e=e.normalize().limbs);var r,n,a=new h.ecc.point(this.curve).toJac(),i=t.multiples();for(r=e.length-1;r>=0;r--)for(n=h.bn.prototype.radix-4;n>=0;n-=4)a=a.doubl().doubl().doubl().doubl().add(i[15&e[r]>>n]);return a},mult2:function(e,t,r,n){"number"==typeof e?e=[e]:e.limbs!==o&&(e=e.normalize().limbs),"number"==typeof r?r=[r]:r.limbs!==o&&(r=r.normalize().limbs);var a,i=new h.ecc.point(this.curve).toJac();t=t.multiples();var s,c,u=n.multiples();for(n=Math.max(e.length,r.length)-1;n>=0;n--)for(s=0|e[n],c=0|r[n],a=
 h.bn.prototype.radix-4;a>=0;a-=4)i=i.doubl().doubl().doubl().doubl().add(t[15&s>>a]).add(u[15&c>>a]);return i},isValid:function(){var e=this.z.square(),t=e.square(),e=t.mul(e);return this.y.square().equals(this.curve.b.mul(e).add(this.x.mul(this.curve.a.mul(t).add(this.x.square()))))}},h.ecc.curve=function(e,t,r,n,a,i){this.field=e,this.r=new h.bn(t),this.a=new e(r),this.b=new e(n),this.G=new h.ecc.point(this,new e(a),new e(i))},h.ecc.curve.prototype.fromBits=function(e){var t=h.bitArray,r=-8&this.field.prototype.exponent+7;if(e=new h.ecc.point(this,this.field.fromBits(t.bitSlice(e,0,r)),this.field.fromBits(t.bitSlice(e,r,2*r))),!e.isValid())throw new h.exception.corrupt("not on the curve!");return e},h.ecc.curves={c192:new h.ecc.curve(h.bn.prime.p192,"0xffffffffffffffffffffffff99def836146bc9b1b4d22831",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new h.ecc.curv
 e(h.bn.prime.p224,"0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new h.ecc.curve(h.bn.prime.p256,"0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new h.ecc.curve(h.bn.prime.p384,"0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60
 b1ce1d7e819d7a431d7c90ea0e5f"),k192:new h.ecc.curve(h.bn.prime.p192k,"0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d",0,3,"0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d","0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"),k224:new h.ecc.curve(h.bn.prime.p224k,"0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7",0,5,"0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c","0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5"),k256:new h.ecc.curve(h.bn.prime.p256k,"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",0,7,"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},h.ecc.P=function(e){h.ecc[e]={publicKey:function(e,t){this.f=e,this.i=e.r.bitLength(),this.A=t instanceof Array?e.fromBits(t):t,this.get=function(){var e=this.A.toBits(),t=h.bitArray.bitLength(e),r=h.bitArray.bitSlice(e,0,t/2),e=h.bitArray.bitSlice(e,t/2);return{x:r,y:e}}},secretKey:f
 unction(e,t){this.f=e,this.i=e.r.bitLength(),this.t=t,this.get=function(){return this.t.toBits()}},generateKeys:function(t,r,n){if(t===o&&(t=256),"number"==typeof t&&(t=h.ecc.curves["c"+t],t===o))throw new h.exception.invalid("no such curve");return n===o&&(n=h.bn.random(t.r,r)),r=t.G.mult(n),{pub:new h.ecc[e].publicKey(t,r),sec:new h.ecc[e].secretKey(t,n)}}}},h.ecc.P("elGamal"),h.ecc.elGamal.publicKey.prototype={kem:function(e){e=h.bn.random(this.f.r,e);var t=this.f.G.mult(e).toBits();return{key:h.hash.sha256.hash(this.A.mult(e).toBits()),tag:t}}},h.ecc.elGamal.secretKey.prototype={unkem:function(e){return h.hash.sha256.hash(this.f.fromBits(e).mult(this.t).toBits())},dh:function(e){return h.hash.sha256.hash(e.A.mult(this.t).toBits())}},h.ecc.P("ecdsa"),h.ecc.ecdsa.secretKey.prototype={sign:function(e,t,r,n){h.bitArray.bitLength(e)>this.i&&(e=h.bitArray.clamp(e,this.i));var a=this.f.r,i=a.bitLength();return n=n||h.bn.random(a.sub(1),t).add(1),t=this.f.G.mult(n).x.mod(a),e=h.bn.fromB
 its(e).add(t.mul(this.t)),r=r?e.inverseMod(a).mul(n).mod(a):e.mul(n.inverseMod(a)).mod(a),h.bitArray.concat(t.toBits(i),r.toBits(i))}},h.ecc.ecdsa.publicKey.prototype={verify:function(e,t,r){h.bitArray.bitLength(e)>this.i&&(e=h.bitArray.clamp(e,this.i));var n=h.bitArray,a=this.f.r,i=this.i,s=h.bn.fromBits(n.bitSlice(t,0,i)),n=h.bn.fromBits(n.bitSlice(t,i,2*i)),u=r?n:n.inverseMod(a),i=h.bn.fromBits(e).mul(u).mod(a),u=s.mul(u).mod(a),i=this.f.G.mult2(i,u,this.A).x;if(s.equals(0)||n.equals(0)||s.greaterEquals(a)||n.greaterEquals(a)||!i.equals(s)){if(r===o)return this.verify(e,t,c);throw new h.exception.corrupt("signature didn't check out")}return c}},AeroGear.Pipeline=function(e){return this instanceof AeroGear.Pipeline?(AeroGear.Core.call(this),this.config=e||{},this.lib="Pipeline",this.type=e?e.type||"Rest":"Rest",this.collectionName="pipes",this.add(e),t):new AeroGear.Pipeline(e)},AeroGear.Pipeline.prototype=AeroGear.Core,AeroGear.Pipeline.constructor=AeroGear.Pipeline,AeroGear.Pipe
 line.adapters={},AeroGear.Pipeline.adapters.Rest=function(e,r){if(!(this instanceof AeroGear.Pipeline.adapters.Rest))return new AeroGear.Pipeline.adapters.Rest(e,r);r=r||{};var n=r.endpoint||e,a={url:r.baseURL?r.baseURL+n:n,contentType:r.contentType||"application/json",dataType:r.dataType||"json",xhrFields:r.xhrFields},i=r.recordId||"id",s=r.authenticator||null,o=r.authorizer||null,c=r.pageConfig,u=r.timeout?1e3*r.timeout:6e4;this.getAjaxSettings=function(){return a},this.getAuthenticator=function(){return s},this.getAuthorizer=function(){return o},this.getRecordId=function(){return i},this.getTimeout=function(){return u},this.getPageConfig=function(){return c},this.updatePageConfig=function(e,t){t?(c={},c.metadataLocation=e.metadataLocation?e.metadataLocation:"webLinking",c.previousIdentifier=e.previousIdentifier?e.previousIdentifier:"previous",c.nextIdentifier=e.nextIdentifier?e.nextIdentifier:"next",c.parameterProvider=e.parameterProvider?e.parameterProvider:null):jQuery.extend(c
 ,e)},c&&this.updatePageConfig(c,!0),this.webLinkingPageParser=function(e){var r,n,a,i,s,o={};n=e.getResponseHeader("Link").split(",");
-for(var u in n){r=n[u].trim().split(";");for(var h in r)a=r[h].trim(),0===a.indexOf("<")&&a.lastIndexOf(">")===r[h].length-1?i=a.substr(1,a.length-2).split("?")[1]:0===a.indexOf("rel=")&&(a.indexOf(c.previousIdentifier)>=0?s=c.previousIdentifier:a.indexOf(c.nextIdentifier)>=0&&(s=c.nextIdentifier));s&&(o[s]=i,s=t)}return o},this.headerPageParser=function(e){var t=e.getResponseHeader(c.previousIdentifier),r=e.getResponseHeader(c.nextIdentifier),n={},a={};return c.parameterProvider?(n=c.parameterProvider(e),a[c.previousIdentifier]=n[c.previousIdentifier],a[c.nextIdentifier]=n[c.nextIdentifier]):(a[c.previousIdentifier]=t?t.split("?")[1]:null,a[c.nextIdentifier]=r?r.split("?")[1]:null),a},this.bodyPageParser=function(e){var t={},r={};return c.parameterProvider?(r=c.parameterProvider(e),t[c.previousIdentifier]=r[c.previousIdentifier],t[c.nextIdentifier]=r[c.nextIdentifier]):(t[c.previousIdentifier]=e[c.previousIdentifier],t[c.nextIdentifier]=e[c.nextIdentifier]),t},this.formatJSONError=
 function(e){if("json"===this.getAjaxSettings().dataType)try{e.responseJSON=JSON.parse(e.responseText)}catch(t){}return e}},AeroGear.Pipeline.adapters.Rest.prototype.read=function(e){var r,n,a,i,s=this,o=this.getRecordId(),c=this.getAjaxSettings(),u=this.getPageConfig();if(e=e?e:{},e.query=e.query?e.query:{},r=e[o]?c.url+"/"+e[o]:c.url,u&&e.paging!==!1){e.paging||(e.paging={offset:e.offsetValue||0,limit:e.limitValue||10}),e.query=e.query||{};for(var h in e.paging)e.query[h]=e.paging[h]}return n=function(r,n,a){var i;u&&e.paging!==!1&&(i=s[u.metadataLocation+"PageParser"]("body"===u.metadataLocation?r:a),["previous","next"].forEach(function(n){r[n]=function(e,r,n){return function(a){return n.paging=!0,n.offsetValue=n.limitValue=t,n.query=r,n.success=a&&a.success?a.success:n.success,n.error=a&&a.error?a.error:n.error,e.read(n)}}(s,i[u[n+"Identifier"]],e)})),e.success&&e.success.apply(this,arguments)},a=function(t){t=s.formatJSONError(t),e.error&&e.error.apply(this,arguments)},i={type:"
 GET",data:e.query,success:n,error:a,url:r,statusCode:e.statusCode,complete:e.complete,headers:e.headers,timeout:this.getTimeout()},e.jsonp&&(i.dataType="jsonp",i.jsonp=e.jsonp.callback?e.jsonp.callback:"callback",e.jsonp.customCallback&&(i.jsonpCallback=e.jsonp.customCallback)),this.getAuthorizer()?this.getAuthorizer().execute(jQuery.extend({},e,i)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),i))},AeroGear.Pipeline.adapters.Rest.prototype.save=function(t,r){var n,a,i,s,o,c,u,h=this,f=this.getRecordId(),l=this.getAjaxSettings();if(t=t||{},r=r||{},n=t[f]?"PUT":"POST",a=t[f]?l.url+"/"+t[f]:l.url,i=function(){r.success&&r.success.apply(this,arguments)},s=function(e){e=h.formatJSONError(e),r.error&&r.error.apply(this,arguments)},o=jQuery.extend({},l,{data:t,type:n,url:a,success:i,error:s,statusCode:r.statusCode,complete:r.complete,headers:r.headers,timeout:this.getTimeout()}),"FormData"in e){c=new FormData;for(u in t)c.append(u,t[u]),(t[u]instanceof File||t[u]instanceof Blob)&&(o
 .contentType=!1,o.processData=!1);o.contentType===!1&&(o.data=c),o.xhr=function(){var e=jQuery.ajaxSettings.xhr();return e.upload&&e.upload.addEventListener("progress",function(){r.progress&&r.progress.apply(this,arguments)},!1),e}}return"application/json"===o.contentType&&o.data&&"string"!=typeof o.data&&(o.data=JSON.stringify(o.data)),this.getAuthorizer()?this.getAuthorizer().execute(jQuery.extend({},r,o)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),o))},AeroGear.Pipeline.adapters.Rest.prototype.remove=function(e,t){var r,n,a,i,s,o=this,c=this.getRecordId(),u=this.getAjaxSettings(),h="";return"string"==typeof e||"number"==typeof e?r=e:e&&e[c]?r=e[c]:e&&!t&&(t=e),t=t||{},h=r?"/"+r:"",n=u.url+h,a=function(){t.success&&t.success.apply(this,arguments)},i=function(e){e=o.formatJSONError(e),t.error&&t.error.apply(this,arguments)},s={type:"DELETE",url:n,success:a,error:i,statusCode:t.statusCode,complete:t.complete,headers:t.headers,timeout:this.getTimeout()},this.getAuthorizer()?
 this.getAuthorizer().execute(jQuery.extend({},t,s)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),s))},AeroGear.DataManager=function(e){return this instanceof AeroGear.DataManager?(this.add=function(e){e=e||{};var t,r,n,a,i;e=AeroGear.isArray(e)?e:[e],e=e.map(function(e){if(i=e.settings||{},n=i.fallback===!1?!1:!0,n&&(a=i.preferred?i.preferred:AeroGear.DataManager.preferred,"string"!=typeof e&&(r=e.type||"Memory",!(r in AeroGear.DataManager.validAdapters))))for(t=0;a.length>t;t++)if(a[t]in AeroGear.DataManager.validAdapters)return("IndexedDB"===r||"WebSQL"===r)&&(e.settings=AeroGear.extend(e.settings||{},{async:!0})),e.type=a[t],e;return e},this),AeroGear.Core.call(this),this.add(e),this.add=this._add},this._add=this.add,this.remove=function(e){AeroGear.Core.call(this),this.remove(e),this.remove=this._remove},this._remove=this.remove,this.lib="DataManager",this.type=e?e.type||"Memory":"Memory",this.collectionName="stores",this.add(e),t):new AeroGear.DataManager(e)},AeroGear.Da
 taManager.prototype=AeroGear.Core,AeroGear.DataManager.constructor=AeroGear.DataManager,AeroGear.DataManager.validAdapters={},AeroGear.DataManager.preferred=["IndexedDB","WebSQL","SessionLocal","Memory"],AeroGear.DataManager.validateAdapter=function(e,t){t.isValid()&&(AeroGear.DataManager.validAdapters[e]=t)},AeroGear.DataManager.adapters={},AeroGear.DataManager.STATUS_NEW=1,AeroGear.DataManager.STATUS_MODIFIED=2,AeroGear.DataManager.STATUS_REMOVED=0,AeroGear.DataManager.adapters.base=function(t,r){if(this instanceof AeroGear.DataManager.adapters.base)throw"Invalid instantiation of base class AeroGear.DataManager.adapters.base";r=r||{};var n=null,a=r.recordId?r.recordId:"id",i=r.crypto||{},s=i.options||{};this.getData=function(){return n||[]},this.setData=function(e){n=e},this.getRecordId=function(){return a},this.always=function(e,t,r){r&&r.call(this,e,t)},this.encrypt=function(r){var n;return i.agcrypto?(s.data=h.codec.utf8String.toBits(JSON.stringify(r)),n={id:r[a],data:i.agcrypt
 o.encrypt(s)},e.localStorage.setItem("ag-"+t+"-IV",JSON.stringify({id:i.agcrypto.getIV()})),n):r},this.decrypt=function(r,n){var a,o;return i.agcrypto?(o=JSON.parse(e.localStorage.getItem("ag-"+t+"-IV"))||{},s.IV=o.id,r=AeroGear.isArray(r)?r:[r],a=r.map(function(e){return s.data=e.data,JSON.parse(h.codec.utf8String.fromBits(i.agcrypto.decrypt(s)))}),n?a[0]:a):r}},AeroGear.DataManager.adapters.Memory=function(e,r){return this instanceof AeroGear.DataManager.adapters.Memory?(AeroGear.DataManager.adapters.base.apply(this,arguments),this.emptyData=function(){this.setData(null)},this.addDataRecord=function(e){this.getData().push(e)},this.updateDataRecord=function(e,t){this.getData()[e]=t},this.removeDataRecord=function(e){this.getData().splice(e,1)},this.always=function(e,t,r){r&&r.call(this,e,t)},this.getAsync=function(){return r&&r.async?!0:!1},this.open=function(e){return jQuery.Deferred().resolve(t,"success",e&&e.success)},this.close=function(){},this.traverseObjects=function(e,t,r){
 for(;"object"==typeof t&&r;)e=Object.keys(t)[0],t=t[e],r=r[e];return t===r?!0:!1},t):new AeroGear.DataManager.adapters.Memory(e,r)},AeroGear.DataManager.adapters.Memory.isValid=function(){return!0},AeroGear.DataManager.adapters.Memory.prototype.read=function(e,r){var n,a={},i=jQuery.Deferred(),s=this.getAsync();return a[this.getRecordId()]=e,e?s?this.filter(a).then(function(e){n=e}):n=this.filter(a):n=this.getData(),s?(i.always(this.always),i.resolve(n,"success",r?r.success:t)):n},AeroGear.DataManager.adapters.Memory.prototype.save=function(e,r){var n=!1,a=jQuery.Deferred(),i=this.getAsync();if(e=AeroGear.isArray(e)?e:[e],r&&r.reset)this.setData(e);else if(this.getData()&&0!==this.getData().length)for(var s=0;e.length>s;s++){for(var o in this.getData())if(this.getData()[o][this.getRecordId()]===e[s][this.getRecordId()]){this.updateDataRecord(o,e[s]),n=!0;break}n||this.addDataRecord(e[s]),n=!1}else this.setData(e);return i?(a.always(this.always),a.resolve(this.getData(),"success",r?r
 .success:t)):this.getData()},AeroGear.DataManager.adapters.Memory.prototype.remove=function(e,r){var n,a,i,s=jQuery.Deferred(),o=this.getAsync();if(s.always(this.always),!e)return this.emptyData(),o?s.resolve(this.getData(),"success",r?r.success:t):this.getData();e=AeroGear.isArray(e)?e:[e];for(var c=0;e.length>c;c++){if("string"==typeof e[c]||"number"==typeof e[c])n=e[c];else{if(!e)continue;n=e[c][this.getRecordId()]}a=this.getData(!0);for(i in a)a[i][this.getRecordId()]===n&&this.removeDataRecord(i)}return o?s.resolve(this.getData(),"success",r?r.success:t):this.getData()},AeroGear.DataManager.adapters.Memory.prototype.filter=function(e,r,n){var a,i,s,o,c,u=this,h=jQuery.Deferred(),f=this.getAsync();return h.always(this.always),e?(a=this.getData().filter(function(t){var n,a,h=r?!1:!0,f=Object.keys(e);for(i=0;f.length>i;i++){if(e[f[i]].data)for(n=e[f[i]],a=n.matchAny?!1:!0,s=0;n.data.length>s;s++)if(AeroGear.isArray(t[f[i]]))if(t[f[i]].length){if(0===jQuery(t[f]).not(n.data).length
 &&0===jQuery(n.data).not(t[f]).length){a=!0;break}for(o=0;t[f[i]].length>o;o++){if(n.matchAny&&n.data[s]===t[f[i]][o]){if(a=!0,r)break;for(c=0;t[f[i]].length>c;c++)if(!r&&n.data[s]!==t[f[i]][c]){a=!1;break}}if(!n.matchAny&&n.data[s]!==t[f[i]][o]){a=!1;break}}}else a=!1;else if("object"==typeof n.data[s]){if(n.matchAny&&u.traverseObjects(f[i],n.data[s],t[f[i]])){a=!0;break}if(!n.matchAny&&!u.traverseObjects(f[i],n.data[s],t[f[i]])){a=!1;break}}else{if(n.matchAny&&n.data[s]===t[f[i]]){a=!0;break}if(!n.matchAny&&n.data[s]!==t[f[i]]){a=!1;break}}else if(AeroGear.isArray(t[f[i]]))if(a=r?!1:!0,t[f[i]].length)for(s=0;t[f[i]].length>s;s++){if(r&&e[f[i]]===t[f[i]][s]){a=!0;break}if(!r&&e[f[i]]!==t[f[i]][s]){a=!1;break}}else a=!1;else a="object"==typeof e[f[i]]?u.traverseObjects(f[i],e[f[i]],t[f[i]]):e[f[i]]===t[f[i]]?!0:!1;if(r&&a){h=!0;break}if(!r&&!a){h=!1;break}}return h}),f?h.resolve(a,"success",n?n.success:t):a):(a=this.getData()||[],f?h.resolve(a,"success",n?n.success:t):a)},AeroGear.D
 ataManager.validateAdapter("Memory",AeroGear.DataManager.adapters.Memory),AeroGear.DataManager.adapters.SessionLocal=function(t,r){if(!(this instanceof AeroGear.DataManager.adapters.SessionLocal))return new AeroGear.DataManager.adapters.SessionLocal(t,r);AeroGear.DataManager.adapters.Memory.apply(this,arguments);var n=r.storageType||"sessionStorage",a=t,i=document.location.pathname.replace(/[\/\.]/g,"-"),s=a+i,o=e[n].getItem(s),c=o?this.decrypt(JSON.parse(o),!0):null;c&&AeroGear.DataManager.adapters.Memory.prototype.save.call(this,c,!0),this.getStoreType=function(){return n},this.getStoreKey=function(){return s}},AeroGear.DataManager.adapters.SessionLocal.isValid=function(){return!(!e.localStorage||!e.sessionStorage)},AeroGear.DataManager.adapters.SessionLocal.prototype=Object.create(new AeroGear.DataManager.adapters.Memory,{save:{value:function(r,n){var a,i=jQuery.Deferred(),s=n&&n.reset?n.reset:!1,o=e[this.getStoreType()].getItem(this.getStoreKey()),c=this.getAsync();c?AeroGear.Da
 taManager.adapters.Memory.prototype.save.apply(this,[arguments[0],{reset:s,async:c}]).then(function(e){a=e}):a=AeroGear.DataManager.adapters.Memory.prototype.save.apply(this,[arguments[0],{reset:s}]),i.always(this.always);try{e[this.getStoreType()].setItem(this.getStoreKey(),JSON.stringify(this.encrypt(a))),n&&n.success&&n.storageSuccess(a)}catch(u){if(o=o?JSON.parse(o):[],c?AeroGear.DataManager.adapters.Memory.prototype.save.apply(this,[o,{reset:s,async:c}]).then(function(e){a=e}):a=AeroGear.DataManager.adapters.Memory.prototype.save.apply(this,[o,{reset:s}]),n&&n.error)return c?i.reject(r,"error",n?n.error:t):n.error(u,r);throw c&&i.reject(),u}return c?i.resolve(a,"success",n?n.success:t):a},enumerable:!0,configurable:!0,writable:!0},remove:{value:function(r,n){var a,i=jQuery.Deferred(),s=this.getAsync();return s?AeroGear.DataManager.adapters.Memory.prototype.remove.apply(this,[arguments[0],{async:!0}]).then(function(e){a=e}):a=AeroGear.DataManager.adapters.Memory.prototype.remove
 .apply(this,arguments),e[this.getStoreType()].setItem(this.getStoreKey(),JSON.stringify(this.encrypt(a))),s?(i.always(this.always),i.resolve(a,status,n?n.success:t)):a},enumerable:!0,configurable:!0,writable:!0}}),AeroGear.DataManager.validateAdapter("SessionLocal",AeroGear.DataManager.adapters.SessionLocal),AeroGear.DataManager.adapters.IndexedDB=function(t,r){if(!e.indexedDB)throw"Your browser doesn't support IndexedDB";if(!(this instanceof AeroGear.DataManager.adapters.IndexedDB))return new AeroGear.DataManager.adapters.IndexedDB(t,r);AeroGear.DataManager.adapters.base.apply(this,arguments),r=r||{};var n,a=r.auto;this.getDatabase=function(){return n},this.setDatabase=function(e){n=e},this.getStoreName=function(){return t},this.getAsync=function(){return!0},this.run=function(e){var t=this;if(n)e.call(this,n);else{if(!a)throw"Database not opened";this.open().always(function(r,a){if("error"===a)throw"Database not opened";e.call(t,n)})}}},AeroGear.DataManager.adapters.IndexedDB.isVal
 id=function(){return!!e.indexedDB},AeroGear.DataManager.adapters.IndexedDB.prototype.open=function(t){t=t||{};var r,n,a=this,i=this.getStoreName(),s=this.getRecordId(),o=jQuery.Deferred();return r=e.indexedDB.open(i),r.onsuccess=function(e){n=e.target.result,a.setDatabase(n),o.resolve(n,"success",t.success)},r.onerror=function(e){o.reject(e,"error",t.error)},r.onupgradeneeded=function(e){n=e.target.result,n.createObjectStore(i,{keyPath:s})},o.always(this.always),o.promise()},AeroGear.DataManager.adapters.IndexedDB.prototype.read=function(e,t){t=t||{};var r,n,a,i,s,o=this,c=[],u=(this.getDatabase(),this.getStoreName()),h=jQuery.Deferred();return s=function(s){s.objectStoreNames.contains(u)||h.resolve([],"success",t.success),r=s.transaction(u),n=r.objectStore(u),e?(i=n.get(e),i.onsuccess=function(){c.push(i.result)}):(a=n.openCursor(),a.onsuccess=function(e){var t=e.target.result;t&&(c.push(t.value),t.continue())}),r.oncomplete=function(){h.resolve(o.decrypt(c),"success",t.success)},r
 .onerror=function(e){h.reject(e,"error",t.error)}},this.run.call(this,s),h.always(this.always),h.promise()},AeroGear.DataManager.adapters.IndexedDB.prototype.save=function(e,t){t=t||{};var r,n,a,i=this,s=(this.getDatabase(),this.getStoreName()),o=jQuery.Deferred(),c=0;return a=function(a){if(r=a.transaction(s,"readwrite"),n=r.objectStore(s),t.reset&&n.clear(),AeroGear.isArray(e))for(c;e.length>c;c++)n.put(this.encrypt(e[c]));else n.put(this.encrypt(e));r.oncomplete=function(){i.read().done(function(e,r){"success"===r?o.resolve(e,r,t.success):o.reject(e,r,t.error)})},r.onerror=function(e){o.reject(e,"error",t.error)}},this.run.call(this,a),o.always(this.always),o.promise()},AeroGear.DataManager.adapters.IndexedDB.prototype.remove=function(e,t){t=t||{};var r,n,a,i=this,s=this.getDatabase(),o=this.getStoreName(),c=jQuery.Deferred(),u=0;return a=function(){if(n=s.transaction(o,"readwrite"),r=n.objectStore(o),e)for(e=AeroGear.isArray(e)?e:[e],u;e.length>u;u++)if("string"==typeof e[u]||"n
 umber"==typeof e[u])r.delete(e[u]);else{if(!e)continue;r.delete(e[u][this.getRecordId()])}else r.clear();n.oncomplete=function(){i.read().done(function(e,r){"success"===r?c.resolve(e,r,t.success):c.reject(e,r,t.error)})},n.onerror=function(e){c.reject(e,"error",t.error)}},this.run.call(this,a),c.always(this.always),c.promise()},AeroGear.DataManager.adapters.IndexedDB.prototype.filter=function(e,r,n){n=n||{};var a,i=this,s=jQuery.Deferred();return this.getDatabase(),a=function(){this.read().then(function(a,o){return"success"!==o?(s.reject(a,o,n.error),t):(AeroGear.DataManager.adapters.Memory.prototype.save.call(i,a,!0),AeroGear.DataManager.adapters.Memory.prototype.filter.call(i,e,r).then(function(e){s.resolve(e,"success",n.success)}),t)})},this.run.call(this,a),s.always(this.always),s.promise()},AeroGear.DataManager.adapters.IndexedDB.prototype.close=function(){var e=this.getDatabase();e&&e.close()},AeroGear.DataManager.validateAdapter("IndexedDB",AeroGear.DataManager.adapters.Index
 edDB),AeroGear.DataManager.adapters.WebSQL=function(t,r){if(!e.openDatabase)throw"Your browser doesn't support WebSQL";if(!(this instanceof AeroGear.DataManager.adapters.WebSQL))return new AeroGear.DataManager.adapters.WebSQL(t,r);AeroGear.DataManager.adapters.base.apply(this,arguments),r=r||{};var n,a=r.auto;this.getDatabase=function(){return n},this.setDatabase=function(e){n=e},this.getStoreName=function(){return t},this.getAsync=function(){return!0},this.run=function(e){var t=this;if(n)e.call(this,n);else{if(!a)throw"Database not opened";this.open().always(function(r,a){if("error"===a)throw"Database not opened";e.call(t,n)})}}},AeroGear.DataManager.adapters.WebSQL.isValid=function(){return!!e.openDatabase},AeroGear.DataManager.adapters.WebSQL.prototype.open=function(t){t=t||{};var r,n,a,i=this,s="1",o=2097152,c=this.getRecordId(),u=this.getStoreName(),h=jQuery.Deferred();return a=e.openDatabase(u,s,"AeroGear WebSQL Store",o),n=function(e,r){h.reject(r,"error",t.error)},r=function
 (){i.setDatabase(a),h.resolve(a,"success",t.success)},a.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS "+u+" ( "+c+" REAL UNIQUE, json)",[],r,n)}),h.always(this.always),h.promise()},AeroGear.DataManager.adapters.WebSQL.prototype.read=function(e,t){t=t||{};var r,n,a,i,s=this,o=[],c=this.getStoreName(),u=(this.getDatabase(),jQuery.Deferred()),h=0;return i=function(i){n=function(e,r){u.reject(r,"error",t.error)},r=function(e,r){var n=r.rows.length;for(h;n>h;h++)o.push(JSON.parse(r.rows.item(h).json));u.resolve(s.decrypt(o),"success",t.success)},a="SELECT * FROM "+c,e&&(a+=" WHERE ID = '"+e+"'"),i.transaction(function(e){e.executeSql(a,[],r,n)})},this.run.call(this,i),u.always(this.always),u.promise()},AeroGear.DataManager.adapters.WebSQL.prototype.save=function(e,t){t=t||{};var r,n,a,i=this,s=this.getRecordId(),o=(this.getDatabase(),this.getStoreName()),c=jQuery.Deferred();return a=function(a){r=function(e,r){c.reject(r,"error",t.error)},n=function(){i.read().done(fun
 ction(e,r){"success"===r?c.resolve(e,r,t.success):c.reject(e,r,t.error)})},e=AeroGear.isArray(e)?e:[e],a.transaction(function(r){t.reset&&(r.executeSql("DROP TABLE "+o),r.executeSql("CREATE TABLE IF NOT EXISTS "+o+" ( "+s+" REAL UNIQUE, json)")),e.forEach(function(e){e=i.encrypt(e),r.executeSql("INSERT OR REPLACE INTO "+o+" ( id, json ) VALUES ( ?, ? ) ",[e[s],JSON.stringify(e)])})},r,n)},this.run.call(this,a),c.always(this.always),c.promise()},AeroGear.DataManager.adapters.WebSQL.prototype.remove=function(e,t){t=t||{};var r,n,a,i,s=this,o=this.getStoreName(),c=(this.getDatabase(),jQuery.Deferred()),u=0;return i=function(i){a=function(e,r){c.reject(r,"error",t.error)},n=function(){s.read().done(function(e,r){"success"===r?c.resolve(e,r,t.success):c.reject(e,r,t.error)})},r="DELETE FROM "+o,e?(e=AeroGear.isArray(e)?e:[e],i.transaction(function(t){for(u;e.length>u;u++)if("string"==typeof e[u]||"number"==typeof e[u])t.executeSql(r+" WHERE ID = ? ",[e[u]]);else{if(!e)continue;t.executeS
 ql(r+" WHERE ID = ? ",[e[u][this.getRecordId()]])}},a,n)):i.transaction(function(e){e.executeSql(r,[],n,a)})},this.run.call(this,i),c.always(this.always),c.promise()},AeroGear.DataManager.adapters.WebSQL.prototype.filter=function(e,r,n){n=n||{};var a,i=this,s=jQuery.Deferred();return this.getDatabase(),a=function(){this.read().then(function(a,o){return"success"!==o?(s.reject(a,o,n.error),t):(AeroGear.DataManager.adapters.Memory.prototype.save.call(i,a,!0),AeroGear.DataManager.adapters.Memory.prototype.filter.call(i,e,r).then(function(e){s.resolve(e,"success",n.success)}),t)})},this.run.call(this,a),s.always(this.always),s.promise()},AeroGear.DataManager.validateAdapter("WebSQL",AeroGear.DataManager.adapters.WebSQL),AeroGear.Auth=function(e){return this instanceof AeroGear.Auth?(AeroGear.Core.call(this),this.lib="Auth",this.type=e?e.type||"Rest":"Rest",this.collectionName="modules",this.add(e),t):new AeroGear.Auth(e)},AeroGear.Auth.prototype=AeroGear.Core,AeroGear.Auth.constructor=Ae
 roGear.Auth,AeroGear.Auth.adapters={},AeroGear.Auth.adapters.Rest=function(e,t){if(!(this instanceof AeroGear.Auth.adapters.Rest))return new AeroGear.Auth.adapters.Rest(e,t);t=t||{};var r=t.endpoints||{},n=e,a=t.baseURL||"";this.getSettings=function(){return t},this.getEndpoints=function(){return r},this.getName=function(){return n},this.getBaseURL=function(){return a},this.processOptions=function(e){var t={};return e.contentType&&(t.contentType=e.contentType),e.dataType&&(t.dataType=e.dataType),t.url=e.baseURL?e.baseURL:a,e.xhrFields&&(t.xhrFields=e.xhrFields),t}},AeroGear.Auth.adapters.Rest.prototype.enroll=function(e,t){t=t||{};var r=(this.getName(),this.getEndpoints()),n=function(){t.success&&t.success.apply(this,arguments)},a=function(e,r,n){var a;try{e.responseJSON=JSON.parse(e.responseText),a=[e,r,n]}catch(i){a=arguments}t.error&&t.error.apply(this,a)},i=jQuery.extend({},this.processOptions(t),{complete:t.complete,success:n,error:a,data:e});return i.url+=r.enroll?r.enroll:"au
 th/enroll","application/json"===i.contentType&&i.data&&"string"!=typeof i.data&&(i.data=JSON.stringify(i.data)),jQuery.ajax(jQuery.extend({},this.getSettings(),{type:"POST"},i))},AeroGear.Auth.adapters.Rest.prototype.login=function(e,t){t=t||{};var r=(this.getName(),this.getEndpoints()),n=function(){t.success&&t.success.apply(this,arguments)},a=function(e,r,n){var a;try{e.responseJSON=JSON.parse(e.responseText),a=[e,r,n]}catch(i){a=arguments}t.error&&t.error.apply(this,a)},i=jQuery.extend({},this.processOptions(t),{complete:t.complete,success:n,error:a,data:e});return i.url+=r.login?r.login:"auth/login","application/json"===i.contentType&&i.data&&"string"!=typeof i.data&&(i.data=JSON.stringify(i.data)),jQuery.ajax(jQuery.extend({},this.getSettings(),{type:"POST"},i))},AeroGear.Auth.adapters.Rest.prototype.logout=function(e){e=e||{};var t=(this.getName(),this.getEndpoints()),r=function(){e.success&&e.success.apply(this,arguments)},n=function(t,r,n){var a;try{t.responseJSON=JSON.parse
 (t.responseText),a=[t,r,n]}catch(i){a=arguments}e.error&&e.error.apply(this,a)},a=jQuery.extend({},this.processOptions(e),{complete:e.complete,success:r,error:n});return a.url+=t.logout?t.logout:"auth/logout",jQuery.ajax(jQuery.extend({},this.getSettings(),{type:"POST"},a))},AeroGear.Authorization=function(e){return this instanceof AeroGear.Authorization?(AeroGear.Core.call(this),this.lib="Authorization",this.type=e?e.type||"OAuth2":"OAuth2",this.collectionName="services",this.add(e),t):new AeroGear.Authorization(e)},AeroGear.Authorization.prototype=AeroGear.Core,AeroGear.Authorization.constructor=AeroGear.Authorization,AeroGear.Authorization.adapters={},AeroGear.Authorization.adapters.OAuth2=function(e,t){if(!(this instanceof AeroGear.Authorization.adapters.OAuth2))return new AeroGear.Authorization.adapters.OAuth2(e,t);t=t||{};var r,n=uuid(),a=t.clientId,i=t.redirectURL,s=t.validationEndpoint,o=t.scopes,c="ag-oauth2-"+a,u=t.authEndpoint+"?"+"response_type=token"+"&redirect_uri="+en
 codeURIComponent(i)+"&scope="+encodeURIComponent(o)+"&state="+encodeURIComponent(n)+"&client_id="+encodeURIComponent(a);this.getAccessToken=function(){return localStorage[c]&&(r=JSON.parse(localStorage[c]).accessToken),r},this.getState=function(){return n},this.getClientId=function(){return a},this.getLocalStorageName=function(){return c},this.getValidationEndpoint=function(){return s},this.createError=function(e){return e=e||{},AeroGear.extend(e,{authURL:u})},this.parseQueryString=function(e){for(var t,r={},n=e.substr(e.indexOf("#")+1),a=/([^&=]+)=([^&]*)/g;t=a.exec(n);)r[decodeURIComponent(t[1])]=decodeURIComponent(t[2]);return r}},AeroGear.Authorization.adapters.OAuth2.prototype.validate=function(e,r){r=r||{};var n,a,i=this,s=this.parseQueryString(e),o=this.getState();return a=function(){localStorage.setItem(i.getLocalStorageName(),JSON.stringify({accessToken:s.access_token})),r.success&&r.success.apply(this,arguments)},n=function(e){r.error&&r.error.call(this,i.createError(e))},
 s.error?(n.call(this,s),t):s.state!==o?(n.call(this,{error:"invalid_request",state:o,error_description:"state's do not match"}),t):(this.getValidationEndpoint()?jQuery.ajax({url:this.getValidationEndpoint()+"?access_token="+s.access_token,success:function(e){return i.getClientId()!==e.audience?(n.call(this,{error:"invalid_token"}),t):(a.call(this,s),t)},error:function(){n.call(this,{error:"invalid_token"})}}):a.call(this,s),t)},AeroGear.Authorization.adapters.OAuth2.prototype.execute=function(e){e=e||{};var t,r,n=this,a=e.url+"?access_token="+this.getAccessToken(),i="application/x-www-form-urlencoded";return t=function(){e.success&&e.success.apply(this,arguments)},r=function(t){e.error&&e.error.call(this,n.createError(t))},jQuery.ajax({url:a,type:e.type,contentType:i,success:t,error:r})},AeroGear.Notifier=function(e){return this instanceof AeroGear.Notifier?(AeroGear.Core.call(this),this.lib="Notifier",this.type=e?e.type||"vertx":"vertx",this.collectionName="clients",this.add(e),t):
 new AeroGear.Notifier(e)},AeroGear.Notifier.prototype=AeroGear.Core,AeroGear.Notifier.constructor=AeroGear.Notifier,AeroGear.Notifier.adapters={},AeroGear.Notifier.CONNECTING=0,AeroGear.Notifier.CONNECTED=1,AeroGear.Notifier.DISCONNECTING=2,AeroGear.Notifier.DISCONNECTED=3,AeroGear.Notifier.adapters.SimplePush=function(e,t){if(!(this instanceof AeroGear.Notifier.adapters.SimplePush))return new AeroGear.Notifier.adapters.SimplePush(e,t);t=t||{};var r=e,n=t.connectURL||"",a=t.useNative||!1,i=null,s=JSON.parse(localStorage.getItem("ag-push-store")||"{}");s.channels=s.channels||[];for(var o in s.channels)s.channels[o].state="available";localStorage.setItem("ag-push-store",JSON.stringify(s)),this.getSettings=function(){return t},this.getName=function(){return r},this.getConnectURL=function(){return n},this.setConnectURL=function(e){n=e},this.getUseNative=function(){return a},this.getClient=function(){return i},this.setClient=function(e){i=e},this.getPushStore=function(){return s},this.se
 tPushStore=function(e){s=e,localStorage.setItem("ag-push-store",JSON.stringify(e))},this.processMessage=function(e){var t,r;if("register"===e.messageType&&200===e.status)t={channelID:e.channelID,version:e.version,state:"used"},s.channels=this.updateChannel(s.channels,t),this.setPushStore(s),t.pushEndpoint=e.pushEndpoint,jQuery(navigator.push).trigger(jQuery.Event(e.channelID+"-success",{target:{result:t}}));else{if("register"===e.messageType)throw"SimplePushRegistrationError";if("unregister"===e.messageType&&200===e.status)s.channels.splice(this.findChannelIndex(s.channels,"channelID",e.channelID),1),this.setPushStore(s);else{if("unregister"===e.messageType)throw"SimplePushUnregistrationError";if("notification"===e.messageType){r=e.updates;for(var n=0,a=r.length;a>n;n++)jQuery(navigator.push).trigger(jQuery.Event("push",{message:r[n]}));e.messageType="ack",i.send(JSON.stringify(e))}}}},this.generateHello=function(){var e=s.channels,t={messageType:"hello",uaid:"",channelIDs:[]};if(s.
 uaid&&(t.uaid=s.uaid),e&&""!==t.uaid)for(var r=e.length,n=r-1;n>-1;n--)t.channelIDs.push(s.channels[n].channelID);return JSON.stringify(t)},this.findChannelIndex=function(e,t,r){for(var n=0;e.length>n;n++)if(e[n][t]===r)return n},this.updateChannel=function(e,t){for(var r=0;e.length>r;r++)if(e[r].channelID===t.channelID){e[r].version=t.version,e[r].state=t.state;break}return e},this.bindSubscribeSuccess=function(e,t){jQuery(navigator.push).off(e+"-success"),jQuery(navigator.push).on(e+"-success",function(e){t.onsuccess(e)})}},AeroGear.Notifier.adapters.SimplePush.prototype.connect=function(e){e=e||{};var t=this,r=this.getUseNative()?new WebSocket(e.url||this.getConnectURL()):new SockJS(e.url||this.getConnectURL());r.onopen=function(){r.send(t.generateHello())},r.onerror=function(){e.onConnectError&&e.onConnectError.apply(this,arguments)},r.onmessage=function(r){var n=t.getPushStore();r=JSON.parse(r.data),"hello"===r.messageType?(r.uaid!==n.uaid&&(n.uaid=r.uaid,t.setPushStore(n)),e.o
 nConnect&&e.onConnect(r)):t.processMessage(r)},r.onclose=function(){e.onClose&&e.onClose.apply(this,arguments)},this.setClient(r)},AeroGear.Notifier.adapters.SimplePush.prototype.disconnect=function(e){var t=this.getClient();t.close(),e&&e()},AeroGear.Notifier.adapters.SimplePush.prototype.subscribe=function(e,r){var n,a,i=!1,s=this.getClient(),o=this.getPushStore();r&&this.unsubscribe(this.getChannels()),e=AeroGear.isArray(e)?e:[e],o.channels=o.channels||[],a=o.channels.length;for(var c=0;e.length>c;c++)a&&(n=this.findChannelIndex(o.channels,"state","available"),n!==t&&(this.bindSubscribeSuccess(o.channels[n].channelID,e[c].requestObject),e[c].channelID=o.channels[n].channelID,e[c].state="used",setTimeout(function(e){return function(){jQuery(navigator.push).trigger(jQuery.Event(e.channelID+"-success",{target:{result:e}}))}}(e[c]),0),o.channels[n]=e[c],i=!0)),i||(e[c].channelID=e[c].channelID||uuid(),e[c].state="used",this.bindSubscribeSuccess(e[c].channelID,e[c].requestObject),s.se
 nd('{"messageType": "register", "channelID": "'+e[c].channelID+'"}'),o.channels.push(e[c])),i=!1;this.setPushStore(o)},AeroGear.Notifier.adapters.SimplePush.prototype.unsubscribe=function(e){var t=this.getClient();e=AeroGear.isArray(e)?e:[e];for(var r=0;e.length>r;r++)t.send('{"messageType": "unregister", "channelID": "'+e[r].channelID+'"}')},AeroGear.Notifier.adapters.vertx=function(e,t){if(!(this instanceof AeroGear.Notifier.adapters.vertx))return new AeroGear.Notifier.adapters.vertx(e,t);t=t||{};var r=t.channels||[],n=!!t.autoConnect||r.length,a=t.connectURL||"",i=AeroGear.Notifier.CONNECTING,s=null;this.getConnectURL=function(){return a},this.setConnectURL=function(e){a=e},this.getChannels=function(){return r},this.addChannel=function(e){r.push(e)},this.getChannelIndex=function(e){for(var t=0;r.length>t;t++)if(r[t].address===e)return t;return-1},this.removeChannel=function(e){var t=this.getChannelIndex(e.address);t>=0&&r.splice(t,1)},this.getState=function(){return i},this.setSt
 ate=function(e){i=e},this.getBus=function(){return s},this.setBus=function(e){s=e},(n||r.length)&&this.connect({url:a,onConnect:t.onConnect,onDisconnect:t.onDisconnect,onConnectError:t.onConnectError})},AeroGear.Notifier.adapters.vertx.prototype.connect=function(e){e=e||{};var t=this,r=new vertx.EventBus(e.url||this.getConnectURL());r.onopen=function(){var r=t.getChannels().slice(0);t.setState(AeroGear.Notifier.CONNECTED),t.subscribe(r,!0),e.onConnect&&e.onConnect.apply(this,arguments)},r.onclose=function(){t.getState()===AeroGear.Notifier.DISCONNECTING?(t.setState(AeroGear.Notifier.DISCONNECTED),e.onDisconnect&&e.onDisconnect.apply(this,arguments)):e.onConnectError&&e.onConnectError.apply(this,arguments)},this.setBus(r)},AeroGear.Notifier.adapters.vertx.prototype.disconnect=function(){var e=this.getBus();this.getState()===AeroGear.Notifier.CONNECTED&&(this.setState(AeroGear.Notifier.DISCONNECTING),e.close())},AeroGear.Notifier.adapters.vertx.prototype.subscribe=function(e,t){var r=
 this.getBus();t&&this.unsubscribe(this.getChannels()),e=AeroGear.isArray(e)?e:[e];for(var n=0;e.length>n;n++)this.addChannel(e[n]),r.registerHandler(e[n].address,e[n].callback)},AeroGear.Notifier.adapters.vertx.prototype.unsubscribe=function(e){var t=this.getBus();e=AeroGear.isArray(e)?e:[e];for(var r=0;e.length>r;r++)this.removeChannel(e[r]),t.unregisterHandler(e[r].address,e[r].callback)},AeroGear.Notifier.adapters.vertx.prototype.send=function(e,t,r){var n=this.getBus();typeof t!==Boolean||r||(r=t,t=""),t=t||"",n[r?"publish":"send"](e,t)},AeroGear.Notifier.adapters.stompws=function(e,t){if(!(this instanceof AeroGear.Notifier.adapters.stompws))return new AeroGear.Notifier.adapters.stompws(e,t);t=t||{};var r=t.channels||[],n=!!t.autoConnect||r.length,a=t.connectURL||"",i=AeroGear.Notifier.CONNECTING,s=null;this.getConnectURL=function(){return a},this.setConnectURL=function(e){a=e},this.getChannels=function(){return r},this.addChannel=function(e){r.push(e)},this.getChannelIndex=func
 tion(e){for(var t=0;r.length>t;t++)if(r[t].address===e)return t;return-1},this.removeChannel=function(e){var t=this.getChannelIndex(e.address);
-t>=0&&r.splice(t,1)},this.getState=function(){return i},this.setState=function(e){i=e},this.getClient=function(){return s},this.setClient=function(e){s=e},!n&&!r.length||t.login||t.password||this.connect({url:a,onConnect:t.onConnect,onConnectError:t.onConnectError})},AeroGear.Notifier.adapters.stompws.prototype.connect=function(e){e=e||{};var t=this,r=new Stomp.client(e.url||this.getConnectURL(),e.protocol||"v11.stomp"),n=function(){var r=t.getChannels().slice(0);t.setState(AeroGear.Notifier.CONNECTED),t.subscribe(r,!0),e.onConnect&&e.onConnect.apply(this,arguments)},a=function(){t.setState(AeroGear.Notifier.DISCONNECTED),e.onConnectError&&e.onConnectError.apply(this,arguments)};r.connect(e.login,e.password,n,a,e.host),this.setClient(r)},AeroGear.Notifier.adapters.stompws.prototype.disconnect=function(e){var t=this,r=this.getClient(),n=function(){t.getState()===AeroGear.Notifier.DISCONNECTING&&(t.setState(AeroGear.Notifier.DISCONNECTED),e&&e.apply(this,arguments))};this.getState()==
 =AeroGear.Notifier.CONNECTED&&(this.setState(AeroGear.Notifier.DISCONNECTING),r.disconnect(n))},AeroGear.Notifier.adapters.stompws.prototype.subscribe=function(e,t){var r=this.getClient();t&&this.unsubscribe(this.getChannels()),e=AeroGear.isArray(e)?e:[e];for(var n=0;e.length>n;n++)e[n].id=r.subscribe(e[n].address,e[n].callback),this.addChannel(e[n])},AeroGear.Notifier.adapters.stompws.prototype.debug=function(e){var t=this.getClient(),r=function(){e&&e.apply(this,arguments)};t&&(t.debug=r)},AeroGear.Notifier.adapters.stompws.prototype.unsubscribe=function(e){var t=this.getClient(),r=this.getChannels();e=AeroGear.isArray(e)?e:[e];for(var n=0;e.length>n;n++)t.unsubscribe(e[n].id||r[this.getChannelIndex(e[n].address)].id),this.removeChannel(e[n])},AeroGear.Notifier.adapters.stompws.prototype.send=function(e,t){var r={},n=this.getClient();t=t||"",t.headers&&(r=t.headers,t=t.body),n.send(e,r,t)},function(r,n){r.UnifiedPushClient=function(a,i,s){if(!a||!i||!s)throw"UnifiedPushClientExcep
 tion";return this instanceof r.UnifiedPushClient?(this.registerWithPushServer=function(t){t=t||{};var o=t.metadata||{};if(!o.deviceToken)throw"UnifiedPushRegistrationException";return o.categories=r.isArray(o.categories)?o.categories:o.categories?[o.categories]:[],n.ajax({contentType:"application/json",dataType:"json",type:"POST",url:s,headers:{Authorization:"Basic "+e.btoa(a+":"+i)},data:JSON.stringify(o),success:t.success,error:t.error,complete:t.complete})},this.unregisterWithPushServer=function(t,r){return r=r||{},n.ajax({contentType:"application/json",dataType:"json",type:"DELETE",url:s+"/"+t,headers:{Authorization:"Basic "+e.btoa(a+":"+i)},success:r.success,error:r.error,complete:r.complete})},t):new r.UnifiedPushClient(a,i,s)}}(AeroGear,jQuery),function(t,r){t.SimplePushClient=function(n){if(!(this instanceof t.SimplePushClient))return new t.SimplePushClient(n);if(this.options=n||{},!navigator.push||!this.options.useNative){if(this.options.useNative)if("WebSocket"in e)this.op
 tions.simplePushServerURL="wss://push.services.mozilla.com";else{if(!this.options.simplePushServerURL)throw"SimplePushConfigurationError";this.options.useNative=!1}var a=this,i={onConnect:function(){navigator.push=function(){return{register:function(){var e={onsuccess:function(){}};if(!a.simpleNotifier)throw"SimplePushConnectionError";return a.simpleNotifier.subscribe({requestObject:e,callback:function(e){r(navigator.push).trigger({type:"push",message:e})}}),e},unregister:function(e){a.simpleNotifier.unsubscribe(e)},reconnect:function(){a.simpleNotifier.connect(i)}}}(),navigator.setMessageHandler=function(e,t){r(navigator.push).on(e,function(e){var r=e.message;t.call(this,r)})},a.options.onConnect&&a.options.onConnect()},onClose:function(){a.simpleNotifier.disconnect(a.options.onClose)}};a.simpleNotifier=t.Notifier({name:"agPushNetwork",type:"SimplePush",settings:{connectURL:a.options.simplePushServerURL,useNative:a.options.useNative}}).clients.agPushNetwork,a.simpleNotifier.connect
 (i)}}}(AeroGear,jQuery),AeroGear.Crypto=function(){if(!e.crypto||!e.crypto.getRandomValues)throw"Your browser does not support the Web Crypto API";if(!(this instanceof AeroGear.Crypto))return new AeroGear.Crypto;var t,r,n,a;this.getSalt=function(){return a},this.getIV=function(){return n},this.getPrivateKey=function(){return t},this.getPublicKey=function(){return r},this.getRandomValue=function(){var e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]},this.deriveKey=function(e,t){a=t||(a?a:this.getRandomValue());var r=h.codec.utf8String,n=2048;return h.misc.pbkdf2(e,r.toBits(a),n)},this.encrypt=function(e){e=e||{};var t=h.mode.gcm,r=new h.cipher.aes(e.key);return n=e.IV||(n?n:this.getRandomValue()),t.encrypt(r,e.data,n,e.aad,128)},this.decrypt=function(e){e=e||{};var t=h.mode.gcm,r=new h.cipher.aes(e.key);return t.decrypt(r,e.data,e.IV||n,e.aad,128)},this.hash=function(e){return h.hash.sha256.hash(e)},this.sign=function(e){e=e||{};var t=e.keys||h.ecc.ecdsa.generateKeys(192),
 r=h.hash.sha256.hash(e.message);return t.sec.sign(r)},this.verify=function(e){e=e||{};var t=h.hash.sha256.hash(e.message);return e.keys.pub.verify(t,e.signature)},this.KeyPair=function(e,n){var a,i;return e&&n?(t=e,r=n):(a=h.ecc.elGamal.generateKeys(192,0),i=a.pub.kem(),r=i.key,t=a.sec.unkem(i.tag)),this}}})(this);
-//@ sourceMappingURL=aerogear.js.map

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/examples/protocols/stomp/stomp-websockets/aerogear-chat/stomp.js
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-websockets/aerogear-chat/stomp.js b/examples/protocols/stomp/stomp-websockets/aerogear-chat/stomp.js
deleted file mode 100644
index 97b55db..0000000
--- a/examples/protocols/stomp/stomp-websockets/aerogear-chat/stomp.js
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// Generated by CoffeeScript 1.4.0
-(function() {
-  var Byte, Client, Frame, Stomp,
-    __hasProp = {}.hasOwnProperty;
-
-  Byte = {
-    LF: '\x0A',
-    NULL: '\x00'
-  };
-
-  Frame = (function() {
-
-    function Frame(command, headers, body) {
-      this.command = command;
-      this.headers = headers != null ? headers : {};
-      this.body = body != null ? body : '';
-    }
-
-    Frame.prototype.toString = function() {
-      var lines, name, value, _ref;
-      lines = [this.command];
-      _ref = this.headers;
-      for (name in _ref) {
-        if (!__hasProp.call(_ref, name)) continue;
-        value = _ref[name];
-        lines.push("" + name + ":" + value);
-      }
-      if (this.body) {
-        lines.push("content-length:" + ('' + this.body).length);
-      }
-      lines.push(Byte.LF + this.body);
-      return lines.join(Byte.LF);
-    };
-
-    Frame._unmarshallSingle = function(data) {
-      var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _ref, _ref1;
-      divider = data.search(RegExp("" + Byte.LF + Byte.LF));
-      headerLines = data.substring(0, divider).split(Byte.LF);
-      command = headerLines.shift();
-      headers = {};
-      trim = function(str) {
-        return str.replace(/^\s+|\s+$/g, '');
-      };
-      line = idx = null;
-      for (i = _i = 0, _ref = headerLines.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
-        line = headerLines[i];
-        idx = line.indexOf(':');
-        headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1));
-      }
-      body = '';
-      start = divider + 2;
-      if (headers['content-length']) {
-        len = parseInt(headers['content-length']);
-        body = ('' + data).substring(start, start + len);
-      } else {
-        chr = null;
-        for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) {
-          chr = data.charAt(i);
-          if (chr === Byte.NULL) {
-            break;
-          }
-          body += chr;
-        }
-      }
-      return new Frame(command, headers, body);
-    };
-
-    Frame.unmarshall = function(datas) {
-      var data;
-      return (function() {
-        var _i, _len, _ref, _results;
-        _ref = datas.split(RegExp("" + Byte.NULL + Byte.LF + "*"));
-        _results = [];
-        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-          data = _ref[_i];
-          if ((data != null ? data.length : void 0) > 0) {
-            _results.push(Frame._unmarshallSingle(data));
-          }
-        }
-        return _results;
-      })();
-    };
-
-    Frame.marshall = function(command, headers, body) {
-      var frame;
-      frame = new Frame(command, headers, body);
-      return frame.toString() + Byte.NULL;
-    };
-
-    return Frame;
-
-  })();
-
-  Client = (function() {
-
-    function Client(ws) {
-      this.ws = ws;
-      this.ws.binaryType = "arraybuffer";
-      this.counter = 0;
-      this.connected = false;
-      this.heartbeat = {
-        outgoing: 10000,
-        incoming: 10000
-      };
-      this.subscriptions = {};
-    }
-
-    Client.prototype._transmit = function(command, headers, body) {
-      var out;
-      out = Frame.marshall(command, headers, body);
-      if (typeof this.debug === "function") {
-        this.debug(">>> " + out);
-      }
-      return this.ws.send(out);
-    };
-
-    Client.prototype._setupHeartbeat = function(headers) {
-      var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1,
-        _this = this;
-      if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) {
-        return;
-      }
-      _ref1 = (function() {
-        var _i, _len, _ref1, _results;
-        _ref1 = headers['heart-beat'].split(",");
-        _results = [];
-        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
-          v = _ref1[_i];
-          _results.push(parseInt(v));
-        }
-        return _results;
-      })(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1];
-      if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) {
-        ttl = Math.max(this.heartbeat.outgoing, serverIncoming);
-        if (typeof this.debug === "function") {
-          this.debug("send PING every " + ttl + "ms");
-        }
-        this.pinger = typeof window !== "undefined" && window !== null ? window.setInterval(function() {
-          _this.ws.send(Byte.LF);
-          return typeof _this.debug === "function" ? _this.debug(">>> PING") : void 0;
-        }, ttl) : void 0;
-      }
-      if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) {
-        ttl = Math.max(this.heartbeat.incoming, serverOutgoing);
-        if (typeof this.debug === "function") {
-          this.debug("check PONG every " + ttl + "ms");
-        }
-        return this.ponger = typeof window !== "undefined" && window !== null ? window.setInterval(function() {
-          var delta;
-          delta = Date.now() - _this.serverActivity;
-          if (delta > ttl * 2) {
-            if (typeof _this.debug === "function") {
-              _this.debug("did not receive server activity for the last " + delta + "ms");
-            }
-            return _this.ws.close();
-          }
-        }, ttl) : void 0;
-      }
-    };
-
-    Client.prototype.connect = function(login, passcode, connectCallback, errorCallback, vhost) {
-      var _this = this;
-      this.connectCallback = connectCallback;
-      if (typeof this.debug === "function") {
-        this.debug("Opening Web Socket...");
-      }
-      this.ws.onmessage = function(evt) {
-        var arr, c, data, frame, onreceive, _i, _len, _ref, _results;
-        data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === "function" ? _this.debug("--- got data length: " + arr.length) : void 0, ((function() {
-          var _i, _len, _results;
-          _results = [];
-          for (_i = 0, _len = arr.length; _i < _len; _i++) {
-            c = arr[_i];
-            _results.push(String.fromCharCode(c));
-          }
-          return _results;
-        })()).join('')) : evt.data;
-        _this.serverActivity = Date.now();
-        if (data === Byte.LF) {
-          if (typeof _this.debug === "function") {
-            _this.debug("<<< PONG");
-          }
-          return;
-        }
-        if (typeof _this.debug === "function") {
-          _this.debug("<<< " + data);
-        }
-        _ref = Frame.unmarshall(data);
-        _results = [];
-        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-          frame = _ref[_i];
-          switch (frame.command) {
-            case "CONNECTED":
-              if (typeof _this.debug === "function") {
-                _this.debug("connected to server " + frame.headers.server);
-              }
-              _this.connected = true;
-              _this._setupHeartbeat(frame.headers);
-              _results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0);
-              break;
-            case "MESSAGE":
-              onreceive = _this.subscriptions[frame.headers.subscription];
-              _results.push(typeof onreceive === "function" ? onreceive(frame) : void 0);
-              break;
-            case "RECEIPT":
-              _results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0);
-              break;
-            case "ERROR":
-              _results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0);
-              break;
-            default:
-              _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0);
-          }
-        }
-        return _results;
-      };
-      this.ws.onclose = function() {
-        var msg;
-        msg = "Whoops! Lost connection to " + _this.ws.url;
-        if (typeof _this.debug === "function") {
-          _this.debug(msg);
-        }
-        _this._cleanUp();
-        return typeof errorCallback === "function" ? errorCallback(msg) : void 0;
-      };
-      return this.ws.onopen = function() {
-        var headers;
-        if (typeof _this.debug === "function") {
-          _this.debug('Web Socket Opened...');
-        }
-        headers = {
-          "accept-version": Stomp.VERSIONS.supportedVersions(),
-          "heart-beat": [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',')
-        };
-        if (vhost) {
-          headers.host = vhost;
-        }
-        if (login) {
-          headers.login = login;
-        }
-        if (passcode) {
-          headers.passcode = passcode;
-        }
-        return _this._transmit("CONNECT", headers);
-      };
-    };
-
-    Client.prototype.disconnect = function(disconnectCallback) {
-      this._transmit("DISCONNECT");
-      this.ws.onclose = null;
-      this.ws.close();
-      this._cleanUp();
-      return typeof disconnectCallback === "function" ? disconnectCallback() : void 0;
-    };
-
-    Client.prototype._cleanUp = function() {
-      this.connected = false;
-      if (this.pinger) {
-        if (typeof window !== "undefined" && window !== null) {
-          window.clearInterval(this.pinger);
-        }
-      }
-      if (this.ponger) {
-        return typeof window !== "undefined" && window !== null ? window.clearInterval(this.ponger) : void 0;
-      }
-    };
-
-    Client.prototype.send = function(destination, headers, body) {
-      if (headers == null) {
-        headers = {};
-      }
-      if (body == null) {
-        body = '';
-      }
-      headers.destination = destination;
-      return this._transmit("SEND", headers, body);
-    };
-
-    Client.prototype.subscribe = function(destination, callback, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      if (!headers.id) {
-        headers.id = "sub-" + this.counter++;
-      }
-      headers.destination = destination;
-      this.subscriptions[headers.id] = callback;
-      this._transmit("SUBSCRIBE", headers);
-      return headers.id;
-    };
-
-    Client.prototype.unsubscribe = function(id) {
-      delete this.subscriptions[id];
-      return this._transmit("UNSUBSCRIBE", {
-        id: id
-      });
-    };
-
-    Client.prototype.begin = function(transaction) {
-      return this._transmit("BEGIN", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.commit = function(transaction) {
-      return this._transmit("COMMIT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.abort = function(transaction) {
-      return this._transmit("ABORT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.ack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("ACK", headers);
-    };
-
-    Client.prototype.nack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("NACK", headers);
-    };
-
-    return Client;
-
-  })();
-
-  Stomp = {
-    libVersion: "2.0.0-next",
-    VERSIONS: {
-      V1_0: '1.0',
-      V1_1: '1.1',
-      V1_2: '1.2',
-      supportedVersions: function() {
-        return '1.1,1.0';
-      }
-    },
-    client: function(url, protocols) {
-      var klass, ws;
-      if (protocols == null) {
-        protocols = ['v10.stomp', 'v11.stomp'];
-      }
-      klass = Stomp.WebSocketClass || WebSocket;
-      ws = new klass(url, protocols);
-      return new Client(ws);
-    },
-    over: function(ws) {
-      return new Client(ws);
-    },
-    Frame: Frame
-  };
-
-  if (typeof window !== "undefined" && window !== null) {
-    window.Stomp = Stomp;
-  } else if (typeof exports !== "undefined" && exports !== null) {
-    exports.Stomp = Stomp;
-    Stomp.WebSocketClass = require('./test/server.mock.js').StompServerMock;
-  } else {
-    self.Stomp = Stomp;
-  }
-
-}).call(this);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/pom.xml
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/pom.xml b/integration/activemq-aerogear-integration/pom.xml
deleted file mode 100644
index d11319a..0000000
--- a/integration/activemq-aerogear-integration/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-   <modelVersion>4.0.0</modelVersion>
-
-   <parent>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>artemis-pom</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
-      <relativePath>../../pom.xml</relativePath>
-   </parent>
-
-   <artifactId>artemis-aerogear-integration</artifactId>
-   <packaging>jar</packaging>
-   <name>ActiveMQ Artemis Aerogear Integration</name>
-
-   <properties>
-      <activemq.basedir>${project.basedir}/../..</activemq.basedir>
-   </properties>
-
-   <dependencies>
-      <dependency>
-         <groupId>org.jboss.logging</groupId>
-         <artifactId>jboss-logging-processor</artifactId>
-         <scope>provided</scope>
-         <optional>true</optional>
-      </dependency>
-
-      <!--
-          JBoss Logging
-      -->
-      <dependency>
-         <groupId>org.jboss.logging</groupId>
-         <artifactId>jboss-logging</artifactId>
-      </dependency>
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-server</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-
-      <dependency>
-         <groupId>org.jboss.aerogear</groupId>
-         <artifactId>unifiedpush-java-client</artifactId>
-         <version>1.0.0</version>
-      </dependency>
-      <!-- RestEasy's Jackson Plugin -->
-      <dependency>
-         <groupId>org.jboss.resteasy</groupId>
-         <artifactId>resteasy-jackson-provider</artifactId>
-         <version>2.3.2.Final</version>
-         <exclusions>
-            <exclusion>
-               <groupId>org.jboss.spec.javax.annotation</groupId>
-               <artifactId>jboss-annotations-api_1.1_spec</artifactId>
-            </exclusion>
-         </exclusions>
-      </dependency>
-   </dependencies>
-
-</project>


[18/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
index eb7cda1..2108be7 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
@@ -31,11 +31,13 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
+import org.apache.activemq.artemis.core.journal.EncoderPersister;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.IOCompletion;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
 import org.apache.activemq.artemis.core.journal.LoaderCallback;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
@@ -366,10 +368,10 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    }
 
    @Override
-   public void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception {
+   public void appendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.ADD_RECORD, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setSync(sync);
       appendRecord(r);
    }
@@ -377,12 +379,13 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    @Override
    public void appendAddRecord(long id,
                                byte recordType,
-                               EncodingSupport record,
+                               Persister persister,
+                               Object record,
                                boolean sync,
                                IOCompletion completionCallback) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.ADD_RECORD, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setSync(sync);
       r.setIoCompletion(completionCallback);
       appendRecord(r);
@@ -398,10 +401,10 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    }
 
    @Override
-   public void appendUpdateRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception {
+   public void appendUpdateRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.UPDATE_RECORD, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setSync(sync);
       appendRecord(r);
    }
@@ -409,12 +412,13 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    @Override
    public void appendUpdateRecord(long id,
                                   byte recordType,
-                                  EncodingSupport record,
+                                  Persister persister,
+                                  Object record,
                                   boolean sync,
                                   IOCompletion completionCallback) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.ADD_RECORD, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setSync(sync);
       r.setIoCompletion(completionCallback);
       appendRecord(r);
@@ -448,10 +452,11 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    public void appendAddRecordTransactional(long txID,
                                             long id,
                                             byte recordType,
-                                            EncodingSupport record) throws Exception {
+                                            Persister persister,
+                                            Object record) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.ADD_RECORD_TX, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setTxId(txID);
       appendRecord(r);
    }
@@ -469,10 +474,11 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    public void appendUpdateRecordTransactional(long txID,
                                                long id,
                                                byte recordType,
-                                               EncodingSupport record) throws Exception {
+                                               Persister persister,
+                                               Object record) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.UPDATE_RECORD_TX, seq.incrementAndGet());
       r.setUserRecordType(recordType);
-      r.setRecord(record);
+      r.setRecord(persister, record);
       r.setTxId(txID);
       appendRecord(r);
    }
@@ -488,7 +494,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    @Override
    public void appendDeleteRecordTransactional(long txID, long id, EncodingSupport record) throws Exception {
       JDBCJournalRecord r = new JDBCJournalRecord(id, JDBCJournalRecord.DELETE_RECORD_TX, seq.incrementAndGet());
-      r.setRecord(record);
+      r.setRecord(EncoderPersister.getInstance(), record);
       r.setTxId(txID);
       appendRecord(r);
    }
@@ -685,10 +691,6 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
    }
 
    @Override
-   public void perfBlast(int pages) {
-   }
-
-   @Override
    public void runDirectJournalBlast() throws Exception {
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
index 9691d3e..b094164 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalRecord.java
@@ -28,6 +28,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.IOCompletion;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
 import org.apache.activemq.artemis.utils.ActiveMQBufferInputStream;
@@ -237,11 +238,11 @@ class JDBCJournalRecord {
       this.record = record;
    }
 
-   public void setRecord(EncodingSupport record) {
-      this.variableSize = record.getEncodeSize();
+   public void setRecord(Persister persister, Object record) {
+      this.variableSize = persister.getEncodeSize(record);
 
       ActiveMQBuffer encodedBuffer = ActiveMQBuffers.fixedBuffer(variableSize);
-      record.encode(encodedBuffer);
+      persister.encode(encodedBuffer, record);
       this.record = new ActiveMQBufferInputStream(encodedBuffer);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
index 59f04e8..6da3912 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQBytesMessage.java
@@ -26,7 +26,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 
 import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesMessageReset;
 import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesReadBoolean;
@@ -374,7 +374,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
       if (bodyLength == 0)
          return null;
       byte[] dst = new byte[bodyLength];
-      message.getBodyBuffer().getBytes(MessageImpl.BODY_OFFSET, dst);
+      message.getBodyBuffer().getBytes(CoreMessage.BODY_OFFSET, dst);
       return (T) dst;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
index 47dcfb2..80a07ac 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
@@ -43,7 +43,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.client.impl.ClientMessageInternal;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.reader.MessageUtil;
 import org.apache.activemq.artemis.utils.UUID;
@@ -293,7 +293,7 @@ public class ActiveMQMessage implements javax.jms.Message {
    @Override
    public String getJMSMessageID() {
       if (msgID == null) {
-         UUID uid = message.getUserID();
+         UUID uid = (UUID)message.getUserID();
 
          msgID = uid == null ? null : "ID:" + uid.toString();
       }
@@ -397,7 +397,7 @@ public class ActiveMQMessage implements javax.jms.Message {
    @Override
    public Destination getJMSDestination() throws JMSException {
       if (dest == null) {
-         SimpleString address = message.getAddress();
+         SimpleString address = message.getAddressSimpleString();
          String prefix = "";
          if (message.containsProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTING_TYPE)) {
             RoutingType routingType = RoutingType.getType(message.getByteProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTING_TYPE));
@@ -756,7 +756,7 @@ public class ActiveMQMessage implements javax.jms.Message {
 
    @SuppressWarnings("unchecked")
    protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException {
-      InputStream is = ((MessageInternal) message).getBodyInputStream();
+      InputStream is = ((ClientMessageInternal) message).getBodyInputStream();
       try {
          ObjectInputStream ois = new ObjectInputStream(is);
          return (T) ois.readObject();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java
index 6cf20ff..289f88c 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/transaction/JMSTransactionDetail.java
@@ -19,7 +19,7 @@ package org.apache.activemq.artemis.jms.transaction;
 import javax.transaction.xa.Xid;
 import java.util.Map;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionDetail;
 import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage;
@@ -36,7 +36,7 @@ public class JMSTransactionDetail extends TransactionDetail {
    }
 
    @Override
-   public String decodeMessageType(ServerMessage msg) {
+   public String decodeMessageType(Message msg) {
       int type = msg.getType();
       switch (type) {
          case ActiveMQMessage.TYPE: // 0
@@ -57,7 +57,7 @@ public class JMSTransactionDetail extends TransactionDetail {
    }
 
    @Override
-   public Map<String, Object> decodeMessageProperties(ServerMessage msg) {
+   public Map<String, Object> decodeMessageProperties(Message msg) {
       try {
          return ActiveMQMessage.coreMaptoJMSMap(msg.toMap());
       } catch (Throwable t) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/EncoderPersister.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/EncoderPersister.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/EncoderPersister.java
new file mode 100644
index 0000000..8fc2a5aa
--- /dev/null
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/EncoderPersister.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.journal;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.core.persistence.Persister;
+
+/** This is a facade between the new Persister and the former EncodingSupport.
+ *  Methods using the old interface will use this as a facade to provide the previous semantic. */
+public class EncoderPersister implements Persister<EncodingSupport> {
+
+   private static final EncoderPersister theInstance = new EncoderPersister();
+
+   private EncoderPersister() {
+   }
+
+   public static EncoderPersister getInstance() {
+      return theInstance;
+   }
+
+   @Override
+   public int getEncodeSize(EncodingSupport record) {
+      return record.getEncodeSize();
+   }
+
+   @Override
+   public void encode(ActiveMQBuffer buffer, EncodingSupport record) {
+      record.encode(buffer);
+   }
+
+   @Override
+   public EncodingSupport decode(ActiveMQBuffer buffer, EncodingSupport record) {
+      record.decode(buffer);
+      return record;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/Journal.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/Journal.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/Journal.java
index fbd4182..ca194b8 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/Journal.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/Journal.java
@@ -21,6 +21,7 @@ import java.util.Map;
 
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 
 /**
@@ -60,23 +61,49 @@ public interface Journal extends ActiveMQComponent {
 
    void appendAddRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception;
 
-   void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception;
+   default void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception {
+      appendAddRecord(id, recordType, EncoderPersister.getInstance(), record, sync);
+   }
+
+   void appendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception;
 
    void appendAddRecord(long id,
                         byte recordType,
-                        EncodingSupport record,
+                        Persister persister,
+                        Object record,
                         boolean sync,
                         IOCompletion completionCallback) throws Exception;
 
+   default void appendAddRecord(long id,
+                        byte recordType,
+                        EncodingSupport record,
+                        boolean sync,
+                        IOCompletion completionCallback) throws Exception {
+      appendAddRecord(id, recordType, EncoderPersister.getInstance(), record, sync, completionCallback);
+   }
+
    void appendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception;
 
-   void appendUpdateRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception;
+   default void appendUpdateRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception {
+      appendUpdateRecord(id, recordType, EncoderPersister.getInstance(), record, sync);
+   }
 
-   void appendUpdateRecord(long id,
+   void appendUpdateRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception;
+
+   default void appendUpdateRecord(long id,
                            byte recordType,
                            EncodingSupport record,
                            boolean sync,
-                           IOCompletion completionCallback) throws Exception;
+                           IOCompletion completionCallback) throws Exception {
+      appendUpdateRecord(id, recordType, EncoderPersister.getInstance(), record, sync, completionCallback);
+   }
+
+   void appendUpdateRecord(final long id,
+                           final byte recordType,
+                           final Persister persister,
+                           final Object record,
+                           final boolean sync,
+                           final IOCompletion callback) throws Exception;
 
    void appendDeleteRecord(long id, boolean sync) throws Exception;
 
@@ -86,11 +113,23 @@ public interface Journal extends ActiveMQComponent {
 
    void appendAddRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception;
 
-   void appendAddRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception;
+   default void appendAddRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception {
+      appendAddRecordTransactional(txID, id, recordType, EncoderPersister.getInstance(), record);
+   }
+
+   void appendAddRecordTransactional(final long txID,
+                                     final long id,
+                                     final byte recordType,
+                                     final Persister persister,
+                                     final Object record) throws Exception;
 
    void appendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record) throws Exception;
 
-   void appendUpdateRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception;
+   default void appendUpdateRecordTransactional(long txID, long id, byte recordType, EncodingSupport record) throws Exception {
+      appendUpdateRecordTransactional(txID, id, recordType, EncoderPersister.getInstance(), record);
+   }
+
+   void appendUpdateRecordTransactional(long txID, long id, byte recordType, Persister persister, Object record) throws Exception;
 
    void appendDeleteRecordTransactional(long txID, long id, byte[] record) throws Exception;
 
@@ -165,8 +204,6 @@ public interface Journal extends ActiveMQComponent {
 
    int getUserVersion();
 
-   void perfBlast(int pages);
-
    void runDirectJournalBlast() throws Exception;
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
index 8bbecd2..943077c 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/AbstractJournalUpdateTask.java
@@ -26,6 +26,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
+import org.apache.activemq.artemis.core.journal.EncoderPersister;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalInternalRecord;
@@ -127,7 +128,7 @@ public abstract class AbstractJournalUpdateTask implements JournalReaderCallback
             }
          }
 
-         JournalInternalRecord controlRecord = new JournalAddRecord(true, 1, (byte) 0, new ByteArrayEncoding(filesToRename.toByteBuffer().array()));
+         JournalInternalRecord controlRecord = new JournalAddRecord(true, 1, (byte) 0, EncoderPersister.getInstance(), new ByteArrayEncoding(filesToRename.toByteBuffer().array()));
 
          ActiveMQBuffer renameBuffer = ActiveMQBuffers.dynamicBuffer(filesToRename.writerIndex());
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java
index 0b702a5..8e5ca2c 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/FileWrapperJournal.java
@@ -31,6 +31,7 @@ import org.apache.activemq.artemis.core.journal.IOCompletion;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
 import org.apache.activemq.artemis.core.journal.LoaderCallback;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
@@ -90,10 +91,11 @@ public final class FileWrapperJournal extends JournalBase {
    @Override
    public void appendAddRecord(long id,
                                byte recordType,
-                               EncodingSupport record,
+                               Persister persister,
+                               Object record,
                                boolean sync,
                                IOCompletion callback) throws Exception {
-      JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, record);
+      JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, persister, record);
 
       writeRecord(addRecord, sync, callback);
    }
@@ -144,19 +146,21 @@ public final class FileWrapperJournal extends JournalBase {
    public void appendAddRecordTransactional(long txID,
                                             long id,
                                             byte recordType,
-                                            EncodingSupport record) throws Exception {
+                                            Persister persister,
+                                            Object record) throws Exception {
       count(txID);
-      JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, record);
+      JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, persister, record);
       writeRecord(addRecord, false, null);
    }
 
    @Override
    public void appendUpdateRecord(long id,
                                   byte recordType,
-                                  EncodingSupport record,
+                                  Persister persister,
+                                  Object record,
                                   boolean sync,
                                   IOCompletion callback) throws Exception {
-      JournalInternalRecord updateRecord = new JournalAddRecord(false, id, recordType, record);
+      JournalInternalRecord updateRecord = new JournalAddRecord(false, id, recordType, persister, record);
       writeRecord(updateRecord, sync, callback);
    }
 
@@ -164,9 +168,10 @@ public final class FileWrapperJournal extends JournalBase {
    public void appendUpdateRecordTransactional(long txID,
                                                long id,
                                                byte recordType,
-                                               EncodingSupport record) throws Exception {
+                                               Persister persister,
+                                               Object record) throws Exception {
       count(txID);
-      JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, txID, id, recordType, record);
+      JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, txID, id, recordType, persister, record);
       writeRecord(updateRecordTX, false, null);
    }
 
@@ -261,11 +266,6 @@ public final class FileWrapperJournal extends JournalBase {
    }
 
    @Override
-   public void perfBlast(int pages) {
-      throw new UnsupportedOperationException();
-   }
-
-   @Override
    public void runDirectJournalBlast() throws Exception {
       throw new UnsupportedOperationException();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalBase.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalBase.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalBase.java
index e2ca84d..e6bd99e 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalBase.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalBase.java
@@ -21,6 +21,7 @@ import org.apache.activemq.artemis.core.io.DummyCallback;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.IOCompletion;
 import org.apache.activemq.artemis.core.journal.Journal;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding;
 
 abstract class JournalBase implements Journal {
@@ -37,68 +38,15 @@ abstract class JournalBase implements Journal {
    }
 
    @Override
-   public abstract void appendAddRecord(final long id,
-                                        final byte recordType,
-                                        final EncodingSupport record,
-                                        final boolean sync,
-                                        final IOCompletion callback) throws Exception;
-
-   @Override
-   public abstract void appendAddRecordTransactional(final long txID,
-                                                     final long id,
-                                                     final byte recordType,
-                                                     final EncodingSupport record) throws Exception;
-
-   @Override
-   public abstract void appendCommitRecord(final long txID,
-                                           final boolean sync,
-                                           final IOCompletion callback,
-                                           boolean lineUpContext) throws Exception;
-
-   @Override
-   public abstract void appendDeleteRecord(final long id,
-                                           final boolean sync,
-                                           final IOCompletion callback) throws Exception;
-
-   @Override
-   public abstract void appendDeleteRecordTransactional(final long txID,
-                                                        final long id,
-                                                        final EncodingSupport record) throws Exception;
-
-   @Override
-   public abstract void appendPrepareRecord(final long txID,
-                                            final EncodingSupport transactionData,
-                                            final boolean sync,
-                                            final IOCompletion callback) throws Exception;
-
-   @Override
-   public abstract void appendUpdateRecord(final long id,
-                                           final byte recordType,
-                                           final EncodingSupport record,
-                                           final boolean sync,
-                                           final IOCompletion callback) throws Exception;
-
-   @Override
-   public abstract void appendUpdateRecordTransactional(final long txID,
-                                                        final long id,
-                                                        final byte recordType,
-                                                        final EncodingSupport record) throws Exception;
-
-   @Override
-   public abstract void appendRollbackRecord(final long txID,
-                                             final boolean sync,
-                                             final IOCompletion callback) throws Exception;
-
-   @Override
    public void appendAddRecord(long id, byte recordType, byte[] record, boolean sync) throws Exception {
       appendAddRecord(id, recordType, new ByteArrayEncoding(record), sync);
    }
 
    @Override
-   public void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws Exception {
+   public void appendAddRecord(long id, byte recordType, Persister persister, Object record, boolean sync) throws Exception {
       SyncIOCompletion callback = getSyncCallback(sync);
 
-      appendAddRecord(id, recordType, record, sync, callback);
+      appendAddRecord(id, recordType, persister, record, sync, callback);
 
       if (callback != null) {
          callback.waitCompletion();
@@ -176,11 +124,12 @@ abstract class JournalBase implements Journal {
    @Override
    public void appendUpdateRecord(final long id,
                                   final byte recordType,
-                                  final EncodingSupport record,
+                                  final Persister persister,
+                                  final Object record,
                                   final boolean sync) throws Exception {
       SyncIOCompletion callback = getSyncCallback(sync);
 
-      appendUpdateRecord(id, recordType, record, sync, callback);
+      appendUpdateRecord(id, recordType, persister, record, sync, callback);
 
       if (callback != null) {
          callback.waitCompletion();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java
index b95d641..c62b27b 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java
@@ -29,6 +29,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
+import org.apache.activemq.artemis.core.journal.EncoderPersister;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord;
@@ -252,7 +253,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ
    @Override
    public void onReadAddRecord(final RecordInfo info) throws Exception {
       if (lookupRecord(info.id)) {
-         JournalInternalRecord addRecord = new JournalAddRecord(true, info.id, info.getUserRecordType(), new ByteArrayEncoding(info.data));
+         JournalInternalRecord addRecord = new JournalAddRecord(true, info.id, info.getUserRecordType(), EncoderPersister.getInstance(), new ByteArrayEncoding(info.data));
          addRecord.setCompactCount((short) (info.compactCount + 1));
 
          checkSize(addRecord.getEncodeSize(), info.compactCount);
@@ -268,7 +269,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ
       if (pendingTransactions.get(transactionID) != null || lookupRecord(info.id)) {
          JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
 
-         JournalInternalRecord record = new JournalAddRecordTX(true, transactionID, info.id, info.getUserRecordType(), new ByteArrayEncoding(info.data));
+         JournalInternalRecord record = new JournalAddRecordTX(true, transactionID, info.id, info.getUserRecordType(), EncoderPersister.getInstance(),new ByteArrayEncoding(info.data));
 
          record.setCompactCount((short) (info.compactCount + 1));
 
@@ -374,7 +375,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ
    @Override
    public void onReadUpdateRecord(final RecordInfo info) throws Exception {
       if (lookupRecord(info.id)) {
-         JournalInternalRecord updateRecord = new JournalAddRecord(false, info.id, info.userRecordType, new ByteArrayEncoding(info.data));
+         JournalInternalRecord updateRecord = new JournalAddRecord(false, info.id, info.userRecordType, EncoderPersister.getInstance(), new ByteArrayEncoding(info.data));
 
          updateRecord.setCompactCount((short) (info.compactCount + 1));
 
@@ -397,7 +398,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ
       if (pendingTransactions.get(transactionID) != null || lookupRecord(info.id)) {
          JournalTransaction newTransaction = getNewJournalTransaction(transactionID);
 
-         JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, transactionID, info.id, info.userRecordType, new ByteArrayEncoding(info.data));
+         JournalInternalRecord updateRecordTX = new JournalAddRecordTX(false, transactionID, info.id, info.userRecordType, EncoderPersister.getInstance(), new ByteArrayEncoding(info.data));
 
          updateRecordTX.setCompactCount((short) (info.compactCount + 1));
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
index db615f8..24bb916 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
@@ -57,11 +57,11 @@ import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.IOCompletion;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
 import org.apache.activemq.artemis.core.journal.LoaderCallback;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TestableJournal;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
-import org.apache.activemq.artemis.core.journal.impl.dataformat.ByteArrayEncoding;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecord;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalAddRecordTX;
 import org.apache.activemq.artemis.core.journal.impl.dataformat.JournalCompleteRecordTX;
@@ -713,7 +713,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
    @Override
    public void appendAddRecord(final long id,
                                final byte recordType,
-                               final EncodingSupport record,
+                               final Persister persister,
+                               final Object record,
                                final boolean sync,
                                final IOCompletion callback) throws Exception {
       checkJournalIsLoaded();
@@ -727,7 +728,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
          public void run() {
             journalLock.readLock().lock();
             try {
-               JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, record);
+               JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, persister, record);
                JournalFile usedFile = appendRecord(addRecord, false, sync, null, callback);
                records.put(id, new JournalRecord(usedFile, addRecord.getEncodeSize()));
 
@@ -762,7 +763,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
    @Override
    public void appendUpdateRecord(final long id,
                                   final byte recordType,
-                                  final EncodingSupport record,
+                                  final Persister persister,
+                                  final Object record,
                                   final boolean sync,
                                   final IOCompletion callback) throws Exception {
       checkJournalIsLoaded();
@@ -777,7 +779,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
             journalLock.readLock().lock();
             try {
                JournalRecord jrnRecord = records.get(id);
-               JournalInternalRecord updateRecord = new JournalAddRecord(false, id, recordType, record);
+               JournalInternalRecord updateRecord = new JournalAddRecord(false, id, recordType, persister, record);
                JournalFile usedFile = appendRecord(updateRecord, false, sync, null, callback);
 
                if (logger.isTraceEnabled()) {
@@ -873,7 +875,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
    public void appendAddRecordTransactional(final long txID,
                                             final long id,
                                             final byte recordType,
-                                            final EncodingSupport record) throws Exception {
+                                            final Persister persister,
+                                            final Object record) throws Exception {
       checkJournalIsLoaded();
 
       final JournalTransaction tx = getTransactionInfo(txID);
@@ -885,7 +888,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
          public void run() {
             journalLock.readLock().lock();
             try {
-               JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, record);
+               JournalInternalRecord addRecord = new JournalAddRecordTX(true, txID, id, recordType, persister, record);
                JournalFile usedFile = appendRecord(addRecord, false, false, tx, null);
 
                if (logger.isTraceEnabled()) {
@@ -952,7 +955,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
    public void appendUpdateRecordTransactional(final long txID,
                                                final long id,
                                                final byte recordType,
-                                               final EncodingSupport record) throws Exception {
+                                               final Persister persister,
+                                               final Object record) throws Exception {
       checkJournalIsLoaded();
 
       final JournalTransaction tx = getTransactionInfo(txID);
@@ -965,7 +969,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
             journalLock.readLock().lock();
             try {
 
-               JournalInternalRecord updateRecordTX = new JournalAddRecordTX( false, txID, id, recordType, record );
+               JournalInternalRecord updateRecordTX = new JournalAddRecordTX( false, txID, id, recordType, persister, record );
                JournalFile usedFile = appendRecord( updateRecordTX, false, false, tx, null );
 
                if ( logger.isTraceEnabled() ) {
@@ -2165,45 +2169,6 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
       }
    }
 
-   @Override
-   public void perfBlast(final int pages) {
-
-      checkJournalIsLoaded();
-
-      final ByteArrayEncoding byteEncoder = new ByteArrayEncoding(new byte[128 * 1024]);
-
-      final JournalInternalRecord blastRecord = new JournalInternalRecord() {
-
-         @Override
-         public int getEncodeSize() {
-            return byteEncoder.getEncodeSize();
-         }
-
-         @Override
-         public void encode(final ActiveMQBuffer buffer) {
-            byteEncoder.encode(buffer);
-         }
-      };
-
-      appendExecutor.execute(new Runnable() {
-         @Override
-         public void run() {
-            journalLock.readLock().lock();
-            try {
-
-               for (int i = 0; i < pages; i++) {
-                  appendRecord(blastRecord, false, false, null, null);
-               }
-
-            } catch (Exception e) {
-               ActiveMQJournalLogger.LOGGER.failedToPerfBlast(e);
-            } finally {
-               journalLock.readLock().unlock();
-            }
-         }
-      });
-   }
-
    // ActiveMQComponent implementation
    // ---------------------------------------------------
 
@@ -2921,5 +2886,4 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
    public int getCompactCount() {
       return compactCount;
    }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java
index c6a5d4a..6e5b651 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecord.java
@@ -17,14 +17,16 @@
 package org.apache.activemq.artemis.core.journal.impl.dataformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
 
 public class JournalAddRecord extends JournalInternalRecord {
 
    protected final long id;
 
-   protected final EncodingSupport record;
+   protected final Persister persister;
+
+   protected final Object record;
 
    protected final byte recordType;
 
@@ -35,7 +37,7 @@ public class JournalAddRecord extends JournalInternalRecord {
     * @param recordType
     * @param record
     */
-   public JournalAddRecord(final boolean add, final long id, final byte recordType, final EncodingSupport record) {
+   public JournalAddRecord(final boolean add, final long id, final byte recordType, final Persister persister, Object record) {
       this.id = id;
 
       this.record = record;
@@ -43,6 +45,8 @@ public class JournalAddRecord extends JournalInternalRecord {
       this.recordType = recordType;
 
       this.add = add;
+
+      this.persister = persister;
    }
 
    @Override
@@ -59,17 +63,19 @@ public class JournalAddRecord extends JournalInternalRecord {
 
       buffer.writeLong(id);
 
-      buffer.writeInt(record.getEncodeSize());
+      int recordEncodeSize = persister.getEncodeSize(record);
+
+      buffer.writeInt(persister.getEncodeSize(record));
 
       buffer.writeByte(recordType);
 
-      record.encode(buffer);
+      persister.encode(buffer, record);
 
-      buffer.writeInt(getEncodeSize());
+      buffer.writeInt(recordEncodeSize + JournalImpl.SIZE_ADD_RECORD + 1);
    }
 
    @Override
    public int getEncodeSize() {
-      return JournalImpl.SIZE_ADD_RECORD + record.getEncodeSize() + 1;
+      return JournalImpl.SIZE_ADD_RECORD + persister.getEncodeSize(record) + 1;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
index 6cec122..483418f 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/dataformat/JournalAddRecordTX.java
@@ -17,7 +17,7 @@
 package org.apache.activemq.artemis.core.journal.impl.dataformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
 
 public class JournalAddRecordTX extends JournalInternalRecord {
@@ -26,7 +26,9 @@ public class JournalAddRecordTX extends JournalInternalRecord {
 
    private final long id;
 
-   private final EncodingSupport record;
+   protected final Persister persister;
+
+   protected final Object record;
 
    private final byte recordType;
 
@@ -41,12 +43,15 @@ public class JournalAddRecordTX extends JournalInternalRecord {
                              final long txID,
                              final long id,
                              final byte recordType,
-                             final EncodingSupport record) {
+                             final Persister persister,
+                             Object record) {
 
       this.txID = txID;
 
       this.id = id;
 
+      this.persister = persister;
+
       this.record = record;
 
       this.recordType = recordType;
@@ -70,17 +75,17 @@ public class JournalAddRecordTX extends JournalInternalRecord {
 
       buffer.writeLong(id);
 
-      buffer.writeInt(record.getEncodeSize());
+      buffer.writeInt(persister.getEncodeSize(record));
 
       buffer.writeByte(recordType);
 
-      record.encode(buffer);
+      persister.encode(buffer, record);
 
       buffer.writeInt(getEncodeSize());
    }
 
    @Override
    public int getEncodeSize() {
-      return JournalImpl.SIZE_ADD_RECORD_TX + record.getEncodeSize() + 1;
+      return JournalImpl.SIZE_ADD_RECORD_TX + persister.getEncodeSize(record) + 1;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
new file mode 100644
index 0000000..ee2f870
--- /dev/null
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -0,0 +1,761 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.protocol.amqp.broker;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Set;
+
+import io.netty.buffer.ByteBuf;
+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.ActiveMQException;
+import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
+import org.apache.activemq.artemis.api.core.RefCountMessage;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.encode.BodyType;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
+import org.apache.activemq.artemis.utils.DataConstants;
+import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
+import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
+import org.apache.qpid.proton.amqp.messaging.Header;
+import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+import org.apache.qpid.proton.amqp.messaging.Section;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.message.Message;
+import org.apache.qpid.proton.message.impl.MessageImpl;
+import org.apache.qpid.proton.util.TLSEncoder;
+
+// see https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
+public class AMQPMessage extends RefCountMessage {
+
+   final long messageFormat;
+   private ProtonProtocolManager protocolManager;
+   ByteBuf data;
+   boolean bufferValid;
+   byte type;
+   long messageID;
+   String address;
+   MessageImpl protonMessage;
+   private long expiration = 0;
+   // this can be used to encode the header again and the rest of the message buffer
+   private int headerEnd = -1;
+   private Header _header;
+   private DeliveryAnnotations _deliveryAnnotations;
+   private MessageAnnotations _messageAnnotations;
+   private Properties _properties;
+   private ApplicationProperties applicationProperties;
+
+   public AMQPMessage(long messageFormat, byte[] data, ProtonProtocolManager protocolManager) {
+      this.protocolManager = protocolManager;
+      this.data = Unpooled.wrappedBuffer(data);
+      this.messageFormat = messageFormat;
+      this.bufferValid = true;
+
+   }
+
+   /** for persistence reload */
+   public AMQPMessage(long messageFormat) {
+      this.messageFormat = messageFormat;
+      this.bufferValid = false;
+
+   }
+
+   public AMQPMessage(long messageFormat, Message message, ProtonProtocolManager protocolManager) {
+      this.protocolManager = protocolManager;
+      this.protonMessage = (MessageImpl)message;
+      this.messageFormat = messageFormat;
+
+   }
+
+   public AMQPMessage(Message message, ProtonProtocolManager protocolManager) {
+      this(0, message, protocolManager);
+   }
+
+   public MessageImpl getProtonMessage() {
+      if (protonMessage == null) {
+         protonMessage = (MessageImpl) Message.Factory.create();
+
+         if (data != null) {
+            data.readerIndex(0);
+            protonMessage.decode(data.nioBuffer());
+            this._header = protonMessage.getHeader();
+            protonMessage.setHeader(null);
+         }
+      }
+
+      return protonMessage;
+   }
+
+   private void initalizeObjects() {
+      if (protonMessage == null) {
+         if (data == null) {
+            this.headerEnd = -1;
+            _header = new Header();
+            _deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
+            _properties = new Properties();
+            this.applicationProperties = new ApplicationProperties(new HashMap<>());
+            this.protonMessage = (MessageImpl)Message.Factory.create();
+            this.protonMessage.setApplicationProperties(applicationProperties);
+            this.protonMessage.setDeliveryAnnotations(_deliveryAnnotations);
+         }
+      }
+   }
+
+   private ApplicationProperties getApplicationProperties() {
+      if (applicationProperties == null) {
+         if (data != null) {
+            partialDecode(data.nioBuffer(), true);
+         } else {
+            initalizeObjects();
+         }
+      }
+
+      return applicationProperties;
+   }
+
+   public Header getHeader() {
+      if (_header == null) {
+         if (data == null) {
+            initalizeObjects();
+         } else {
+            partialDecode(this.data.nioBuffer(), false);
+         }
+      }
+
+      return _header;
+   }
+
+   public Properties getProperties() {
+      if (_properties == null) {
+         if (data == null) {
+            initalizeObjects();
+         } else {
+            partialDecode(this.data.nioBuffer(), true);
+         }
+      }
+
+      return _properties;
+   }
+
+   @Override
+   public Persister<org.apache.activemq.artemis.api.core.Message> getPersister() {
+      return AMQPMessagePersister.getInstance();
+   }
+
+   private synchronized void partialDecode(ByteBuffer buffer, boolean readApplicationProperties) {
+      DecoderImpl decoder = TLSEncoder.getDecoder();
+      decoder.setByteBuffer(buffer);
+      buffer.position(0);
+
+      _header = null;
+      _deliveryAnnotations = null;
+      _messageAnnotations = null;
+      _properties = null;
+      applicationProperties = null;
+      Section section = null;
+
+      try {
+         if (buffer.hasRemaining()) {
+            section = (Section) decoder.readObject();
+         }
+
+         if (section instanceof Header) {
+            headerEnd = buffer.position();
+            _header = (Header) section;
+
+            if (!readApplicationProperties) {
+               return;
+            }
+
+            if (buffer.hasRemaining() && readApplicationProperties) {
+               section = (Section) decoder.readObject();
+            } else {
+               section = null;
+            }
+         }
+
+         if (!readApplicationProperties) {
+            return;
+         }
+         if (section instanceof DeliveryAnnotations) {
+            _deliveryAnnotations = (DeliveryAnnotations) section;
+
+            if (buffer.hasRemaining()) {
+               section = (Section) decoder.readObject();
+            } else {
+               section = null;
+            }
+
+         }
+         if (section instanceof MessageAnnotations) {
+            _messageAnnotations = (MessageAnnotations) section;
+
+            if (buffer.hasRemaining()) {
+               section = (Section) decoder.readObject();
+            } else {
+               section = null;
+            }
+
+         }
+         if (section instanceof Properties) {
+            _properties = (Properties) section;
+
+            if (_header.getTtl() != null) {
+               this.expiration = System.currentTimeMillis() + _header.getTtl().intValue();
+            }
+
+            if (buffer.hasRemaining()) {
+               section = (Section) decoder.readObject();
+            } else {
+               section = null;
+            }
+
+         }
+         if (section instanceof ApplicationProperties) {
+            applicationProperties = (ApplicationProperties) section;
+         }
+      } finally {
+         decoder.setByteBuffer(null);
+      }
+   }
+
+   public long getMessageFormat() {
+      return messageFormat;
+   }
+
+   public int getLength() {
+      return data.array().length;
+   }
+
+   public byte[] getArray() {
+      return data.array();
+   }
+
+   @Override
+   public void messageChanged() {
+      bufferValid = false;
+      this.data = null;
+   }
+
+   // TODO-now this only make sense on Core
+   @Override
+   public ActiveMQBuffer getBodyBuffer() {
+      return null;
+   }
+
+   // TODO-now this only make sense on Core
+   @Override
+   public ActiveMQBuffer getReadOnlyBodyBuffer() {
+      return null;
+   }
+
+   // TODO: Refactor Large message
+   @Override
+   public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
+      return null;
+   }
+
+   @Override
+   public byte getType() {
+      // TODO-now: what to do here?
+      return type;
+   }
+
+   @Override
+   public AMQPMessage setType(byte type) {
+      this.type = type;
+      return this;
+   }
+
+   @Override
+   public boolean isLargeMessage() {
+      return false;
+   }
+
+   @Override
+   public ByteBuf getBuffer() {
+      if (data == null) {
+         return null;
+      } else {
+         return Unpooled.wrappedBuffer(data);
+      }
+   }
+
+   @Override
+   public AMQPMessage setBuffer(ByteBuf buffer) {
+      this.data = null;
+      return this;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message copy() {
+      // TODO-now: what to do with this?
+      AMQPMessage newEncode = new AMQPMessage(this.messageFormat, data.array(), protocolManager);
+      return newEncode;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message copy(long newID) {
+      return copy().setMessageID(newID);
+   }
+
+   @Override
+   public long getMessageID() {
+      return messageID;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setMessageID(long id) {
+      this.messageID = id;
+      return this;
+   }
+
+   @Override
+   public long getExpiration() {
+      return expiration;
+   }
+
+   @Override
+   public AMQPMessage setExpiration(long expiration) {
+      this.expiration = expiration;
+      return this;
+   }
+
+   @Override
+   public Object getUserID() {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setUserID(Object userID) {
+      return null;
+   }
+
+   @Override
+   public void copyHeadersAndProperties(org.apache.activemq.artemis.api.core.Message msg) {
+
+   }
+
+   @Override
+   public boolean isDurable() {
+      if (getHeader() != null) {
+         return getHeader().getDurable().booleanValue();
+      } else {
+         return false;
+      }
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setDurable(boolean durable) {
+      return null;
+   }
+
+   @Override
+   public Object getProtocol() {
+      return protocolManager;
+   }
+
+   @Override
+   public AMQPMessage setProtocol(Object protocol) {
+      this.protocolManager = (ProtonProtocolManager)protocol;
+      return this;
+   }
+
+   @Override
+   public Object getBody() {
+      return null;
+   }
+
+   @Override
+   public BodyType getBodyType() {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setBody(BodyType type, Object body) {
+      return null;
+   }
+
+   @Override
+   public String getAddress() {
+      if (address == null) {
+         Properties properties = getProtonMessage().getProperties();
+         if (properties != null) {
+            return  properties.getTo();
+         } else {
+            return null;
+         }
+      } else {
+         return address;
+      }
+   }
+
+   @Override
+   public AMQPMessage setAddress(SimpleString address) {
+      return setAddress(address.toString());
+   }
+
+   @Override
+   public AMQPMessage setAddress(String address) {
+      this.address = address;
+      return this;
+   }
+
+   @Override
+   public SimpleString getAddressSimpleString() {
+      return SimpleString.toSimpleString(getAddress());
+   }
+
+   @Override
+   public long getTimestamp() {
+      return 0;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setTimestamp(long timestamp) {
+      return null;
+   }
+
+   @Override
+   public byte getPriority() {
+      return 0;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message setPriority(byte priority) {
+      return null;
+   }
+
+   @Override
+   public void receiveBuffer(ByteBuf buffer) {
+
+   }
+
+   private synchronized void checkBuffer() {
+      if (!bufferValid) {
+         ByteBuf buffer = PooledByteBufAllocator.DEFAULT.heapBuffer(1500);
+         try {
+            getProtonMessage().encode(new NettyWritable(buffer));
+            byte[] bytes = new byte[buffer.writerIndex()];
+            buffer.readBytes(bytes);
+            this.data = Unpooled.wrappedBuffer(bytes);
+         } finally {
+            buffer.release();
+         }
+      }
+   }
+
+   @Override
+   public void sendBuffer(ByteBuf buffer, int deliveryCount) {
+      // TODO: do I need to change the Header with deliveryCount?
+      //       I would send a new instance of Header with a new delivery count, and only send partial of the buffer
+      //       previously received
+      checkBuffer();
+      buffer.writeBytes(data);
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putBooleanProperty(String key, boolean value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putByteProperty(String key, byte value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putBytesProperty(String key, byte[] value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putShortProperty(String key, short value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putCharProperty(String key, char value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putIntProperty(String key, int value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putLongProperty(String key, long value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putFloatProperty(String key, float value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putDoubleProperty(String key, double value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putBooleanProperty(SimpleString key, boolean value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putByteProperty(SimpleString key, byte value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putBytesProperty(SimpleString key, byte[] value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putShortProperty(SimpleString key, short value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putCharProperty(SimpleString key, char value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putIntProperty(SimpleString key, int value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putLongProperty(SimpleString key, long value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putFloatProperty(SimpleString key, float value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putDoubleProperty(SimpleString key, double value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putStringProperty(String key, String value) {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putObjectProperty(String key,
+                                                                         Object value) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putObjectProperty(SimpleString key,
+                                                                         Object value) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Object removeProperty(String key) {
+      return null;
+   }
+
+   @Override
+   public boolean containsProperty(String key) {
+      return false;
+   }
+
+   @Override
+   public Boolean getBooleanProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Byte getByteProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Double getDoubleProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Integer getIntProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Long getLongProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Object getObjectProperty(String key) {
+      return null;
+   }
+
+   @Override
+   public Short getShortProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Float getFloatProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public String getStringProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public SimpleString getSimpleStringProperty(String key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException {
+      return new byte[0];
+   }
+
+   @Override
+   public Object removeProperty(SimpleString key) {
+      return null;
+   }
+
+   @Override
+   public boolean containsProperty(SimpleString key) {
+      return false;
+   }
+
+   @Override
+   public Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Object getObjectProperty(SimpleString key) {
+      return null;
+   }
+
+   @Override
+   public Short getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return null;
+   }
+
+   @Override
+   public byte[] getBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException {
+      return new byte[0];
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message putStringProperty(SimpleString key, SimpleString value) {
+      return null;
+   }
+
+   @Override
+   public int getEncodeSize() {
+      return 0;
+   }
+
+   @Override
+   public Set<SimpleString> getPropertyNames() {
+      return Collections.emptySet();
+   }
+
+   @Override
+   public int getMemoryEstimate() {
+      return 0;
+   }
+
+   @Override
+   public org.apache.activemq.artemis.api.core.Message toCore() {
+      MessageImpl protonMessage = getProtonMessage();
+      return null;
+   }
+
+   @Override
+   public int getPersistSize() {
+      checkBuffer();
+      return data.array().length + DataConstants.SIZE_INT;
+   }
+
+   @Override
+   public void persist(ActiveMQBuffer targetRecord) {
+      checkBuffer();
+      targetRecord.writeInt(data.array().length);
+      targetRecord.writeBytes(data.array());
+   }
+
+   @Override
+   public void reloadPersistence(ActiveMQBuffer record) {
+      int size = record.readInt();
+      byte[] recordArray = new byte[size];
+      record.readBytes(recordArray);
+      this.data = Unpooled.wrappedBuffer(recordArray);
+      this.bufferValid = true;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessagePersister.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessagePersister.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessagePersister.java
new file mode 100644
index 0000000..3b5bdda
--- /dev/null
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessagePersister.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.protocol.amqp.broker;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
+import org.apache.activemq.artemis.utils.DataConstants;
+
+public class AMQPMessagePersister extends MessagePersister {
+
+   public static AMQPMessagePersister theInstance = new AMQPMessagePersister();
+
+   public static AMQPMessagePersister getInstance() {
+      return theInstance;
+   }
+
+   private AMQPMessagePersister() {
+   }
+
+   @Override
+   protected byte getID() {
+      return ProtonProtocolManagerFactory.ID;
+   }
+
+   @Override
+   public int getEncodeSize(Message record) {
+      return DataConstants.SIZE_BYTE + record.getPersistSize() +
+         SimpleString.sizeofNullableString(record.getAddressSimpleString()) + DataConstants.SIZE_LONG + DataConstants.SIZE_LONG;
+   }
+
+
+   /** Sub classes must add the first short as the protocol-id */
+   @Override
+   public void encode(ActiveMQBuffer buffer, Message record) {
+      super.encode(buffer, record);
+      AMQPMessage msgEncode = (AMQPMessage)record;
+      buffer.writeLong(record.getMessageID());
+      buffer.writeLong(msgEncode.getMessageFormat());
+      buffer.writeNullableSimpleString(record.getAddressSimpleString());
+      record.persist(buffer);
+   }
+
+
+   @Override
+   public Message decode(ActiveMQBuffer buffer, Message record) {
+      long id = buffer.readLong();
+      long format = buffer.readLong();
+      SimpleString address = buffer.readNullableSimpleString();
+      record = new AMQPMessage(format);
+      record.reloadPersistence(buffer);
+      record.setMessageID(id);
+      if (address != null) {
+         record.setAddress(address);
+      }
+      return record;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java
----------------------------------------------------------------------
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 18c6b05..0b02838 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
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.core.io.IOCallback;
@@ -34,14 +35,12 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
 import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter;
-import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException;
@@ -69,7 +68,6 @@ import org.apache.qpid.proton.codec.WritableBuffer;
 import org.apache.qpid.proton.engine.Delivery;
 import org.apache.qpid.proton.engine.EndpointState;
 import org.apache.qpid.proton.engine.Receiver;
-import io.netty.buffer.ByteBuf;
 import org.jboss.logging.Logger;
 
 public class AMQPSessionCallback implements SessionCallback {
@@ -298,11 +296,11 @@ public class AMQPSessionCallback implements SessionCallback {
       }
    }
 
-   public long encodeMessage(Object message, int deliveryCount, WritableBuffer buffer) throws Exception {
+   public long encodeMessage(Message message, int deliveryCount, WritableBuffer buffer) throws Exception {
       ProtonMessageConverter converter = (ProtonMessageConverter) manager.getConverter();
 
       // The Proton variant accepts a WritableBuffer to allow for a faster more direct encode.
-      return (long) converter.outbound((ServerMessage) message, deliveryCount, buffer);
+      return (long) converter.outbound(message, deliveryCount, buffer);
    }
 
    public String tempQueueName() {
@@ -321,22 +319,22 @@ public class AMQPSessionCallback implements SessionCallback {
       }
    }
 
-   public void ack(Transaction transaction, Object brokerConsumer, Object message) throws Exception {
+   public void ack(Transaction transaction, Object brokerConsumer, Message message) throws Exception {
       if (transaction == null) {
          transaction = serverSession.getCurrentTransaction();
       }
       recoverContext();
       try {
-         ((ServerConsumer) brokerConsumer).individualAcknowledge(transaction, ((ServerMessage) message).getMessageID());
+         ((ServerConsumer) brokerConsumer).individualAcknowledge(transaction, message.getMessageID());
       } finally {
          resetContext();
       }
    }
 
-   public void cancel(Object brokerConsumer, Object message, boolean updateCounts) throws Exception {
+   public void cancel(Object brokerConsumer, Message message, boolean updateCounts) throws Exception {
       recoverContext();
       try {
-         ((ServerConsumer) brokerConsumer).individualCancel(((ServerMessage) message).getMessageID(), updateCounts);
+         ((ServerConsumer) brokerConsumer).individualCancel(message.getMessageID(), updateCounts);
       } finally {
          resetContext();
       }
@@ -351,11 +349,8 @@ public class AMQPSessionCallback implements SessionCallback {
                           final Delivery delivery,
                           String address,
                           int messageFormat,
-                          ByteBuf messageEncoded) throws Exception {
-      EncodedMessage encodedMessage = new EncodedMessage(messageFormat, messageEncoded.array(), messageEncoded.arrayOffset(), messageEncoded.writerIndex());
-
-      ServerMessage message = manager.getConverter().inbound(encodedMessage);
-      //use the address on the receiver if not null, if null let's hope it was set correctly on the message
+                          byte[] data) throws Exception {
+      AMQPMessage message = new AMQPMessage(messageFormat, data, manager);
       if (address != null) {
          message.setAddress(new SimpleString(address));
       } else {
@@ -372,7 +367,7 @@ public class AMQPSessionCallback implements SessionCallback {
 
       recoverContext();
 
-      PagingStore store = manager.getServer().getPagingManager().getPageStore(message.getAddress());
+      PagingStore store = manager.getServer().getPagingManager().getPageStore(message.getAddressSimpleString());
       if (store.isRejectingMessages()) {
          // We drop pre-settled messages (and abort any associated Tx)
          if (delivery.remotelySettled()) {
@@ -401,7 +396,7 @@ public class AMQPSessionCallback implements SessionCallback {
    }
 
    private void serverSend(final Transaction transaction,
-                           final ServerMessage message,
+                           final Message message,
                            final Delivery delivery,
                            final Receiver receiver) throws Exception {
       try {
@@ -416,8 +411,8 @@ public class AMQPSessionCallback implements SessionCallback {
                synchronized (connection.getLock()) {
                   delivery.disposition(Accepted.getInstance());
                   delivery.settle();
-                  connection.flush();
                }
+               connection.flush(true);
             }
 
             @Override
@@ -492,7 +487,7 @@ public class AMQPSessionCallback implements SessionCallback {
    }
 
    @Override
-   public int sendMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, int deliveryCount) {
+   public int sendMessage(MessageReference ref, Message message, ServerConsumer consumer, int deliveryCount) {
 
       message.removeProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString());
 
@@ -512,7 +507,7 @@ public class AMQPSessionCallback implements SessionCallback {
 
    @Override
    public int sendLargeMessage(MessageReference ref,
-                               ServerMessage message,
+                               Message message,
                                ServerConsumer consumer,
                                long bodySize,
                                int deliveryCount) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java
index bef8ef0..98ec228 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java
@@ -22,6 +22,8 @@ import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.Interceptor;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.spi.core.protocol.AbstractProtocolManagerFactory;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
@@ -32,6 +34,8 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ProtocolManagerFactory.class)
 public class ProtonProtocolManagerFactory extends AbstractProtocolManagerFactory<Interceptor> {
 
+   public static final byte ID = 2;
+
    private static final String AMQP_PROTOCOL_NAME = "AMQP";
 
    private static final String MODULE_NAME = "artemis-amqp-protocol";
@@ -39,6 +43,16 @@ public class ProtonProtocolManagerFactory extends AbstractProtocolManagerFactory
    private static String[] SUPPORTED_PROTOCOLS = {AMQP_PROTOCOL_NAME};
 
    @Override
+   public byte getStoreID() {
+      return ID;
+   }
+
+   @Override
+   public Persister<Message> getPersister() {
+      return AMQPMessagePersister.getInstance();
+   }
+
+   @Override
    public ProtocolManager createProtocolManager(ActiveMQServer server,
                                                 final Map<String, Object> parameters,
                                                 List<BaseInterceptor> incomingInterceptors,


[10/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
index 923e719..905e550 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java
@@ -33,10 +33,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
@@ -49,10 +51,8 @@ import org.apache.activemq.artemis.core.paging.impl.PageTransactionInfoImpl;
 import org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
@@ -152,7 +152,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       buffers.add(buffer);
       SimpleString destination = new SimpleString("test");
 
-      ServerMessage msg = createMessage(1, storeImpl, destination, buffer);
+      Message msg = createMessage(1, storeImpl, destination, buffer);
 
       Assert.assertTrue(storeImpl.isPaging());
 
@@ -197,7 +197,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
 
          buffers.add(buffer);
 
-         ServerMessage msg = createMessage(i, storeImpl, destination, buffer);
+         Message msg = createMessage(i, storeImpl, destination, buffer);
          final RoutingContextImpl ctx = new RoutingContextImpl(null);
          Assert.assertTrue(storeImpl.page(msg, ctx.getTransaction(), ctx.getContextListing(storeImpl.getStoreName()), lock));
 
@@ -263,7 +263,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
             store.forceAnotherPage();
          }
 
-         ServerMessage msg = createMessage(i, store, destination, buffer);
+         Message msg = createMessage(i, store, destination, buffer);
 
          final RoutingContextImpl ctx = new RoutingContextImpl(null);
          Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
@@ -298,7 +298,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
 
       Assert.assertTrue(store.isPaging());
 
-      ServerMessage msg = createMessage(1, store, destination, buffers.get(0));
+      Message msg = createMessage(1, store, destination, buffers.get(0));
 
       final RoutingContextImpl ctx = new RoutingContextImpl(null);
       Assert.assertTrue(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
@@ -374,7 +374,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
 
       final CountDownLatch latchStart = new CountDownLatch(numberOfThreads);
 
-      final ConcurrentHashMap<Long, ServerMessage> buffers = new ConcurrentHashMap<>();
+      final ConcurrentHashMap<Long, Message> buffers = new ConcurrentHashMap<>();
 
       final ArrayList<Page> readPages = new ArrayList<>();
 
@@ -408,7 +408,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
                   // Each thread will Keep paging until all the messages are depaged.
                   // This is possible because the depage thread is not actually reading the pages.
                   // Just using the internal API to remove it from the page file system
-                  ServerMessage msg = createMessage(id, storeImpl, destination, createRandomBuffer(id, 5));
+                  Message msg = createMessage(id, storeImpl, destination, createRandomBuffer(id, 5));
                   final RoutingContextImpl ctx2 = new RoutingContextImpl(null);
                   if (storeImpl.page(msg, ctx2.getTransaction(), ctx2.getContextListing(storeImpl.getStoreName()), lock)) {
                      buffers.put(id, msg);
@@ -477,7 +477,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
          throw consumer.e;
       }
 
-      final ConcurrentMap<Long, ServerMessage> buffers2 = new ConcurrentHashMap<>();
+      final ConcurrentMap<Long, Message> buffers2 = new ConcurrentHashMap<>();
 
       for (Page page : readPages) {
          page.open();
@@ -488,10 +488,10 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
             long id = msg.getMessage().getBodyBuffer().readLong();
             msg.getMessage().getBodyBuffer().resetReaderIndex();
 
-            ServerMessage msgWritten = buffers.remove(id);
+            Message msgWritten = buffers.remove(id);
             buffers2.put(id, msg.getMessage());
             Assert.assertNotNull(msgWritten);
-            Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddress());
+            Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddressSimpleString());
             ActiveMQTestBase.assertEqualsBuffers(10, msgWritten.getBodyBuffer(), msg.getMessage().getBodyBuffer());
          }
       }
@@ -522,7 +522,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       Assert.assertEquals(numberOfPages, storeImpl2.getNumberOfPages());
 
       long lastMessageId = messageIdGenerator.incrementAndGet();
-      ServerMessage lastMsg = createMessage(lastMessageId, storeImpl, destination, createRandomBuffer(lastMessageId, 5));
+      Message lastMsg = createMessage(lastMessageId, storeImpl, destination, createRandomBuffer(lastMessageId, 5));
 
       storeImpl2.forceAnotherPage();
 
@@ -548,9 +548,9 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
          for (PagedMessage msg : msgs) {
 
             long id = msg.getMessage().getBodyBuffer().readLong();
-            ServerMessage msgWritten = buffers2.remove(id);
+            Message msgWritten = buffers2.remove(id);
             Assert.assertNotNull(msgWritten);
-            Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddress());
+            Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddressSimpleString());
             ActiveMQTestBase.assertEqualsByteArrays(msgWritten.getBodyBuffer().writerIndex(), msgWritten.getBodyBuffer().toByteBuffer().array(), msg.getMessage().getBodyBuffer().toByteBuffer().array());
          }
       }
@@ -643,7 +643,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
                   // Each thread will Keep paging until all the messages are depaged.
                   // This is possible because the depage thread is not actually reading the pages.
                   // Just using the internal API to remove it from the page file system
-                  ServerMessage msg = createMessage(i, store, destination, createRandomBuffer(i, 1024));
+                  Message msg = createMessage(i, store, destination, createRandomBuffer(i, 1024));
                   msg.putLongProperty("count", i);
 
                   final RoutingContextImpl ctx2 = new RoutingContextImpl(null);
@@ -681,7 +681,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
                      List<PagedMessage> messages = page.read(new NullStorageManager());
 
                      for (PagedMessage pgmsg : messages) {
-                        ServerMessage msg = pgmsg.getMessage();
+                        Message msg = pgmsg.getMessage();
 
                         Assert.assertEquals(msgsRead++, msg.getMessageID());
 
@@ -739,15 +739,15 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
       };
    }
 
-   private ServerMessage createMessage(final long id,
+   private Message createMessage(final long id,
                                        final PagingStore store,
                                        final SimpleString destination,
                                        final ActiveMQBuffer buffer) {
-      ServerMessage msg = new ServerMessageImpl(id, 50 + buffer.capacity());
+      Message msg = new CoreMessage(id, 50 + buffer.capacity());
 
       msg.setAddress(destination);
 
-      msg.setPagingStore(store);
+      msg.setContext(store);
 
       msg.getBodyBuffer().resetReaderIndex();
       msg.getBodyBuffer().resetWriterIndex();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java
index 8cc138d..830e61f 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java
@@ -22,8 +22,10 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.postoffice.BindingType;
 import org.apache.activemq.artemis.core.postoffice.Bindings;
@@ -31,10 +33,8 @@ import org.apache.activemq.artemis.core.postoffice.impl.BindingsImpl;
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.RefsOperation;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionOperation;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -91,9 +91,9 @@ public class BindingsImplTest extends ActiveMQTestBase {
 
       for (int i = 0; i < 100; i++) {
          if (route) {
-            bind.route(new ServerMessageImpl(i, 100), new RoutingContextImpl(new FakeTransaction()));
+            bind.route(new CoreMessage(i, 100), new RoutingContextImpl(new FakeTransaction()));
          } else {
-            bind.redistribute(new ServerMessageImpl(i, 100), queue, new RoutingContextImpl(new FakeTransaction()));
+            bind.redistribute(new CoreMessage(i, 100), queue, new RoutingContextImpl(new FakeTransaction()));
          }
       }
    }
@@ -273,7 +273,7 @@ public class BindingsImplTest extends ActiveMQTestBase {
        * @see org.apache.activemq.artemis.core.filter.Filter#match(org.apache.activemq.artemis.core.server.ServerMessage)
        */
       @Override
-      public boolean match(final ServerMessage message) {
+      public boolean match(final Message message) {
          return false;
       }
 
@@ -372,12 +372,12 @@ public class BindingsImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public boolean isHighAcceptPriority(final ServerMessage message) {
+      public boolean isHighAcceptPriority(final Message message) {
          return false;
       }
 
       @Override
-      public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+      public void route(final Message message, final RoutingContext context) throws Exception {
 
       }
 
@@ -395,7 +395,7 @@ public class BindingsImplTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void routeWithAck(ServerMessage message, RoutingContext context) {
+      public void routeWithAck(Message message, RoutingContext context) {
 
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/FakeQueue.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/FakeQueue.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/FakeQueue.java
index 8171e39..66bdddb 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/FakeQueue.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/FakeQueue.java
@@ -22,6 +22,8 @@ import java.util.Set;
 import java.util.concurrent.Executor;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@@ -30,7 +32,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.AckReason;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
@@ -539,18 +540,18 @@ public class FakeQueue implements Queue {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       // no-op
 
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) {
+   public void routeWithAck(Message message, RoutingContext context) {
 
    }
 
    @Override
-   public boolean hasMatchingConsumer(final ServerMessage message) {
+   public boolean hasMatchingConsumer(final Message message) {
       // no-op
       return false;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java
index 3718afb..b74a4c0 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.tests.unit.core.postoffice.impl;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.postoffice.Binding;
@@ -29,7 +30,6 @@ import org.apache.activemq.artemis.core.postoffice.impl.WildcardAddressManager;
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Test;
@@ -132,7 +132,7 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase {
       }
 
       @Override
-      public boolean isHighAcceptPriority(ServerMessage message) {
+      public boolean isHighAcceptPriority(Message message) {
          return false;
       }
 
@@ -152,7 +152,7 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void route(ServerMessage message, RoutingContext context) throws Exception {
+      public void route(Message message, RoutingContext context) throws Exception {
       }
 
       @Override
@@ -170,7 +170,7 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void routeWithAck(ServerMessage message, RoutingContext context) {
+      public void routeWithAck(Message message, RoutingContext context) {
 
       }
    }
@@ -204,14 +204,14 @@ public class WildcardAddressManagerUnitTest extends ActiveMQTestBase {
       }
 
       @Override
-      public boolean redistribute(ServerMessage message,
+      public boolean redistribute(Message message,
                                   Queue originatingQueue,
                                   RoutingContext context) throws Exception {
          return false;
       }
 
       @Override
-      public void route(ServerMessage message, RoutingContext context) throws Exception {
+      public void route(Message message, RoutingContext context) throws Exception {
          System.out.println("routing message: " + message);
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java
index 804429f..78179a8 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java
@@ -25,6 +25,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.api.core.client.ClientProducer;
@@ -40,7 +41,6 @@ import org.apache.activemq.artemis.core.server.Consumer;
 import org.apache.activemq.artemis.core.server.HandleStatus;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer;
@@ -157,7 +157,7 @@ public class QueueImplTest extends ActiveMQTestBase {
 
       Filter filter = new Filter() {
          @Override
-         public boolean match(final ServerMessage message) {
+         public boolean match(final Message message) {
             return false;
          }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeFilter.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeFilter.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeFilter.java
index 9d7f0e1..8f394e2 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeFilter.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeFilter.java
@@ -16,9 +16,10 @@
  */
 package org.apache.activemq.artemis.tests.unit.core.server.impl.fakes;
 
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 public class FakeFilter implements Filter {
 
@@ -36,9 +37,9 @@ public class FakeFilter implements Filter {
    }
 
    @Override
-   public boolean match(final ServerMessage message) {
+   public boolean match(final Message message) {
       if (headerName != null) {
-         Object value = message.getObjectProperty(new SimpleString(headerName));
+         Object value = message.getObjectProperty(headerName);
 
          if (value instanceof SimpleString) {
             value = ((SimpleString) value).toString();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java
index 547d669..a84d2d0 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeJournalLoader.java
@@ -20,6 +20,7 @@ import javax.transaction.xa.Xid;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.journal.Journal;
@@ -29,7 +30,6 @@ import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
 import org.apache.activemq.artemis.core.persistence.impl.PageCountPending;
 import org.apache.activemq.artemis.core.persistence.impl.journal.AddMessageRecord;
 import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.JournalLoader;
 import org.apache.activemq.artemis.core.transaction.ResourceManager;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -37,7 +37,7 @@ import org.apache.activemq.artemis.core.transaction.Transaction;
 public class FakeJournalLoader implements JournalLoader {
 
    @Override
-   public void handleNoMessageReferences(Map<Long, ServerMessage> messages) {
+   public void handleNoMessageReferences(Map<Long, Message> messages) {
    }
 
    @Override
@@ -69,7 +69,7 @@ public class FakeJournalLoader implements JournalLoader {
    }
 
    @Override
-   public void handlePreparedSendMessage(ServerMessage message, Transaction tx, long queueID) {
+   public void handlePreparedSendMessage(Message message, Transaction tx, long queueID) {
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
index 6602df5..109a336 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
@@ -35,7 +36,6 @@ import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -173,14 +173,14 @@ public class FakePostOffice implements PostOffice {
    }
 
    @Override
-   public Pair<RoutingContext, ServerMessage> redistribute(final ServerMessage message,
-                                                           final Queue originatingQueue,
-                                                           final Transaction tx) throws Exception {
+   public Pair<RoutingContext, Message> redistribute(final Message message,
+                                                     final Queue originatingQueue,
+                                                     final Transaction tx) throws Exception {
       return null;
    }
 
    @Override
-   public MessageReference reroute(final ServerMessage message,
+   public MessageReference reroute(final Message message,
                                    final Queue queue,
                                    final Transaction tx) throws Exception {
       message.incrementRefCount();
@@ -188,14 +188,14 @@ public class FakePostOffice implements PostOffice {
    }
 
    @Override
-   public RoutingStatus route(ServerMessage message,
+   public RoutingStatus route(Message message,
                               Transaction tx,
                               boolean direct) throws Exception {
       return RoutingStatus.OK;
    }
 
    @Override
-   public RoutingStatus route(ServerMessage message,
+   public RoutingStatus route(Message message,
                               Transaction tx,
                               boolean direct,
                               boolean rejectDuplicates) throws Exception {
@@ -203,12 +203,12 @@ public class FakePostOffice implements PostOffice {
    }
 
    @Override
-   public RoutingStatus route(ServerMessage message, RoutingContext context, boolean direct) throws Exception {
+   public RoutingStatus route(Message message, RoutingContext context, boolean direct) throws Exception {
       return null;
    }
 
    @Override
-   public RoutingStatus route(ServerMessage message,
+   public RoutingStatus route(Message message,
                               RoutingContext context,
                               boolean direct,
                               boolean rejectDuplicates) throws Exception {
@@ -216,11 +216,11 @@ public class FakePostOffice implements PostOffice {
    }
 
    @Override
-   public void processRoute(ServerMessage message, RoutingContext context, boolean direct) throws Exception {
+   public void processRoute(Message message, RoutingContext context, boolean direct) throws Exception {
    }
 
    @Override
-   public RoutingStatus route(ServerMessage message, boolean direct) throws Exception {
+   public RoutingStatus route(Message message, boolean direct) throws Exception {
       return RoutingStatus.OK;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/FakePagingManager.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/FakePagingManager.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/FakePagingManager.java
index 500a81f..d1012a6 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/FakePagingManager.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/FakePagingManager.java
@@ -19,11 +19,12 @@ package org.apache.activemq.artemis.tests.unit.util;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.paging.PageTransactionInfo;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
 
 public final class FakePagingManager implements PagingManager {
@@ -64,11 +65,11 @@ public final class FakePagingManager implements PagingManager {
       return false;
    }
 
-   public boolean page(final ServerMessage message, final boolean duplicateDetection) throws Exception {
+   public boolean page(final Message message, final boolean duplicateDetection) throws Exception {
       return false;
    }
 
-   public boolean page(final ServerMessage message,
+   public boolean page(final Message message,
                        final long transactionId,
                        final boolean duplicateDetection) throws Exception {
       return false;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java
index 3fa2df8..2b5205e 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.activemq.artemis.tests.unit.util;
 
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
 import org.apache.activemq.artemis.utils.MemorySize;
 import org.junit.Assert;
@@ -30,7 +30,7 @@ public class MemorySizeTest extends Assert {
       UnitTestLogger.LOGGER.info("Server message size is " + MemorySize.calculateSize(new MemorySize.ObjectFactory() {
          @Override
          public Object createObject() {
-            return new ServerMessageImpl(1, 1000);
+            return new CoreMessage(1, 1000);
          }
       }));
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java
index b07f5bf..570c791 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java
@@ -44,7 +44,7 @@ public class UTF8Test extends ActiveMQTestBase {
 
       String str = new String(bytes);
 
-      UTF8Util.saveUTF(buffer, str);
+      UTF8Util.saveUTF(buffer.byteBuf(), str);
 
       String newStr = UTF8Util.readUTF(buffer);
 
@@ -72,7 +72,7 @@ public class UTF8Test extends ActiveMQTestBase {
    }
 
    private void testValidateUTFOnDataInputStream(final String str, final ActiveMQBuffer wrap) throws Exception {
-      UTF8Util.saveUTF(wrap, str);
+      UTF8Util.saveUTF(wrap.byteBuf(), str);
 
       DataInputStream data = new DataInputStream(new ByteArrayInputStream(wrap.toByteBuffer().array()));
 
@@ -106,7 +106,7 @@ public class UTF8Test extends ActiveMQTestBase {
       ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(0xffff + 4);
 
       try {
-         UTF8Util.saveUTF(buffer, str);
+         UTF8Util.saveUTF(buffer.byteBuf(), str);
          Assert.fail("String is too big, supposed to throw an exception");
       } catch (Exception ignored) {
       }
@@ -122,7 +122,7 @@ public class UTF8Test extends ActiveMQTestBase {
       str = new String(chars);
 
       try {
-         UTF8Util.saveUTF(buffer, str);
+         UTF8Util.saveUTF(buffer.byteBuf(), str);
          Assert.fail("Encoded String is too big, supposed to throw an exception");
       } catch (Exception ignored) {
       }
@@ -138,7 +138,7 @@ public class UTF8Test extends ActiveMQTestBase {
 
       str = new String(chars);
 
-      UTF8Util.saveUTF(buffer, str);
+      UTF8Util.saveUTF(buffer.byteBuf(), str);
 
       Assert.assertEquals(0xffff + DataConstants.SIZE_SHORT, buffer.writerIndex());
 


[21/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
ARTEMIS-1009 Pure Message Encoding.

with this we could send and receive message in their raw format,
without requiring conversions to Core.

- MessageImpl and ServerMessage are removed as part of this
- AMQPMessage and CoreMessage will have the specialized message format for each protocol
- The protocol manager is now responsible to send the message
- The message will provide an encoder for journal and paging


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/46be6a2f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/46be6a2f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/46be6a2f

Branch: refs/heads/artemis-1009
Commit: 46be6a2f9bd69ca9532868252d71b33d42cd0acb
Parents: 02906b5
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Feb 20 15:55:15 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../artemis/cli/commands/tools/PrintData.java   |    7 +
 .../cli/commands/tools/XmlDataExporter.java     |   18 +-
 .../cli/commands/tools/XmlDataExporterUtil.java |    7 +-
 .../cli/commands/tools/XmlDataImporter.java     |    3 +-
 .../org/apache/activemq/artemis/Closeable.java  |   22 +
 .../artemis/api/core/ActiveMQBuffer.java        |   13 +
 .../artemis/api/core/ActiveMQBuffers.java       |   15 +
 .../activemq/artemis/api/core/SimpleString.java |   34 +
 .../core/buffers/impl/ChannelBufferWrapper.java |   83 +-
 .../artemis/core/persistence/Persister.java     |   30 +
 .../apache/activemq/artemis/utils/ByteUtil.java |    8 +
 .../activemq/artemis/utils/TypedProperties.java |   74 +-
 .../apache/activemq/artemis/utils/UTF8Util.java |   36 +-
 .../artemis/utils/TypedPropertiesTest.java      |   10 +-
 .../config/ActiveMQDefaultConfiguration.java    |   20 -
 .../activemq/artemis/api/core/Message.java      |  627 +++++-----
 .../artemis/api/core/RefCountMessage.java       |   81 ++
 .../api/core/RefCountMessageListener.java       |   31 +
 .../artemis/api/core/client/ClientMessage.java  |    8 -
 .../artemis/api/core/encode/BodyType.java       |   22 +
 .../artemis/api/core/encode/MessageBody.java    |   28 +
 .../impl/ResetLimitWrappedActiveMQBuffer.java   |   24 +-
 .../client/impl/ClientLargeMessageImpl.java     |   22 +-
 .../core/client/impl/ClientMessageImpl.java     |   74 +-
 .../core/client/impl/ClientMessageInternal.java |    5 +
 .../core/client/impl/ClientProducerImpl.java    |   41 +-
 .../CompressedLargeMessageControllerImpl.java   |    6 +
 .../client/impl/LargeMessageControllerImpl.java |   15 +
 .../artemis/core/message/BodyEncoder.java       |   55 -
 .../artemis/core/message/LargeBodyEncoder.java  |   55 +
 .../artemis/core/message/impl/CoreMessage.java  | 1066 ++++++++++++++++++
 .../core/message/impl/CoreMessagePersister.java |   66 ++
 .../artemis/core/message/impl/MessageImpl.java  | 1059 -----------------
 .../core/message/impl/MessageInternal.java      |   57 -
 .../core/impl/ActiveMQSessionContext.java       |   16 +-
 .../core/protocol/core/impl/ChannelImpl.java    |    1 +
 .../core/protocol/core/impl/PacketImpl.java     |   30 +-
 .../core/impl/RemotingConnectionImpl.java       |    1 +
 .../core/impl/wireformat/MessagePacket.java     |   18 +-
 .../SessionReceiveClientLargeMessage.java       |    5 +-
 .../wireformat/SessionReceiveLargeMessage.java  |   14 +-
 .../impl/wireformat/SessionReceiveMessage.java  |   60 +-
 .../SessionSendContinuationMessage.java         |    8 +-
 .../wireformat/SessionSendLargeMessage.java     |   12 +-
 .../impl/wireformat/SessionSendMessage.java     |   54 +-
 .../activemq/artemis/reader/MapMessageUtil.java |    4 +-
 .../spi/core/remoting/SessionContext.java       |   11 +-
 .../artemis/message/CoreMessageTest.java        |  365 ++++++
 .../jdbc/store/journal/JDBCJournalImpl.java     |   36 +-
 .../jdbc/store/journal/JDBCJournalRecord.java   |    7 +-
 .../jms/client/ActiveMQBytesMessage.java        |    4 +-
 .../artemis/jms/client/ActiveMQMessage.java     |    8 +-
 .../jms/transaction/JMSTransactionDetail.java   |    6 +-
 .../artemis/core/journal/EncoderPersister.java  |   51 +
 .../activemq/artemis/core/journal/Journal.java  |   55 +-
 .../journal/impl/AbstractJournalUpdateTask.java |    3 +-
 .../core/journal/impl/FileWrapperJournal.java   |   26 +-
 .../artemis/core/journal/impl/JournalBase.java  |   63 +-
 .../core/journal/impl/JournalCompactor.java     |    9 +-
 .../artemis/core/journal/impl/JournalImpl.java  |   62 +-
 .../impl/dataformat/JournalAddRecord.java       |   20 +-
 .../impl/dataformat/JournalAddRecordTX.java     |   17 +-
 .../protocol/amqp/broker/AMQPMessage.java       |  761 +++++++++++++
 .../amqp/broker/AMQPMessagePersister.java       |   75 ++
 .../amqp/broker/AMQPSessionCallback.java        |   33 +-
 .../broker/ProtonProtocolManagerFactory.java    |   14 +
 .../amqp/converter/ProtonMessageConverter.java  |   12 +-
 .../converter/jms/ServerJMSBytesMessage.java    |    8 +-
 .../amqp/converter/jms/ServerJMSMapMessage.java |    3 +-
 .../amqp/converter/jms/ServerJMSMessage.java    |   21 +-
 .../converter/jms/ServerJMSObjectMessage.java   |    3 +-
 .../converter/jms/ServerJMSStreamMessage.java   |    5 +-
 .../converter/jms/ServerJMSTextMessage.java     |    3 +-
 .../converter/message/AMQPMessageSupport.java   |   28 +-
 .../message/AMQPNativeInboundTransformer.java   |   44 -
 .../message/AMQPRawInboundTransformer.java      |   62 -
 .../converter/message/InboundTransformer.java   |    5 +-
 .../message/JMSMappingInboundTransformer.java   |   34 +-
 .../message/JMSMappingOutboundTransformer.java  |    3 +-
 .../amqp/proton/AMQPConnectionContext.java      |    4 +
 .../proton/ProtonServerReceiverContext.java     |   32 +-
 .../amqp/proton/ProtonServerSenderContext.java  |   25 +-
 .../amqp/proton/ProtonTransactionHandler.java   |    3 +-
 .../amqp/proton/handler/ProtonHandler.java      |    2 +-
 .../protocol/amqp/util/DeliveryUtil.java        |   13 -
 .../protocol/amqp/util/NettyReadable.java       |  139 +++
 .../amqp/converter/TestConversions.java         |   62 +-
 .../JMSMappingInboundTransformerTest.java       |    6 +-
 .../JMSMappingOutboundTransformerTest.java      |   38 +-
 .../JMSTransformationSpeedComparisonTest.java   |   36 +-
 .../message/MessageTransformationTest.java      |   19 +-
 .../protocol/amqp/message/AMQPMessageTest.java  |   63 ++
 .../core/protocol/mqtt/MQTTPublishManager.java  |   22 +-
 .../protocol/mqtt/MQTTRetainMessageManager.java |    8 +-
 .../core/protocol/mqtt/MQTTSessionCallback.java |   10 +-
 .../artemis/core/protocol/mqtt/MQTTUtil.java    |   15 +-
 .../openwire/OpenWireMessageConverter.java      |   20 +-
 .../core/protocol/openwire/amq/AMQConsumer.java |    6 +-
 .../core/protocol/openwire/amq/AMQSession.java  |    9 +-
 .../protocol/openwire/util/OpenWireUtil.java    |    7 +-
 .../ActiveMQStompProtocolMessageBundle.java     |    3 +-
 .../core/protocol/stomp/StompConnection.java    |   14 +-
 .../protocol/stomp/StompProtocolManager.java    |    6 +-
 .../core/protocol/stomp/StompSession.java       |   35 +-
 .../artemis/core/protocol/stomp/StompUtils.java |    6 +-
 .../stomp/VersionedStompFrameHandler.java       |   19 +-
 .../stomp/v12/StompFrameHandlerV12.java         |    4 +-
 .../artemis/core/config/Configuration.java      |    8 -
 .../core/config/impl/ConfigurationImpl.java     |   32 -
 .../deployers/impl/FileConfigurationParser.java |    4 -
 .../activemq/artemis/core/filter/Filter.java    |    4 +-
 .../artemis/core/filter/impl/FilterImpl.java    |   12 +-
 .../management/impl/AddressControlImpl.java     |    6 +-
 .../core/management/impl/QueueControlImpl.java  |   10 +-
 .../impl/openmbean/OpenTypeSupport.java         |   16 +-
 .../artemis/core/paging/PagedMessage.java       |    5 +-
 .../artemis/core/paging/PagingStore.java        |    8 +-
 .../core/paging/cursor/PagedReferenceImpl.java  |   16 +-
 .../cursor/impl/PageSubscriptionImpl.java       |    4 +-
 .../activemq/artemis/core/paging/impl/Page.java |    2 +-
 .../core/paging/impl/PagedMessageImpl.java      |   66 +-
 .../core/paging/impl/PagingStoreImpl.java       |   52 +-
 .../core/persistence/StorageManager.java        |   16 +-
 .../journal/AbstractJournalStorageManager.java  |   60 +-
 .../impl/journal/AddMessageRecord.java          |    8 +-
 .../impl/journal/DescribeJournal.java           |   17 +-
 .../impl/journal/JournalRecordIds.java          |    3 +
 .../impl/journal/JournalStorageManager.java     |   14 +-
 .../journal/LargeMessageTXFailureCallback.java  |    6 +-
 .../impl/journal/LargeServerMessageImpl.java    |  117 +-
 .../journal/LargeServerMessagePersister.java    |   73 ++
 .../journal/codec/LargeMessageEncoding.java     |   55 -
 .../journal/codec/LargeMessagePersister.java    |   63 ++
 .../nullpm/NullStorageLargeServerMessage.java   |   18 +-
 .../impl/nullpm/NullStorageManager.java         |   16 +-
 .../artemis/core/postoffice/Binding.java        |    9 +-
 .../artemis/core/postoffice/Bindings.java       |    6 +-
 .../artemis/core/postoffice/PostOffice.java     |   18 +-
 .../core/postoffice/impl/BindingsImpl.java      |   27 +-
 .../core/postoffice/impl/DivertBinding.java     |    8 +-
 .../core/postoffice/impl/LocalQueueBinding.java |    8 +-
 .../core/postoffice/impl/PostOfficeImpl.java    |   84 +-
 .../core/protocol/ServerPacketDecoder.java      |    6 +-
 .../core/ServerSessionPacketHandler.java        |   82 +-
 .../core/impl/ActiveMQPacketHandler.java        |    2 +-
 .../core/impl/CoreProtocolManagerFactory.java   |   14 +
 .../protocol/core/impl/CoreSessionCallback.java |    8 +-
 .../impl/wireformat/ReplicationAddMessage.java  |   14 +-
 .../wireformat/ReplicationAddTXMessage.java     |   13 +-
 .../wireformat/ReplicationPageWriteMessage.java |    2 +-
 .../core/remoting/server/RemotingService.java   |    4 +
 .../server/impl/RemotingServiceImpl.java        |   11 +-
 .../core/replication/ReplicatedJournal.java     |   52 +-
 .../core/replication/ReplicationEndpoint.java   |    7 +-
 .../core/replication/ReplicationManager.java    |   11 +-
 .../core/server/ActiveMQServerLogger.java       |    9 +-
 .../activemq/artemis/core/server/Bindable.java  |    6 +-
 .../artemis/core/server/LargeServerMessage.java |    3 +-
 .../artemis/core/server/MessageReference.java   |   10 +-
 .../activemq/artemis/core/server/Queue.java     |    3 +-
 .../artemis/core/server/ServerMessage.java      |   78 --
 .../artemis/core/server/ServerSession.java      |   22 +-
 .../core/server/cluster/Transformer.java        |    4 +-
 .../core/server/cluster/impl/BridgeImpl.java    |   17 +-
 .../cluster/impl/ClusterConnectionBridge.java   |   14 +-
 .../core/server/cluster/impl/Redistributor.java |    3 +-
 .../cluster/impl/RemoteQueueBindingImpl.java    |   14 +-
 .../core/server/impl/ActiveMQServerImpl.java    |    1 +
 .../artemis/core/server/impl/DivertImpl.java    |   10 +-
 .../artemis/core/server/impl/JournalLoader.java |    6 +-
 .../core/server/impl/LastValueQueue.java        |   10 +-
 .../core/server/impl/MessageReferenceImpl.java  |   24 +-
 .../server/impl/PostOfficeJournalLoader.java    |    7 +-
 .../artemis/core/server/impl/QueueImpl.java     |   65 +-
 .../artemis/core/server/impl/RefsOperation.java |    4 +-
 .../core/server/impl/ScaleDownHandler.java      |   45 +-
 .../core/server/impl/ServerConsumerImpl.java    |   27 +-
 .../core/server/impl/ServerMessageImpl.java     |  341 ------
 .../core/server/impl/ServerSessionImpl.java     |  118 +-
 .../server/management/ManagementService.java    |    5 +-
 .../management/impl/ManagementServiceImpl.java  |   12 +-
 .../core/transaction/TransactionDetail.java     |    9 +-
 .../transaction/impl/CoreTransactionDetail.java |    6 +-
 .../spi/core/protocol/MessageConverter.java     |    7 +-
 .../spi/core/protocol/MessagePersister.java     |   88 ++
 .../spi/core/protocol/ProtocolManager.java      |    2 +
 .../core/protocol/ProtocolManagerFactory.java   |   15 +
 .../spi/core/protocol/SessionCallback.java      |    6 +-
 .../resources/schema/artemis-configuration.xsd  |   16 -
 .../core/config/impl/ConfigurationImplTest.java |    9 -
 .../artemis/core/filter/impl/FilterTest.java    |   12 +-
 .../group/impl/ClusteredResetMockTest.java      |    5 +-
 .../impl/ScheduledDeliveryHandlerTest.java      |  196 ++--
 .../transaction/impl/TransactionImplTest.java   |   16 +-
 .../artemis/tests/util/ActiveMQTestBase.java    |   13 +-
 .../resources/ConfigurationTest-full-config.xml |    2 -
 .../test/resources/artemis-configuration.xsd    |   16 -
 .../jms/example/HatColourChangeTransformer.java |    2 +-
 .../example/AddForwardingTimeTransformer.java   |    2 +-
 pom.xml                                         |    3 +-
 .../amqp/client/util/UnmodifiableDelivery.java  |    5 +
 .../journal/gcfree/EncodersBench.java           |    5 +-
 .../byteman/JMSBridgeReconnectionTest.java      |    4 +-
 .../tests/extras/byteman/MessageCopyTest.java   |  163 ---
 .../integration/DuplicateDetectionTest.java     |    6 +-
 .../tests/integration/amqp/ProtonTest.java      |   22 +-
 .../integration/client/AckBatchSizeTest.java    |   14 +-
 .../integration/client/AcknowledgeTest.java     |  177 ++-
 .../tests/integration/client/ConsumerTest.java  |  163 ++-
 .../integration/client/HangConsumerTest.java    |    7 +-
 .../InVMNonPersistentMessageBufferTest.java     |   36 +-
 .../client/InterruptedLargeMessageTest.java     |   10 +-
 .../integration/client/LargeMessageTest.java    |    4 +-
 .../integration/cluster/bridge/BridgeTest.java  |   10 +-
 .../cluster/bridge/SimpleTransformer.java       |   61 +-
 .../distribution/ClusterHeadersRemovedTest.java |    5 +-
 .../distribution/MessageRedistributionTest.java |    4 +-
 .../tests/integration/divert/DivertTest.java    |    5 +-
 .../interceptors/InterceptorTest.java           |    8 +-
 .../integration/journal/MessageJournalTest.java |  133 +++
 .../journal/NIOJournalCompactTest.java          |    6 +-
 .../integration/karaf/ContainerBaseTest.java    |   64 ++
 .../tests/integration/karaf/KarafBaseTest.java  |  212 ++++
 .../karaf/distribution/ArtemisFeatureTest.java  |  101 ++
 .../karaf/distribution/package-info.java        |   21 +
 .../karaf/version/ProbeRemoteServer.java        |   51 +
 .../integration/karaf/version/RemoteTest.java   |   38 +
 .../karaf/version/VersionWireTest.java          |  104 ++
 .../integration/karaf/version/package-info.java |   21 +
 .../management/ManagementServiceImplTest.java   |   24 +-
 .../DeleteMessagesOnStartupTest.java            |   10 +-
 .../replication/ReplicationTest.java            |   71 +-
 .../integration/server/FakeStorageManager.java  |    6 +-
 .../storage/PersistMultiThreadTest.java         |   31 +-
 .../stress/paging/PageCursorStressTest.java     |   24 +-
 .../core/server/impl/QueueConcurrentTest.java   |    6 +-
 tests/unit-tests/pom.xml                        |    6 +
 .../core/journal/impl/JournalImplTestUnit.java  |    2 +-
 .../unit/core/message/impl/MessageImplTest.java |    9 +-
 .../tests/unit/core/paging/impl/PageTest.java   |   42 +-
 .../core/paging/impl/PagingManagerImplTest.java |   16 +-
 .../core/paging/impl/PagingStoreImplTest.java   |   38 +-
 .../core/postoffice/impl/BindingsImplTest.java  |   16 +-
 .../unit/core/postoffice/impl/FakeQueue.java    |    9 +-
 .../impl/WildcardAddressManagerUnitTest.java    |   12 +-
 .../unit/core/server/impl/QueueImplTest.java    |    4 +-
 .../unit/core/server/impl/fakes/FakeFilter.java |    7 +-
 .../server/impl/fakes/FakeJournalLoader.java    |    6 +-
 .../core/server/impl/fakes/FakePostOffice.java  |   22 +-
 .../tests/unit/util/FakePagingManager.java      |    7 +-
 .../artemis/tests/unit/util/MemorySizeTest.java |    4 +-
 .../artemis/tests/unit/util/UTF8Test.java       |   10 +-
 252 files changed, 6442 insertions(+), 4208 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
index 408aef5..2816aaf 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
@@ -34,6 +34,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.cli.Artemis;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
+import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
@@ -50,16 +51,22 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordId
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.CursorAckRecordEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.journal.codec.PageUpdateTXEncoding;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
 import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.ExecutorFactory;
 
 @Command(name = "print", description = "Print data records information (WARNING: don't use while a production server is running)")
 public class PrintData extends OptionalLocking {
 
+   static {
+      MessagePersister.registerPersister(CoreProtocolManagerFactory.ID, CoreMessagePersister.getInstance());
+   }
+
    @Override
    public Object execute(ActionContext context) throws Exception {
       super.execute(context);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
index 4f99181..b57b5c5 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
@@ -50,7 +50,7 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
@@ -75,7 +75,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository;
@@ -367,7 +367,7 @@ public final class XmlDataExporter extends OptionalLocking {
       // Order here is important.  We must process the messages from the journal before we process those from the page
       // files in order to get the messages in the right order.
       for (Map.Entry<Long, Message> messageMapEntry : messages.entrySet()) {
-         printSingleMessageAsXML((ServerMessage) messageMapEntry.getValue(), extractQueueNames(messageRefs.get(messageMapEntry.getKey())));
+         printSingleMessageAsXML(messageMapEntry.getValue(), extractQueueNames(messageRefs.get(messageMapEntry.getKey())));
       }
 
       printPagedMessagesAsXML();
@@ -381,6 +381,8 @@ public final class XmlDataExporter extends OptionalLocking {
     */
    private void printPagedMessagesAsXML() {
       try {
+
+         // TODO-now: fix encodings
          ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory());
          final ExecutorService executor = Executors.newFixedThreadPool(10, ActiveMQThreadFactory.defaultThreadFactory());
          ExecutorFactory executorFactory = new ExecutorFactory() {
@@ -456,7 +458,7 @@ public final class XmlDataExporter extends OptionalLocking {
       }
    }
 
-   private void printSingleMessageAsXML(ServerMessage message, List<String> queues) throws XMLStreamException {
+   private void printSingleMessageAsXML(Message message, List<String> queues) throws XMLStreamException {
       xmlWriter.writeStartElement(XmlDataConstants.MESSAGES_CHILD);
       printMessageAttributes(message);
       printMessageProperties(message);
@@ -466,7 +468,7 @@ public final class XmlDataExporter extends OptionalLocking {
       messagesPrinted++;
    }
 
-   private void printMessageBody(ServerMessage message) throws XMLStreamException {
+   private void printMessageBody(Message message) throws XMLStreamException {
       xmlWriter.writeStartElement(XmlDataConstants.MESSAGE_BODY);
 
       if (message.isLargeMessage()) {
@@ -479,7 +481,7 @@ public final class XmlDataExporter extends OptionalLocking {
 
    private void printLargeMessageBody(LargeServerMessage message) throws XMLStreamException {
       xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_IS_LARGE, Boolean.TRUE.toString());
-      BodyEncoder encoder = null;
+      LargeBodyEncoder encoder = null;
 
       try {
          encoder = message.getBodyEncoder();
@@ -522,7 +524,7 @@ public final class XmlDataExporter extends OptionalLocking {
       xmlWriter.writeEndElement(); // end QUEUES_PARENT
    }
 
-   private void printMessageProperties(ServerMessage message) throws XMLStreamException {
+   private void printMessageProperties(Message message) throws XMLStreamException {
       xmlWriter.writeStartElement(XmlDataConstants.PROPERTIES_PARENT);
       for (SimpleString key : message.getPropertyNames()) {
          Object value = message.getObjectProperty(key);
@@ -539,7 +541,7 @@ public final class XmlDataExporter extends OptionalLocking {
       xmlWriter.writeEndElement(); // end PROPERTIES_PARENT
    }
 
-   private void printMessageAttributes(ServerMessage message) throws XMLStreamException {
+   private void printMessageAttributes(Message message) throws XMLStreamException {
       xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_ID, Long.toString(message.getMessageID()));
       xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_PRIORITY, Byte.toString(message.getPriority()));
       xmlWriter.writeAttribute(XmlDataConstants.MESSAGE_EXPIRATION, Long.toString(message.getExpiration()));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporterUtil.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporterUtil.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporterUtil.java
index 8ee7678..a3807bd 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporterUtil.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporterUtil.java
@@ -17,10 +17,9 @@
 package org.apache.activemq.artemis.cli.commands.tools;
 
 import com.google.common.base.Preconditions;
-
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.utils.Base64;
 
 /**
@@ -92,10 +91,10 @@ public class XmlDataExporterUtil {
     * @param message
     * @return
     */
-   public static String encodeMessageBody(final ServerMessage message) {
+   public static String encodeMessageBody(final Message message) {
       Preconditions.checkNotNull(message, "ServerMessage can not be null");
 
-      int size = message.getEndOfBodyPosition() - message.getBodyBuffer().readerIndex();
+      int size = ((CoreMessage)message.toCore()).getEndOfBodyPosition() - message.getBodyBuffer().readerIndex();
       byte[] buffer = new byte[size];
       message.getBodyBuffer().readBytes(buffer);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
index 8e2bb9f..0f06738 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
@@ -59,7 +59,6 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.cli.commands.ActionAbstract;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
@@ -387,7 +386,7 @@ public final class XmlDataImporter extends ActionAbstract {
          logger.debug(logMessage);
       }
 
-      message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+      message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array());
       try (ClientProducer producer = session.createProducer(destination)) {
          producer.send(message);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/Closeable.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/Closeable.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/Closeable.java
new file mode 100644
index 0000000..2f00c5d
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/Closeable.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis;
+
+public interface Closeable {
+   void close(boolean failed);
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
index 5446f3f..3a208a6 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffer.java
@@ -1065,6 +1065,19 @@ public interface ActiveMQBuffer extends DataInput {
     */
    void writeBytes(ByteBuffer src);
 
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the current {@code writerIndex} until the source buffer's position
+    * reaches its limit, and increases the {@code writerIndex} by the
+    * number of the transferred bytes.
+    *
+    * @param src The source buffer
+    * @throws IndexOutOfBoundsException if {@code src.remaining()} is greater than
+    *                                   {@code this.writableBytes}
+    */
+   void writeBytes(ByteBuf src, int srcIndex, int length);
+
    /**
     * Returns a copy of this buffer's readable bytes.  Modifying the content
     * of the returned buffer or this buffer does not affect each other at all.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
index 32f9279..25fcfea 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.api.core;
 
 import java.nio.ByteBuffer;
 
+import io.netty.buffer.ByteBuf;
 import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.buffer.Unpooled;
 import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
@@ -76,6 +77,20 @@ public final class ActiveMQBuffers {
    }
 
    /**
+    * Creates an ActiveMQBuffer wrapping an underlying ByteBuf
+    *
+    * The position on this buffer won't affect the position on the inner buffer
+    *
+    * @param underlying the underlying NIO ByteBuffer
+    * @return an ActiveMQBuffer wrapping the underlying NIO ByteBuffer
+    */
+   public static ActiveMQBuffer wrappedBuffer(final ByteBuf underlying) {
+      ActiveMQBuffer buff = new ChannelBufferWrapper(underlying.duplicate());
+
+      return buff;
+   }
+
+   /**
     * Creates an ActiveMQBuffer wrapping an underlying byte array
     *
     * @param underlying the underlying byte array

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
index b7f70c6..e8530e6 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
@@ -20,6 +20,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.utils.DataConstants;
 
 /**
@@ -134,6 +135,39 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
    }
 
 
+   public static SimpleString readNullableSimpleString(ByteBuf buffer) {
+      int b = buffer.readByte();
+      if (b == DataConstants.NULL) {
+         return null;
+      }
+      return readSimpleString(buffer);
+   }
+
+
+   public static SimpleString readSimpleString(ByteBuf buffer) {
+      int len = buffer.readInt();
+      byte[] data = new byte[len];
+      buffer.readBytes(data);
+      return new SimpleString(data);
+   }
+
+   public static void writeNullableSimpleString(ByteBuf buffer, SimpleString val) {
+      if (val == null) {
+         buffer.writeByte(DataConstants.NULL);
+      } else {
+         buffer.writeByte(DataConstants.NOT_NULL);
+         writeSimpleString(buffer, val);
+      }
+   }
+
+   public static void writeSimpleString(ByteBuf buffer, SimpleString val) {
+      byte[] data = val.getData();
+      buffer.writeInt(data.length);
+      buffer.writeBytes(data);
+   }
+
+
+
    public SimpleString subSeq(final int start, final int end) {
       int len = data.length >> 1;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
index 690dbd7..b2660fa 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
@@ -66,11 +66,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
 
    @Override
    public SimpleString readNullableSimpleString() {
-      int b = buffer.readByte();
-      if (b == DataConstants.NULL) {
-         return null;
-      }
-      return readSimpleStringInternal();
+      return SimpleString.readNullableSimpleString(buffer);
    }
 
    @Override
@@ -84,14 +80,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
 
    @Override
    public SimpleString readSimpleString() {
-      return readSimpleStringInternal();
-   }
-
-   private SimpleString readSimpleStringInternal() {
-      int len = buffer.readInt();
-      byte[] data = new byte[len];
-      buffer.readBytes(data);
-      return new SimpleString(data);
+      return SimpleString.readSimpleString(buffer);
    }
 
    @Override
@@ -111,11 +100,21 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
       } else if (len < 0xfff) {
          return readUTF();
       } else {
-         return readSimpleStringInternal().toString();
+         return SimpleString.readNullableSimpleString(buffer).toString();
       }
    }
 
    @Override
+   public void writeNullableString(String val) {
+      UTF8Util.writeNullableString(buffer, val);
+   }
+
+   @Override
+   public void writeUTF(String utf) {
+      UTF8Util.saveUTF(buffer, utf);
+   }
+
+   @Override
    public String readUTF() {
       return UTF8Util.readUTF(this);
    }
@@ -127,62 +126,17 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
 
    @Override
    public void writeNullableSimpleString(final SimpleString val) {
-      if (val == null) {
-         buffer.writeByte(DataConstants.NULL);
-      } else {
-         buffer.writeByte(DataConstants.NOT_NULL);
-         writeSimpleStringInternal(val);
-      }
-   }
-
-   @Override
-   public void writeNullableString(final String val) {
-      if (val == null) {
-         buffer.writeByte(DataConstants.NULL);
-      } else {
-         buffer.writeByte(DataConstants.NOT_NULL);
-         writeStringInternal(val);
-      }
+      SimpleString.writeNullableSimpleString(buffer, val);
    }
 
    @Override
    public void writeSimpleString(final SimpleString val) {
-      writeSimpleStringInternal(val);
-   }
-
-   private void writeSimpleStringInternal(final SimpleString val) {
-      byte[] data = val.getData();
-      buffer.writeInt(data.length);
-      buffer.writeBytes(data);
+      SimpleString.writeSimpleString(buffer, val);
    }
 
    @Override
    public void writeString(final String val) {
-      writeStringInternal(val);
-   }
-
-   private void writeStringInternal(final String val) {
-      int length = val.length();
-
-      buffer.writeInt(length);
-
-      if (length < 9) {
-         // If very small it's more performant to store char by char
-         for (int i = 0; i < val.length(); i++) {
-            buffer.writeShort((short) val.charAt(i));
-         }
-      } else if (length < 0xfff) {
-         // Store as UTF - this is quicker than char by char for most strings
-         writeUTF(val);
-      } else {
-         // Store as SimpleString, since can't store utf > 0xffff in length
-         writeSimpleStringInternal(new SimpleString(val));
-      }
-   }
-
-   @Override
-   public void writeUTF(final String utf) {
-      UTF8Util.saveUTF(this, utf);
+      UTF8Util.writeString(buffer, val);
    }
 
    @Override
@@ -576,6 +530,11 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
    }
 
    @Override
+   public void writeBytes(ByteBuf src, int srcIndex, int length) {
+      buffer.writeBytes(src, srcIndex, length);
+   }
+
+   @Override
    public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
       buffer.writeBytes(src.byteBuf(), srcIndex, length);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/core/persistence/Persister.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/persistence/Persister.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/persistence/Persister.java
new file mode 100644
index 0000000..fd68a77
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/persistence/Persister.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.persistence;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+
+public interface Persister<T extends Object> {
+
+   int getEncodeSize(T record);
+
+   void encode(ActiveMQBuffer buffer, T record);
+
+   T decode(ActiveMQBuffer buffer, T record);
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
index bee8790..e70891d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
@@ -101,6 +101,14 @@ public class ByteUtil {
    }
 
    public static String bytesToHex(byte[] bytes, int groupSize) {
+      if (bytes == null) {
+         return "NULL";
+      }
+
+      if (bytes.length == 0) {
+         return "[]";
+      }
+
       char[] hexChars = new char[bytes.length * 2 + numberOfGroups(bytes, groupSize)];
       int outPos = 0;
       for (int j = 0; j < bytes.length; j++) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
index 56cec48..a421484 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/TypedProperties.java
@@ -24,7 +24,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.logs.ActiveMQUtilBundle;
@@ -47,21 +47,23 @@ import static org.apache.activemq.artemis.utils.DataConstants.STRING;
  * This implementation follows section 3.5.4 of the <i>Java Message Service</i> specification
  * (Version 1.1 April 12, 2002).
  * <p>
- * TODO - should have typed property getters and do conversions herein
  */
 public final class TypedProperties {
 
-   private static final SimpleString AMQ_PROPNAME = new SimpleString("_AMQ_");
-
    private Map<SimpleString, PropertyValue> properties;
 
    private volatile int size;
 
-   private boolean internalProperties;
-
    public TypedProperties() {
    }
 
+   /**
+    *  Return the number of properites
+    * */
+   public int size() {
+      return properties.size();
+   }
+
    public int getMemoryOffset() {
       // The estimate is basically the encode size + 2 object references for each entry in the map
       // Note we don't include the attributes or anything else since they already included in the memory estimate
@@ -75,10 +77,6 @@ public final class TypedProperties {
       size = other.size;
    }
 
-   public boolean hasInternalProperties() {
-      return internalProperties;
-   }
-
    public void putBooleanProperty(final SimpleString key, final boolean value) {
       checkCreateProperties();
       doPutValue(key, new BooleanValue(value));
@@ -321,7 +319,7 @@ public final class TypedProperties {
       }
    }
 
-   public synchronized void decode(final ActiveMQBuffer buffer) {
+   public synchronized void decode(final ByteBuf buffer) {
       byte b = buffer.readByte();
 
       if (b == DataConstants.NULL) {
@@ -406,7 +404,7 @@ public final class TypedProperties {
       }
    }
 
-   public synchronized void encode(final ActiveMQBuffer buffer) {
+   public synchronized void encode(final ByteBuf buffer) {
       if (properties == null) {
          buffer.writeByte(DataConstants.NULL);
       } else {
@@ -499,10 +497,6 @@ public final class TypedProperties {
    }
 
    private synchronized void doPutValue(final SimpleString key, final PropertyValue value) {
-      if (key.startsWith(AMQ_PROPNAME)) {
-         internalProperties = true;
-      }
-
       PropertyValue oldValue = properties.put(key, value);
       if (oldValue != null) {
          size += value.encodeSize() - oldValue.encodeSize();
@@ -547,7 +541,7 @@ public final class TypedProperties {
 
       abstract Object getValue();
 
-      abstract void write(ActiveMQBuffer buffer);
+      abstract void write(ByteBuf buffer);
 
       abstract int encodeSize();
 
@@ -568,7 +562,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.NULL);
       }
 
@@ -587,7 +581,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private BooleanValue(final ActiveMQBuffer buffer) {
+      private BooleanValue(final ByteBuf buffer) {
          val = buffer.readBoolean();
       }
 
@@ -597,7 +591,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.BOOLEAN);
          buffer.writeBoolean(val);
       }
@@ -617,7 +611,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private ByteValue(final ActiveMQBuffer buffer) {
+      private ByteValue(final ByteBuf buffer) {
          val = buffer.readByte();
       }
 
@@ -627,7 +621,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.BYTE);
          buffer.writeByte(val);
       }
@@ -646,7 +640,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private BytesValue(final ActiveMQBuffer buffer) {
+      private BytesValue(final ByteBuf buffer) {
          int len = buffer.readInt();
          val = new byte[len];
          buffer.readBytes(val);
@@ -658,7 +652,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.BYTES);
          buffer.writeInt(val.length);
          buffer.writeBytes(val);
@@ -679,7 +673,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private ShortValue(final ActiveMQBuffer buffer) {
+      private ShortValue(final ByteBuf buffer) {
          val = buffer.readShort();
       }
 
@@ -689,7 +683,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.SHORT);
          buffer.writeShort(val);
       }
@@ -708,7 +702,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private IntValue(final ActiveMQBuffer buffer) {
+      private IntValue(final ByteBuf buffer) {
          val = buffer.readInt();
       }
 
@@ -718,7 +712,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.INT);
          buffer.writeInt(val);
       }
@@ -737,7 +731,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private LongValue(final ActiveMQBuffer buffer) {
+      private LongValue(final ByteBuf buffer) {
          val = buffer.readLong();
       }
 
@@ -747,7 +741,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.LONG);
          buffer.writeLong(val);
       }
@@ -766,7 +760,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private FloatValue(final ActiveMQBuffer buffer) {
+      private FloatValue(final ByteBuf buffer) {
          val = Float.intBitsToFloat(buffer.readInt());
       }
 
@@ -776,7 +770,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.FLOAT);
          buffer.writeInt(Float.floatToIntBits(val));
       }
@@ -796,7 +790,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private DoubleValue(final ActiveMQBuffer buffer) {
+      private DoubleValue(final ByteBuf buffer) {
          val = Double.longBitsToDouble(buffer.readLong());
       }
 
@@ -806,7 +800,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.DOUBLE);
          buffer.writeLong(Double.doubleToLongBits(val));
       }
@@ -825,7 +819,7 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private CharValue(final ActiveMQBuffer buffer) {
+      private CharValue(final ByteBuf buffer) {
          val = (char) buffer.readShort();
       }
 
@@ -835,7 +829,7 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.CHAR);
          buffer.writeShort((short) val);
       }
@@ -854,8 +848,8 @@ public final class TypedProperties {
          this.val = val;
       }
 
-      private StringValue(final ActiveMQBuffer buffer) {
-         val = buffer.readSimpleString();
+      private StringValue(final ByteBuf buffer) {
+         val = SimpleString.readSimpleString(buffer);
       }
 
       @Override
@@ -864,9 +858,9 @@ public final class TypedProperties {
       }
 
       @Override
-      public void write(final ActiveMQBuffer buffer) {
+      public void write(final ByteBuf buffer) {
          buffer.writeByte(DataConstants.STRING);
-         buffer.writeSimpleString(val);
+         SimpleString.writeSimpleString(buffer, val);
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
index e75395b..84e1557 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java
@@ -18,7 +18,9 @@ package org.apache.activemq.artemis.utils;
 
 import java.lang.ref.SoftReference;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.logs.ActiveMQUtilBundle;
 import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
 
@@ -29,15 +31,43 @@ import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
  */
 public final class UTF8Util {
 
+
+   private static final boolean isTrace = ActiveMQUtilLogger.LOGGER.isTraceEnabled();
+
+   private static final ThreadLocal<SoftReference<StringUtilBuffer>> currenBuffer = new ThreadLocal<>();
+
    private UTF8Util() {
       // utility class
    }
+   public static void writeNullableString(ByteBuf buffer, final String val) {
+      if (val == null) {
+         buffer.writeByte(DataConstants.NULL);
+      } else {
+         buffer.writeByte(DataConstants.NOT_NULL);
+         writeString(buffer, val);
+      }
+   }
 
-   private static final boolean isTrace = ActiveMQUtilLogger.LOGGER.isTraceEnabled();
+   public static void writeString(final ByteBuf buffer, final String val) {
+      int length = val.length();
 
-   private static final ThreadLocal<SoftReference<StringUtilBuffer>> currenBuffer = new ThreadLocal<>();
+      buffer.writeInt(length);
+
+      if (length < 9) {
+         // If very small it's more performant to store char by char
+         for (int i = 0; i < val.length(); i++) {
+            buffer.writeShort((short) val.charAt(i));
+         }
+      } else if (length < 0xfff) {
+         // Store as UTF - this is quicker than char by char for most strings
+         saveUTF(buffer, val);
+      } else {
+         // Store as SimpleString, since can't store utf > 0xffff in length
+         SimpleString.writeSimpleString(buffer, new SimpleString(val));
+      }
+   }
 
-   public static void saveUTF(final ActiveMQBuffer out, final String str) {
+   public static void saveUTF(final ByteBuf out, final String str) {
       StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
 
       if (str.length() > 0xffff) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java
index 8013e96..cb6c8fe 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/TypedPropertiesTest.java
@@ -187,12 +187,12 @@ public class TypedPropertiesTest {
       props.putSimpleStringProperty(keyToRemove, RandomUtil.randomSimpleString());
 
       ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024);
-      props.encode(buffer);
+      props.encode(buffer.byteBuf());
 
       Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex());
 
       TypedProperties decodedProps = new TypedProperties();
-      decodedProps.decode(buffer);
+      decodedProps.decode(buffer.byteBuf());
 
       TypedPropertiesTest.assertEqualsTypeProperties(props, decodedProps);
 
@@ -200,7 +200,7 @@ public class TypedPropertiesTest {
 
       // After removing a property, you should still be able to encode the Property
       props.removeProperty(keyToRemove);
-      props.encode(buffer);
+      props.encode(buffer.byteBuf());
 
       Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex());
    }
@@ -210,12 +210,12 @@ public class TypedPropertiesTest {
       TypedProperties emptyProps = new TypedProperties();
 
       ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024);
-      emptyProps.encode(buffer);
+      emptyProps.encode(buffer.byteBuf());
 
       Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex());
 
       TypedProperties decodedProps = new TypedProperties();
-      decodedProps.decode(buffer);
+      decodedProps.decode(buffer.byteBuf());
 
       TypedPropertiesTest.assertEqualsTypeProperties(emptyProps, decodedProps);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
index 38ec105..c0d9db6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
@@ -262,12 +262,6 @@ public final class ActiveMQDefaultConfiguration {
    // The minimal number of data files before we can start compacting
    private static int DEFAULT_JOURNAL_COMPACT_MIN_FILES = 10;
 
-   // XXX Only meant to be used by project developers
-   private static int DEFAULT_JOURNAL_PERF_BLAST_PAGES = -1;
-
-   // XXX Only meant to be used by project developers
-   private static boolean DEFAULT_RUN_SYNC_SPEED_TEST = false;
-
    // Interval to log server specific information (e.g. memory usage etc)
    private static long DEFAULT_SERVER_DUMP_INTERVAL = -1;
 
@@ -801,20 +795,6 @@ public final class ActiveMQDefaultConfiguration {
    }
 
    /**
-    * XXX Only meant to be used by project developers
-    */
-   public static int getDefaultJournalPerfBlastPages() {
-      return DEFAULT_JOURNAL_PERF_BLAST_PAGES;
-   }
-
-   /**
-    * XXX Only meant to be used by project developers
-    */
-   public static boolean isDefaultRunSyncSpeedTest() {
-      return DEFAULT_RUN_SYNC_SPEED_TEST;
-   }
-
-   /**
     * Interval to log server specific information (e.g. memory usage etc)
     */
    public static long getDefaultServerDumpInterval() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
index 80116ed..4a5381c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
@@ -16,10 +16,14 @@
  */
 package org.apache.activemq.artemis.api.core;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.activemq.artemis.utils.UUID;
+import io.netty.buffer.ByteBuf;
+import org.apache.activemq.artemis.api.core.encode.BodyType;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.persistence.Persister;
 
 /**
  * A Message is a routable instance that has a payload.
@@ -48,9 +52,41 @@ import org.apache.activemq.artemis.utils.UUID;
  * <p>
  * If conversion is not allowed (for example calling {@code getFloatProperty} on a property set a
  * {@code boolean}), a {@link ActiveMQPropertyConversionException} will be thrown.
+ *
+ *
+ * User cases that will be covered by Message
+ *
+ * Receiving a buffer:
+ *
+ * Message encode = new CoreMessage(); // or any other implementation
+ * encode.receiveBuffer(buffer);
+ *
+ *
+ * Sending to a buffer:
+ *
+ * Message encode;
+ * size = encode.getEncodeSize();
+ * encode.encodeDirectly(bufferOutput);
+ *
+ *
+ * Disabling temporary buffer:
+ *
+ * // This will make the message to only be encoded directly to the output stream, useful on client core API
+ * encode.disableInternalBuffer();
+
  */
 public interface Message {
 
+
+   SimpleString HDR_ROUTE_TO_IDS = new SimpleString("_AMQ_ROUTE_TO");
+
+   SimpleString HDR_SCALEDOWN_TO_IDS = new SimpleString("_AMQ_SCALEDOWN_TO");
+
+   SimpleString HDR_ROUTE_TO_ACK_IDS = new SimpleString("_AMQ_ACK_ROUTE_TO");
+
+   // used by the bridges to set duplicates
+   SimpleString HDR_BRIDGE_DUPLICATE_ID = new SimpleString("_AMQ_BRIDGE_DUP");
+
    /**
     * the actual time the message was expired.
     * * *
@@ -129,6 +165,60 @@ public interface Message {
 
    byte STREAM_TYPE = 6;
 
+
+   void messageChanged();
+
+   /**
+    * Careful: Unless you are changing the body of the message, prefer getReadOnlyBodyBuffer
+    */
+   ActiveMQBuffer getBodyBuffer();
+
+   ActiveMQBuffer getReadOnlyBodyBuffer();
+
+   /** Used in the cases of large messages */
+   LargeBodyEncoder getBodyEncoder() throws ActiveMQException;
+
+   /** Context can be used by the application server to inject extra control, like a protocol specific on the server.
+    * There is only one per Object, use it wisely!
+    *
+    * Note: the intent of this was to replace PageStore reference on Message, but it will be later increased by adidn a ServerPojo
+    * */
+   RefCountMessageListener getContext();
+
+   Message setContext(RefCountMessageListener context);
+
+   /** The buffer will belong to this message, until release is called. */
+   Message setBuffer(ByteBuf buffer);
+
+   // TODO-now: Do we need this?
+   byte getType();
+
+   // TODO-now: Do we need this?
+   Message setType(byte type);
+
+   /**
+    * Returns whether this message is a <em>large message</em> or a regular message.
+    */
+   boolean isLargeMessage();
+
+   /**
+    * TODO: There's currently some treatment on LargeMessage that is done for server's side large message
+    *       This needs to be refactored, this Method shouldn't be used at all.
+    * @Deprecated do not use this, internal use only. *It will* be removed for sure even on minor releases.
+    * */
+   @Deprecated
+   default boolean isServerMessage() {
+      return false;
+   }
+
+   ByteBuf getBuffer();
+
+   /** It will generate a new instance of the message encode, being a deep copy, new properties, new everything */
+   Message copy();
+
+   /** It will generate a new instance of the message encode, being a deep copy, new properties, new everything */
+   Message copy(long newID);
+
    /**
     * Returns the messageID.
     * <br>
@@ -136,39 +226,43 @@ public interface Message {
     */
    long getMessageID();
 
+   Message setMessageID(long id);
+
    /**
-    * Returns the userID - this is an optional user specified UUID that can be set to identify the message
-    * and will be passed around with the message
-    *
-    * @return the user id
+    * Returns the expiration time of this message.
     */
-   UUID getUserID();
+   long getExpiration();
 
    /**
-    * Sets the user ID
+    * Sets the expiration of this message.
     *
-    * @param userID
+    * @param expiration expiration time
     */
-   Message setUserID(UUID userID);
+   Message setExpiration(long expiration);
 
    /**
-    * Returns the address this message is sent to.
+    * Returns whether this message is expired or not.
     */
-   SimpleString getAddress();
+   default boolean isExpired() {
+      if (getExpiration() == 0) {
+         return false;
+      }
+
+      return System.currentTimeMillis() - getExpiration() >= 0;
+   }
+
 
    /**
-    * Sets the address to send this message to.
+    * Returns the userID - this is an optional user specified UUID that can be set to identify the message
+    * and will be passed around with the message
     *
-    * @param address address to send the message to
+    * @return the user id
     */
-   Message setAddress(SimpleString address);
+   Object getUserID();
 
-   /**
-    * Returns this message type.
-    * <p>
-    * See fields {@literal *_TYPE} for possible values.
-    */
-   byte getType();
+   Message setUserID(Object userID);
+
+   void copyHeadersAndProperties(final Message msg);
 
    /**
     * Returns whether this message is durable or not.
@@ -182,36 +276,28 @@ public interface Message {
     */
    Message setDurable(boolean durable);
 
-   /**
-    * Returns the expiration time of this message.
-    */
-   long getExpiration();
+   Persister<Message> getPersister();
 
-   /**
-    * Returns whether this message is expired or not.
-    */
-   boolean isExpired();
+   Object getProtocol();
 
-   /**
-    * Sets the expiration of this message.
-    *
-    * @param expiration expiration time
-    */
-   Message setExpiration(long expiration);
+   Message setProtocol(Object protocol);
+
+   Object getBody();
+
+   BodyType getBodyType();
+
+   Message setBody(BodyType type, Object body);
+
+   String getAddress();
+
+   Message setAddress(String address);
+
+   SimpleString getAddressSimpleString();
+
+   Message setAddress(SimpleString address);
 
-   /**
-    * Returns the message timestamp.
-    * <br>
-    * The timestamp corresponds to the time this message
-    * was handled by an ActiveMQ Artemis server.
-    */
    long getTimestamp();
 
-   /**
-    * Sets the message timestamp.
-    *
-    * @param timestamp timestamp
-    */
    Message setTimestamp(long timestamp);
 
    /**
@@ -230,164 +316,128 @@ public interface Message {
     */
    Message setPriority(byte priority);
 
-   /**
-    * Returns the size of the <em>encoded</em> message.
-    */
-   int getEncodeSize();
+   /** Used to receive this message from an encoded medium buffer */
+   void receiveBuffer(ByteBuf buffer);
 
-   /**
-    * Returns whether this message is a <em>large message</em> or a regular message.
-    */
-   boolean isLargeMessage();
+   /** Used to send this message to an encoded medium buffer.
+    * @param buffer the buffer used.
+    * @param deliveryCount Some protocols (AMQP) will have this as part of the message. */
+   void sendBuffer(ByteBuf buffer, int deliveryCount);
 
-   /**
-    * Returns the message body as an ActiveMQBuffer
-    */
-   ActiveMQBuffer getBodyBuffer();
+   int getPersistSize();
 
-   /**
-    * Writes the input byte array to the message body ActiveMQBuffer
-    */
-   Message writeBodyBufferBytes(byte[] bytes);
+   void persist(ActiveMQBuffer targetRecord);
 
-   /**
-    * Writes the input String to the message body ActiveMQBuffer
-    */
-   Message writeBodyBufferString(String string);
+   void reloadPersistence(ActiveMQBuffer record);
 
-   /**
-    * Returns a <em>copy</em> of the message body as an ActiveMQBuffer. Any modification
-    * of this buffer should not impact the underlying buffer.
-    */
-   ActiveMQBuffer getBodyBufferDuplicate();
+   default void releaseBuffer() {
+      ByteBuf buffer = getBuffer();
+      if (buffer != null) {
+         buffer.release();
+      }
+      setBuffer(null);
+   }
 
-   // Properties
-   // -----------------------------------------------------------------
+   default String getText() {
+      if (getBodyType() == BodyType.Text) {
+         return getBody().toString();
+      } else {
+         return null;
+      }
+   }
 
-   /**
-    * Puts a boolean property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putBooleanProperty(SimpleString key, boolean value);
+   // TODO-now: move this to some utility class
+   default void referenceOriginalMessage(final Message original, String originalQueue) {
+      String queueOnMessage = original.getStringProperty(Message.HDR_ORIGINAL_QUEUE.toString());
 
-   /**
-    * @see #putBooleanProperty(SimpleString, boolean)
-    */
-   Message putBooleanProperty(String key, boolean value);
+      if (queueOnMessage != null) {
+         putStringProperty(Message.HDR_ORIGINAL_QUEUE.toString(), queueOnMessage);
+      } else if (originalQueue != null) {
+         putStringProperty(Message.HDR_ORIGINAL_QUEUE.toString(), originalQueue);
+      }
 
-   /**
-    * Puts a byte property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putByteProperty(SimpleString key, byte value);
+      if (original.containsProperty(Message.HDR_ORIG_MESSAGE_ID.toString())) {
+         putStringProperty(Message.HDR_ORIGINAL_ADDRESS.toString(), original.getStringProperty(Message.HDR_ORIGINAL_ADDRESS.toString()));
 
-   /**
-    * @see #putByteProperty(SimpleString, byte)
-    */
-   Message putByteProperty(String key, byte value);
+         putLongProperty(Message.HDR_ORIG_MESSAGE_ID.toString(), original.getLongProperty(Message.HDR_ORIG_MESSAGE_ID.toString()));
+      } else {
+         putStringProperty(Message.HDR_ORIGINAL_ADDRESS.toString(), original.getAddress());
 
-   /**
-    * Puts a byte[] property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putBytesProperty(SimpleString key, byte[] value);
+         putLongProperty(Message.HDR_ORIG_MESSAGE_ID.toString(), original.getMessageID());
+      }
 
-   /**
-    * @see #putBytesProperty(SimpleString, byte[])
-    */
-   Message putBytesProperty(String key, byte[] value);
+      // reset expiry
+      setExpiration(0);
+   }
 
    /**
-    * Puts a short property in this message.
-    *
-    * @param key   property name
-    * @param value property value
+    * it will translate a property named HDR_DUPLICATE_DETECTION_ID.
+    * TODO-NOW: this can probably be replaced by an utility.
+    * @return
     */
-   Message putShortProperty(SimpleString key, short value);
+   default byte[] getDuplicateIDBytes() {
+      Object duplicateID = getDuplicateProperty();
 
-   /**
-    * @see #putShortProperty(SimpleString, short)
-    */
-   Message putShortProperty(String key, short value);
+      if (duplicateID == null) {
+         return null;
+      } else {
+         if (duplicateID instanceof SimpleString) {
+            return ((SimpleString) duplicateID).getData();
+         } else if (duplicateID instanceof String) {
+            return new SimpleString(duplicateID.toString()).getData();
+         } else {
+            return (byte[]) duplicateID;
+         }
+      }
+   }
 
    /**
-    * Puts a char property in this message.
-    *
-    * @param key   property name
-    * @param value property value
+    * it will translate a property named HDR_DUPLICATE_DETECTION_ID.
+    * TODO-NOW: this can probably be replaced by an utility.
+    * @return
     */
-   Message putCharProperty(SimpleString key, char value);
+   default Object getDuplicateProperty() {
+      return getObjectProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString());
+   }
 
-   /**
-    * @see #putCharProperty(SimpleString, char)
-    */
-   Message putCharProperty(String key, char value);
 
-   /**
-    * Puts an int property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putIntProperty(SimpleString key, int value);
+   Message putBooleanProperty(String key, boolean value);
 
-   /**
-    * @see #putIntProperty(SimpleString, int)
-    */
-   Message putIntProperty(String key, int value);
+   Message putByteProperty(String key, byte value);
 
-   /**
-    * Puts a long property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putLongProperty(SimpleString key, long value);
+   Message putBytesProperty(String key, byte[] value);
 
-   /**
-    * @see #putLongProperty(SimpleString, long)
-    */
-   Message putLongProperty(String key, long value);
+   Message putShortProperty(String key, short value);
 
-   /**
-    * Puts a float property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putFloatProperty(SimpleString key, float value);
+   Message putCharProperty(String key, char value);
 
-   /**
-    * @see #putFloatProperty(SimpleString, float)
-    */
-   Message putFloatProperty(String key, float value);
+   Message putIntProperty(String key, int value);
 
-   /**
-    * Puts a double property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putDoubleProperty(SimpleString key, double value);
+   Message putLongProperty(String key, long value);
+
+   Message putFloatProperty(String key, float value);
 
-   /**
-    * @see #putDoubleProperty(SimpleString, double)
-    */
    Message putDoubleProperty(String key, double value);
 
-   /**
-    * Puts a SimpleString property in this message.
-    *
-    * @param key   property name
-    * @param value property value
-    */
-   Message putStringProperty(SimpleString key, SimpleString value);
+
+
+   Message putBooleanProperty(SimpleString key, boolean value);
+
+   Message putByteProperty(SimpleString key, byte value);
+
+   Message putBytesProperty(SimpleString key, byte[] value);
+
+   Message putShortProperty(SimpleString key, short value);
+
+   Message putCharProperty(SimpleString key, char value);
+
+   Message putIntProperty(SimpleString key, int value);
+
+   Message putLongProperty(SimpleString key, long value);
+
+   Message putFloatProperty(SimpleString key, float value);
+
+   Message putDoubleProperty(SimpleString key, double value);
 
    /**
     * Puts a String property in this message.
@@ -397,202 +447,125 @@ public interface Message {
     */
    Message putStringProperty(String key, String value);
 
-   /**
-    * Puts an Object property in this message. <br>
-    * Accepted types are:
-    * <ul>
-    * <li>Boolean</li>
-    * <li>Byte</li>
-    * <li>Short</li>
-    * <li>Character</li>
-    * <li>Integer</li>
-    * <li>Long</li>
-    * <li>Float</li>
-    * <li>Double</li>
-    * <li>String</li>
-    * <li>SimpleString</li>
-    * </ul>
-    * Using any other type will throw a PropertyConversionException.
-    *
-    * @param key   property name
-    * @param value property value
-    * @throws ActiveMQPropertyConversionException if the value is not one of the accepted property
-    *                                             types.
-    */
-   Message putObjectProperty(SimpleString key, Object value) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #putObjectProperty(SimpleString, Object)
-    */
    Message putObjectProperty(String key, Object value) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Removes the property corresponding to the specified key.
-    *
-    * @param key property name
-    * @return the value corresponding to the specified key or @{code null}
-    */
-   Object removeProperty(SimpleString key);
+   Message putObjectProperty(SimpleString key, Object value) throws ActiveMQPropertyConversionException;
 
-   /**
-    * @see #removeProperty(SimpleString)
-    */
    Object removeProperty(String key);
 
-   /**
-    * Returns {@code true} if this message contains a property with the given key, {@code false} else.
-    *
-    * @param key property name
-    */
-   boolean containsProperty(SimpleString key);
-
-   /**
-    * @see #containsProperty(SimpleString)
-    */
    boolean containsProperty(String key);
 
-   /**
-    * Returns the property corresponding to the specified key as a Boolean.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Boolean
-    */
-   Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getBooleanProperty(SimpleString)
-    */
    Boolean getBooleanProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a Byte.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Byte
-    */
-   Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getByteProperty(SimpleString)
-    */
    Byte getByteProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a Double.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Double
-    */
-   Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getDoubleProperty(SimpleString)
-    */
    Double getDoubleProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as an Integer.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to an Integer
-    */
-   Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getIntProperty(SimpleString)
-    */
    Integer getIntProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a Long.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Long
-    */
-   Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getLongProperty(SimpleString)
-    */
    Long getLongProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key
-    */
-   Object getObjectProperty(SimpleString key);
-
-   /**
-    * @see #getBooleanProperty(SimpleString)
-    */
    Object getObjectProperty(String key);
 
-   /**
-    * Returns the property corresponding to the specified key as a Short.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Short
-    */
-   Short getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getShortProperty(SimpleString)
-    */
    Short getShortProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a Float.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a Float
-    */
-   Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getFloatProperty(SimpleString)
-    */
    Float getFloatProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a String.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a String
-    */
-   String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getStringProperty(SimpleString)
-    */
    String getStringProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a SimpleString.
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a SimpleString
-    */
-   SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException;
-
-   /**
-    * @see #getSimpleStringProperty(SimpleString)
-    */
    SimpleString getSimpleStringProperty(String key) throws ActiveMQPropertyConversionException;
 
-   /**
-    * Returns the property corresponding to the specified key as a byte[].
-    *
-    * @throws ActiveMQPropertyConversionException if the value can not be converted to a byte[]
-    */
+   byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException;
+
+
+   Object removeProperty(SimpleString key);
+
+   boolean containsProperty(SimpleString key);
+
+   Boolean getBooleanProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Byte getByteProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Double getDoubleProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Integer getIntProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Long getLongProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Object getObjectProperty(SimpleString key);
+
+   Short getShortProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   Float getFloatProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   String getStringProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
+   SimpleString getSimpleStringProperty(SimpleString key) throws ActiveMQPropertyConversionException;
+
    byte[] getBytesProperty(SimpleString key) throws ActiveMQPropertyConversionException;
 
+   Message putStringProperty(SimpleString key, SimpleString value);
+
    /**
-    * @see #getBytesProperty(SimpleString)
+    * Returns the size of the <em>encoded</em> message.
     */
-   byte[] getBytesProperty(String key) throws ActiveMQPropertyConversionException;
+   int getEncodeSize();
 
    /**
     * Returns all the names of the properties for this message.
     */
    Set<SimpleString> getPropertyNames();
 
+
+
+   int getRefCount();
+
+   int incrementRefCount() throws Exception;
+
+   int decrementRefCount() throws Exception;
+
+   int incrementDurableRefCount();
+
+   int decrementDurableRefCount();
+
    /**
     * @return Returns the message in Map form, useful when encoding to JSON
     */
-   Map<String, Object> toMap();
+   default Map<String, Object> toMap() {
+      Map map = toPropertyMap();
+      map.put("messageID", getMessageID());
+      Object userID = getUserID();
+      if (getUserID() != null) {
+         map.put("userID", "ID:" + userID.toString());
+      }
+
+      map.put("address", getAddress());
+      map.put("type", getBodyType().toString());
+      map.put("durable", isDurable());
+      map.put("expiration", getExpiration());
+      map.put("timestamp", getTimestamp());
+      map.put("priority", (int)getPriority());
+
+      return map;
+   }
 
    /**
     * @return Returns the message properties in Map form, useful when encoding to JSON
     */
-   Map<String, Object> toPropertyMap();
+   default Map<String, Object> toPropertyMap() {
+      Map map = new HashMap<>();
+      for (SimpleString name : getPropertyNames()) {
+         map.put(name.toString(), getObjectProperty(name.toString()));
+      }
+      return map;
+   }
+
+
+   /** This should make you convert your message into Core format. */
+   Message toCore();
+
+   int getMemoryEstimate();
+
+
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java
new file mode 100644
index 0000000..64dd44d
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessage.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.api.core;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public abstract class RefCountMessage implements Message {
+
+   private final AtomicInteger durableRefCount = new AtomicInteger();
+
+   private final AtomicInteger refCount = new AtomicInteger();
+
+   private RefCountMessageListener context;
+
+   @Override
+   public Message setContext(RefCountMessageListener context) {
+      this.context = context;
+      return this;
+   }
+
+   @Override
+   public RefCountMessageListener getContext() {
+      return context;
+   }
+
+   @Override
+   public int getRefCount() {
+      return refCount.get();
+   }
+
+   @Override
+   public int incrementRefCount() throws Exception {
+      int count = refCount.incrementAndGet();
+      if (context != null) {
+         context.nonDurableUp(this, count);
+      }
+      return count;
+   }
+
+   @Override
+   public int incrementDurableRefCount() {
+      int count = durableRefCount.incrementAndGet();
+      if (context != null) {
+         context.durableUp(this, count);
+      }
+      return count;
+   }
+
+   @Override
+   public int decrementDurableRefCount() {
+      int count = durableRefCount.decrementAndGet();
+      if (context != null) {
+         context.durableDown(this, count);
+      }
+      return count;
+   }
+
+   @Override
+   public int decrementRefCount() throws Exception {
+      int count = refCount.decrementAndGet();
+      if (context != null) {
+         context.nonDurableDown(this, count);
+      }
+      return count;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessageListener.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessageListener.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessageListener.java
new file mode 100644
index 0000000..e68dffd
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/RefCountMessageListener.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.api.core;
+
+/** If {@link Message#getContext()} != null and is implementing this interface.
+ *  These methods will be called during refCount operations */
+public interface RefCountMessageListener {
+
+   void durableUp(Message message, int durableCount);
+
+   void durableDown(Message message, int durableCount);
+
+   void nonDurableUp(Message message, int nonDurableCoun);
+
+   void nonDurableDown(Message message, int nonDurableCoun);
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java
index e87d365..daded00 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ClientMessage.java
@@ -234,24 +234,16 @@ public interface ClientMessage extends Message {
     * Overridden from {@link Message} to enable fluent API
     */
    @Override
-   ClientMessage putStringProperty(SimpleString key, SimpleString value);
-
-   /**
-    * Overridden from {@link Message} to enable fluent API
-    */
-   @Override
    ClientMessage putStringProperty(String key, String value);
 
    /**
     * Overridden from {@link Message} to enable fluent API
     */
-   @Override
    ClientMessage writeBodyBufferBytes(byte[] bytes);
 
    /**
     * Overridden from {@link Message} to enable fluent API
     */
-   @Override
    ClientMessage writeBodyBufferString(String string);
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/BodyType.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/BodyType.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/BodyType.java
new file mode 100644
index 0000000..743583b
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/BodyType.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.api.core.encode;
+
+public enum BodyType {
+   Undefined, Bytes, Map, Object, Stream, Text
+}


[22/29] activemq-artemis git commit: fixing paging & flow control on AMQP

Posted by cl...@apache.org.
fixing paging & flow control on AMQP


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e85f755a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e85f755a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e85f755a

Branch: refs/heads/artemis-1009
Commit: e85f755a0d128b4338d1c2c5911b42a35bc35787
Parents: 46be6a2
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 28 21:01:05 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/api/core/Message.java      |  6 ++++
 .../artemis/core/message/impl/CoreMessage.java  | 14 --------
 .../protocol/amqp/broker/AMQPMessage.java       | 35 ++++++++++++++++----
 3 files changed, 34 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e85f755a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
index 4a5381c..b266279 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java
@@ -77,6 +77,12 @@ import org.apache.activemq.artemis.core.persistence.Persister;
  */
 public interface Message {
 
+   // This is an estimate of how much memory a Message takes up, exclusing body and properties
+   // Note, it is only an estimate, it's not possible to be entirely sure with Java
+   // This figure is calculated using the test utilities in org.apache.activemq.tests.unit.util.sizeof
+   // The value is somewhat higher on 64 bit architectures, probably due to different alignment
+   int memoryOffset = 352;
+
 
    SimpleString HDR_ROUTE_TO_IDS = new SimpleString("_AMQ_ROUTE_TO");
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e85f755a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index fd09751..edbcaa9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -45,15 +45,8 @@ public class CoreMessage extends RefCountMessage {
 
    public static final int BUFFER_HEADER_SPACE = PacketImpl.PACKET_HEADERS_SIZE;
 
-   // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
-   // Note, it is only an estimate, it's not possible to be entirely sure with Java
-   // This figure is calculated using the test utilities in org.apache.activemq.tests.unit.util.sizeof
-   // The value is somewhat higher on 64 bit architectures, probably due to different alignment
-   private static final int memoryOffset = 352;
-
    private volatile int memoryEstimate = -1;
 
-
    private static final Logger logger = Logger.getLogger(CoreMessage.class);
 
    // There's an integer with the number of bytes for the body
@@ -351,16 +344,9 @@ public class CoreMessage extends RefCountMessage {
       return this.properties;
    }
 
-
    @Override
    public int getMemoryEstimate() {
       if (memoryEstimate == -1) {
-         if (buffer == null) {
-            new Exception("It is null").printStackTrace();
-         }
-         if (properties == null) {
-            new Exception("Properties It is null").printStackTrace();
-         }
          memoryEstimate = memoryOffset +
             (buffer != null ? buffer.capacity() : 0) +
             (properties != null ? properties.getMemoryOffset() : 0);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e85f755a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index ee2f870..c530c94 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -34,6 +34,7 @@ import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
 import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.activemq.artemis.utils.DataConstants;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
 import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
 import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
 import org.apache.qpid.proton.amqp.messaging.Header;
@@ -48,6 +49,8 @@ import org.apache.qpid.proton.util.TLSEncoder;
 // see https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format
 public class AMQPMessage extends RefCountMessage {
 
+   private volatile int memoryEstimate = -1;
+
    final long messageFormat;
    private ProtonProtocolManager protocolManager;
    ByteBuf data;
@@ -192,6 +195,9 @@ public class AMQPMessage extends RefCountMessage {
             } else {
                section = null;
             }
+         } else {
+            // meaning there is no header
+            headerEnd = 0;
          }
 
          if (!readApplicationProperties) {
@@ -257,27 +263,26 @@ public class AMQPMessage extends RefCountMessage {
       this.data = null;
    }
 
-   // TODO-now this only make sense on Core
    @Override
    public ActiveMQBuffer getBodyBuffer() {
+      // NO-IMPL
       return null;
    }
 
-   // TODO-now this only make sense on Core
    @Override
    public ActiveMQBuffer getReadOnlyBodyBuffer() {
+      // NO-IMPL
       return null;
    }
 
-   // TODO: Refactor Large message
    @Override
    public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
+      // NO-IMPL
       return null;
    }
 
    @Override
    public byte getType() {
-      // TODO-now: what to do here?
       return type;
    }
 
@@ -309,7 +314,6 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public org.apache.activemq.artemis.api.core.Message copy() {
-      // TODO-now: what to do with this?
       AMQPMessage newEncode = new AMQPMessage(this.messageFormat, data.array(), protocolManager);
       return newEncode;
    }
@@ -471,7 +475,19 @@ public class AMQPMessage extends RefCountMessage {
       //       I would send a new instance of Header with a new delivery count, and only send partial of the buffer
       //       previously received
       checkBuffer();
-      buffer.writeBytes(data);
+      Header header = getHeader();
+      if (header != null) {
+         synchronized (header) {
+            if (header.getDeliveryCount() != null) {
+               header.setDeliveryCount(UnsignedInteger.valueOf(header.getDeliveryCount().intValue() + 1));
+            } else {
+               header.setDeliveryCount(UnsignedInteger.valueOf(1));
+            }
+            TLSEncoder.getEncoder().setByteBuffer(new NettyWritable(buffer));
+            TLSEncoder.getEncoder().writeObject(header);
+         }
+      }
+      buffer.writeBytes(data, headerEnd, data.writerIndex() - headerEnd);
    }
 
    @Override
@@ -728,7 +744,12 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public int getMemoryEstimate() {
-      return 0;
+      if (memoryEstimate == -1) {
+         memoryEstimate = memoryOffset +
+            (data != null ? data.capacity() : 0);
+      }
+
+      return memoryEstimate;
    }
 
    @Override


[13/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index 2943f15..ed9a396 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -43,13 +43,14 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.io.IOCallback;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
 import org.apache.activemq.artemis.core.paging.cursor.PagedReference;
 import org.apache.activemq.artemis.core.persistence.QueueStatus;
@@ -71,7 +72,6 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ScheduledDeliveryHandler;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
 import org.apache.activemq.artemis.core.server.cluster.impl.Redistributor;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
@@ -440,12 +440,12 @@ public class QueueImpl implements Queue {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       context.addQueue(address, this);
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) {
+   public void routeWithAck(Message message, RoutingContext context) {
       context.addQueueWithAck(address, this);
    }
 
@@ -922,7 +922,7 @@ public class QueueImpl implements Queue {
    }
 
    @Override
-   public boolean hasMatchingConsumer(final ServerMessage message) {
+   public boolean hasMatchingConsumer(final Message message) {
       for (ConsumerHolder holder : consumerList) {
          Consumer consumer = holder.consumer;
 
@@ -1055,7 +1055,7 @@ public class QueueImpl implements Queue {
          pageSubscription.ack((PagedReference) ref);
          postAcknowledge(ref);
       } else {
-         ServerMessage message = ref.getMessage();
+         Message message = ref.getMessage();
 
          boolean durableRef = message.isDurable() && durable;
 
@@ -1087,7 +1087,7 @@ public class QueueImpl implements Queue {
 
          getRefsOperation(tx).addAck(ref);
       } else {
-         ServerMessage message = ref.getMessage();
+         Message message = ref.getMessage();
 
          boolean durableRef = message.isDurable() && durable;
 
@@ -1111,7 +1111,7 @@ public class QueueImpl implements Queue {
 
    @Override
    public void reacknowledge(final Transaction tx, final MessageReference ref) throws Exception {
-      ServerMessage message = ref.getMessage();
+      Message message = ref.getMessage();
 
       if (message.isDurable() && durable) {
          tx.setContainsPersistent();
@@ -1216,11 +1216,11 @@ public class QueueImpl implements Queue {
       return expiryAddress;
    }
 
-   private SimpleString extractAddress(ServerMessage message) {
-      if (message.containsProperty(Message.HDR_ORIG_MESSAGE_ID)) {
-         return message.getSimpleStringProperty(Message.HDR_ORIGINAL_ADDRESS);
+   private SimpleString extractAddress(Message message) {
+      if (message.containsProperty(Message.HDR_ORIG_MESSAGE_ID.toString())) {
+         return message.getSimpleStringProperty(Message.HDR_ORIGINAL_ADDRESS.toString());
       } else {
-         return message.getAddress();
+         return message.getAddressSimpleString();
       }
    }
 
@@ -1244,7 +1244,9 @@ public class QueueImpl implements Queue {
       List<MessageReference> scheduledMessages = scheduledDeliveryHandler.cancel(null);
       if (scheduledMessages != null && scheduledMessages.size() > 0) {
          for (MessageReference ref : scheduledMessages) {
-            ref.getMessage().putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, ref.getScheduledDeliveryTime());
+
+            // TODO-now remove this, use something on Reference
+//            ref.getMessage().putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, ref.getScheduledDeliveryTime());
             ref.setScheduledDeliveryTime(0);
          }
          this.addHead(scheduledMessages, true);
@@ -2274,7 +2276,7 @@ public class QueueImpl implements Queue {
    public boolean checkRedelivery(final MessageReference reference,
                                   final long timeBase,
                                   final boolean ignoreRedeliveryDelay) throws Exception {
-      ServerMessage message = reference.getMessage();
+      Message message = reference.getMessage();
 
       if (internalQueue) {
          if (logger.isTraceEnabled()) {
@@ -2337,7 +2339,7 @@ public class QueueImpl implements Queue {
                      final boolean expiry,
                      final boolean rejectDuplicate,
                      final long... queueIDs) throws Exception {
-      ServerMessage copyMessage = makeCopy(ref, expiry);
+      Message copyMessage = makeCopy(ref, expiry);
 
       copyMessage.setAddress(toAddress);
 
@@ -2346,7 +2348,7 @@ public class QueueImpl implements Queue {
          for (long id : queueIDs) {
             buffer.putLong(id);
          }
-         copyMessage.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+         copyMessage.putBytesProperty(Message.HDR_ROUTE_TO_IDS.toString(), buffer.array());
       }
 
       postOffice.route(copyMessage, tx, false, rejectDuplicate);
@@ -2358,16 +2360,17 @@ public class QueueImpl implements Queue {
    private void moveBetweenSnFQueues(final SimpleString queueSuffix,
                                      final Transaction tx,
                                      final MessageReference ref) throws Exception {
-      ServerMessage copyMessage = makeCopy(ref, false, false);
+      Message copyMessage = makeCopy(ref, false, false);
 
       byte[] oldRouteToIDs = null;
       String targetNodeID;
       Binding targetBinding;
 
+      // TODO-now: this needs to go away
       // remove the old route
       for (SimpleString propName : copyMessage.getPropertyNames()) {
-         if (propName.startsWith(MessageImpl.HDR_ROUTE_TO_IDS)) {
-            oldRouteToIDs = (byte[]) copyMessage.removeProperty(propName);
+         if (propName.startsWith(Message.HDR_ROUTE_TO_IDS)) {
+            oldRouteToIDs = (byte[]) copyMessage.removeProperty(propName.toString());
             final String hashcodeToString = oldRouteToIDs.toString(); // don't use Arrays.toString(..) here
             logger.debug("Removed property from message: " + propName + " = " + hashcodeToString + " (" + ByteBuffer.wrap(oldRouteToIDs).getLong() + ")");
 
@@ -2420,7 +2423,7 @@ public class QueueImpl implements Queue {
    }
 
    private Pair<String, Binding> locateTargetBinding(SimpleString queueSuffix,
-                                                     ServerMessage copyMessage,
+                                                     Message copyMessage,
                                                      long oldQueueID) {
       String targetNodeID = null;
       Binding targetBinding = null;
@@ -2440,7 +2443,7 @@ public class QueueImpl implements Queue {
                // parse the queue name of the remote queue binding to determine the node ID
                String temp = remoteQueueBinding.getQueue().getName().toString();
                targetNodeID = temp.substring(temp.lastIndexOf(".") + 1);
-               logger.debug("Message formerly destined for " + oldQueueName + " with ID: " + oldQueueID + " on address " + copyMessage.getAddress() + " on node " + targetNodeID);
+               logger.debug("Message formerly destined for " + oldQueueName + " with ID: " + oldQueueID + " on address " + copyMessage.getAddressSimpleString() + " on node " + targetNodeID);
 
                // now that we have the name of the queue we need to look through all the bindings again to find the new remote queue binding
                for (Map.Entry<SimpleString, Binding> entry2 : postOffice.getAllBindings().entrySet()) {
@@ -2468,14 +2471,14 @@ public class QueueImpl implements Queue {
       return new Pair<>(targetNodeID, targetBinding);
    }
 
-   private ServerMessage makeCopy(final MessageReference ref, final boolean expiry) throws Exception {
+   private Message makeCopy(final MessageReference ref, final boolean expiry) throws Exception {
       return makeCopy(ref, expiry, true);
    }
 
-   private ServerMessage makeCopy(final MessageReference ref,
+   private Message makeCopy(final MessageReference ref,
                                   final boolean expiry,
                                   final boolean copyOriginalHeaders) throws Exception {
-      ServerMessage message = ref.getMessage();
+      Message message = ref.getMessage();
       /*
        We copy the message and send that to the dla/expiry queue - this is
        because otherwise we may end up with a ref with the same message id in the
@@ -2487,7 +2490,15 @@ public class QueueImpl implements Queue {
 
       long newID = storageManager.generateID();
 
-      ServerMessage copy = message.makeCopyForExpiryOrDLA(newID, ref, expiry, copyOriginalHeaders);
+      Message copy = message.copy(newID);
+
+      if (copyOriginalHeaders) {
+         copy.referenceOriginalMessage(message, ref != null ? ref.getQueue().getAddress().toString() : null);
+      }
+
+      if (expiry) {
+         copy.putLongProperty(Message.HDR_ACTUAL_EXPIRY_TIME.toString(), System.currentTimeMillis());
+      }
 
       return copy;
    }
@@ -2549,7 +2560,7 @@ public class QueueImpl implements Queue {
          tx = new TransactionImpl(storageManager);
       }
 
-      ServerMessage copyMessage = makeCopy(ref, reason == AckReason.EXPIRED);
+      Message copyMessage = makeCopy(ref, reason == AckReason.EXPIRED);
 
       copyMessage.setAddress(address);
 
@@ -2719,7 +2730,7 @@ public class QueueImpl implements Queue {
          return;
       }
 
-      ServerMessage message;
+      Message message;
 
       try {
          message = ref.getMessage();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java
index 8e3a94b..0f3da07 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java
@@ -22,12 +22,12 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.paging.cursor.NonExistentPage;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
 import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
@@ -122,7 +122,7 @@ public class RefsOperation extends TransactionOperationAbstract {
          try {
             Transaction ackedTX = new TransactionImpl(storageManager);
             for (MessageReference ref : ackedRefs) {
-               ServerMessage message = ref.getMessage();
+               Message message = ref.getMessage();
                if (message.isDurable()) {
                   int durableRefCount = message.incrementDurableRefCount();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
index a5f96b1..4eda3ed 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java
@@ -29,6 +29,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -39,7 +40,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@@ -54,7 +55,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.ClusterControl;
 import org.apache.activemq.artemis.core.server.cluster.ClusterController;
 import org.apache.activemq.artemis.core.transaction.ResourceManager;
@@ -193,7 +193,7 @@ public class ScaleDownHandler {
                      buffer.putLong(queueID);
                   }
 
-                  message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+                  message.putBytesProperty(Message.HDR_ROUTE_TO_IDS.toString(), buffer.array());
 
                   if (logger.isDebugEnabled()) {
                      if (messageReference.isPaged()) {
@@ -203,7 +203,8 @@ public class ScaleDownHandler {
                      }
                   }
 
-                  producer.send(address, message);
+                  // TODO-no: fix encoding
+                  producer.send(address, (Message)message);
                   messageCount++;
 
                   messagesIterator.remove();
@@ -264,11 +265,11 @@ public class ScaleDownHandler {
                byte[] oldRouteToIDs = null;
 
                List<SimpleString> propertiesToRemove = new ArrayList<>();
-               message.removeProperty(MessageImpl.HDR_ROUTE_TO_IDS);
+               message.removeProperty(Message.HDR_ROUTE_TO_IDS.toString());
                for (SimpleString propName : message.getPropertyNames()) {
-                  if (propName.startsWith(MessageImpl.HDR_ROUTE_TO_IDS)) {
+                  if (propName.startsWith(Message.HDR_ROUTE_TO_IDS)) {
                      if (propName.toString().endsWith(propertyEnd)) {
-                        oldRouteToIDs = message.getBytesProperty(propName);
+                        oldRouteToIDs = message.getBytesProperty(propName.toString());
                      }
                      propertiesToRemove.add(propName);
                   }
@@ -277,17 +278,19 @@ public class ScaleDownHandler {
                // TODO: what if oldRouteToIDs == null ??
 
                for (SimpleString propertyToRemove : propertiesToRemove) {
-                  message.removeProperty(propertyToRemove);
+                  message.removeProperty(propertyToRemove.toString());
                }
 
                if (queueOnTarget) {
-                  message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, oldRouteToIDs);
+                  message.putBytesProperty(Message.HDR_ROUTE_TO_IDS.toString(), oldRouteToIDs);
                } else {
-                  message.putBytesProperty(MessageImpl.HDR_SCALEDOWN_TO_IDS, oldRouteToIDs);
+                  message.putBytesProperty(Message.HDR_SCALEDOWN_TO_IDS.toString(), oldRouteToIDs);
                }
 
                logger.debug("Scaling down message " + message + " from " + address + " to " + message.getAddress() + " on node " + targetNodeId);
-               producer.send(message.getAddress(), message);
+
+               // TODO-now: fix encode
+               producer.send(message.getAddress(), (Message)message);
 
                messageCount++;
 
@@ -322,13 +325,13 @@ public class ScaleDownHandler {
          List<TransactionOperation> allOperations = transaction.getAllOperations();
 
          // Get the information of the Prepared TXs so it could replay the TXs
-         Map<ServerMessage, Pair<List<Long>, List<Long>>> queuesToSendTo = new HashMap<>();
+         Map<Message, Pair<List<Long>, List<Long>>> queuesToSendTo = new HashMap<>();
          for (TransactionOperation operation : allOperations) {
             if (operation instanceof PostOfficeImpl.AddOperation) {
                PostOfficeImpl.AddOperation addOperation = (PostOfficeImpl.AddOperation) operation;
                List<MessageReference> refs = addOperation.getRelatedMessageReferences();
                for (MessageReference ref : refs) {
-                  ServerMessage message = ref.getMessage();
+                  Message message = ref.getMessage();
                   Queue queue = ref.getQueue();
                   long queueID;
                   String queueName = queue.getName().toString();
@@ -336,7 +339,7 @@ public class ScaleDownHandler {
                   if (queueIDs.containsKey(queueName)) {
                      queueID = queueIDs.get(queueName);
                   } else {
-                     queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddress());
+                     queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddressSimpleString());
                      queueIDs.put(queueName, queueID);  // store it so we don't have to look it up every time
                   }
                   Pair<List<Long>, List<Long>> queueIds = queuesToSendTo.get(message);
@@ -350,7 +353,7 @@ public class ScaleDownHandler {
                RefsOperation refsOperation = (RefsOperation) operation;
                List<MessageReference> refs = refsOperation.getReferencesToAcknowledge();
                for (MessageReference ref : refs) {
-                  ServerMessage message = ref.getMessage();
+                  Message message = ref.getMessage();
                   Queue queue = ref.getQueue();
                   long queueID;
                   String queueName = queue.getName().toString();
@@ -358,7 +361,7 @@ public class ScaleDownHandler {
                   if (queueIDs.containsKey(queueName)) {
                      queueID = queueIDs.get(queueName);
                   } else {
-                     queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddress());
+                     queueID = createQueueIfNecessaryAndGetID(queueCreateSession, queue, message.getAddressSimpleString());
                      queueIDs.put(queueName, queueID);  // store it so we don't have to look it up every time
                   }
                   Pair<List<Long>, List<Long>> queueIds = queuesToSendTo.get(message);
@@ -373,23 +376,23 @@ public class ScaleDownHandler {
          }
 
          ClientProducer producer = session.createProducer();
-         for (Map.Entry<ServerMessage, Pair<List<Long>, List<Long>>> entry : queuesToSendTo.entrySet()) {
+         for (Map.Entry<Message, Pair<List<Long>, List<Long>>> entry : queuesToSendTo.entrySet()) {
             List<Long> ids = entry.getValue().getA();
             ByteBuffer buffer = ByteBuffer.allocate(ids.size() * 8);
             for (Long id : ids) {
                buffer.putLong(id);
             }
-            ServerMessage message = entry.getKey();
-            message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+            Message message = entry.getKey();
+            message.putBytesProperty(Message.HDR_ROUTE_TO_IDS.toString(), buffer.array());
             ids = entry.getValue().getB();
             if (ids.size() > 0) {
                buffer = ByteBuffer.allocate(ids.size() * 8);
                for (Long id : ids) {
                   buffer.putLong(id);
                }
-               message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_ACK_IDS, buffer.array());
+               message.putBytesProperty(Message.HDR_ROUTE_TO_ACK_IDS.toString(), buffer.array());
             }
-            producer.send(message.getAddress(), message);
+            producer.send(message.getAddressSimpleString().toString(), message);
          }
          session.end(xid, XAResource.TMSUCCESS);
          session.prepare(xid);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index bcc6df1..a130437 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -31,12 +31,14 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.postoffice.QueueBinding;
@@ -48,7 +50,6 @@ import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
@@ -205,7 +206,6 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
 
       this.creationTime = System.currentTimeMillis();
 
-
       if (browseOnly) {
          browserDeliverer = new BrowserDeliverer(messageQueue.browserIterator());
       } else {
@@ -341,7 +341,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
             }
             return HandleStatus.BUSY;
          }
-         final ServerMessage message = ref.getMessage();
+         final Message message = ref.getMessage();
 
          if (filter != null && !filter.match(message)) {
             if (logger.isTraceEnabled()) {
@@ -400,7 +400,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
    @Override
    public void proceedDeliver(MessageReference reference) throws Exception {
       try {
-         ServerMessage message = reference.getMessage();
+         Message message = reference.getMessage();
 
          if (message.isLargeMessage() && supportLargeMessage) {
             if (largeMessageDeliverer == null) {
@@ -508,16 +508,13 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
     */
    @Override
    public void forceDelivery(final long sequence) {
-      forceDelivery(sequence, new Runnable() {
-         @Override
-         public void run() {
-            ServerMessage forcedDeliveryMessage = new ServerMessageImpl(storageManager.generateID(), 50);
+      forceDelivery(sequence, () -> {
+         Message forcedDeliveryMessage = new CoreMessage(storageManager.generateID(), 50);
 
-            forcedDeliveryMessage.putLongProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE, sequence);
-            forcedDeliveryMessage.setAddress(messageQueue.getName());
+         forcedDeliveryMessage.putLongProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE, sequence);
+         forcedDeliveryMessage.setAddress(messageQueue.getName());
 
-            callback.sendMessage(null, forcedDeliveryMessage, ServerConsumerImpl.this, 0);
-         }
+         callback.sendMessage(null, forcedDeliveryMessage, ServerConsumerImpl.this, 0);
       });
    }
 
@@ -1018,7 +1015,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
     * @param ref
     * @param message
     */
-   private void deliverStandardMessage(final MessageReference ref, final ServerMessage message) {
+   private void deliverStandardMessage(final MessageReference ref, final Message message) {
       int packetSize = callback.sendMessage(ref, message, ServerConsumerImpl.this, ref.getDeliveryCount());
 
       if (availableCredits != null) {
@@ -1070,7 +1067,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
        */
       private long positionPendingLargeMessage;
 
-      private BodyEncoder context;
+      private LargeBodyEncoder context;
 
       private LargeMessageDeliverer(final LargeServerMessage message, final MessageReference ref) throws Exception {
          largeMessage = message;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java
deleted file mode 100644
index 39e77ca..0000000
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.server.impl;
-
-import java.io.InputStream;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
-import org.apache.activemq.artemis.core.paging.PagingStore;
-import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.utils.DataConstants;
-import org.apache.activemq.artemis.utils.MemorySize;
-import org.apache.activemq.artemis.utils.TypedProperties;
-
-public class ServerMessageImpl extends MessageImpl implements ServerMessage {
-
-   private final AtomicInteger durableRefCount = new AtomicInteger();
-
-   private final AtomicInteger refCount = new AtomicInteger();
-
-   private PagingStore pagingStore;
-
-   private static final int memoryOffset;
-
-   private boolean persisted = false;
-
-   static {
-      // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
-      // Note, it is only an estimate, it's not possible to be entirely sure with Java
-      // This figure is calculated using the test utilities in org.apache.activemq.tests.unit.util.sizeof
-      // The value is somewhat higher on 64 bit architectures, probably due to different alignment
-
-      if (MemorySize.is64bitArch()) {
-         memoryOffset = 352;
-      } else {
-         memoryOffset = 232;
-      }
-   }
-
-   /*
-    * Constructor for when reading from network
-    */
-   public ServerMessageImpl() {
-   }
-
-   /*
-    * Construct a MessageImpl from storage, or notification, or before routing
-    */
-   public ServerMessageImpl(final long messageID, final int initialMessageBufferSize) {
-      super(initialMessageBufferSize);
-
-      this.messageID = messageID;
-   }
-
-   /*
-    * Copy constructor
-    */
-   protected ServerMessageImpl(final ServerMessageImpl other) {
-      super(other);
-   }
-
-   /*
-    * Copy constructor
-    */
-   protected ServerMessageImpl(final ServerMessageImpl other, TypedProperties properties) {
-      super(other, properties);
-   }
-
-   @Override
-   public boolean isServerMessage() {
-      return true;
-   }
-
-   @Override
-   public ServerMessageImpl setMessageID(final long id) {
-      messageID = id;
-      return this;
-   }
-
-   @Override
-   public MessageReference createReference(final Queue queue) {
-      MessageReference ref = new MessageReferenceImpl(this, queue);
-
-      return ref;
-   }
-
-   @Override
-   public boolean hasInternalProperties() {
-      return properties.hasInternalProperties();
-   }
-
-   @Override
-   public int incrementRefCount() throws Exception {
-      int count = refCount.incrementAndGet();
-
-      if (pagingStore != null) {
-         if (count == 1) {
-            pagingStore.addSize(getMemoryEstimate() + MessageReferenceImpl.getMemoryEstimate());
-         } else {
-            pagingStore.addSize(MessageReferenceImpl.getMemoryEstimate());
-         }
-      }
-
-      return count;
-   }
-
-   @Override
-   public int decrementRefCount() throws Exception {
-      int count = refCount.decrementAndGet();
-
-      if (count < 0) {
-         // this could happen on paged messages since they are not routed and incrementRefCount is never called
-         return count;
-      }
-
-      if (pagingStore != null) {
-         if (count == 0) {
-            pagingStore.addSize(-getMemoryEstimate() - MessageReferenceImpl.getMemoryEstimate());
-
-            if (buffer != null) {
-               // release the buffer now
-               buffer.byteBuf().release();
-            }
-         } else {
-            pagingStore.addSize(-MessageReferenceImpl.getMemoryEstimate());
-         }
-      }
-
-      return count;
-   }
-
-   @Override
-   public int incrementDurableRefCount() {
-      return durableRefCount.incrementAndGet();
-   }
-
-   @Override
-   public int decrementDurableRefCount() {
-      return durableRefCount.decrementAndGet();
-   }
-
-   @Override
-   public int getRefCount() {
-      return refCount.get();
-   }
-
-   @Override
-   public boolean isLargeMessage() {
-      return false;
-   }
-
-   private volatile int memoryEstimate = -1;
-
-   @Override
-   public int getMemoryEstimate() {
-      if (memoryEstimate == -1) {
-         memoryEstimate = ServerMessageImpl.memoryOffset + buffer.capacity() + properties.getMemoryOffset();
-      }
-
-      return memoryEstimate;
-   }
-
-   @Override
-   public ServerMessage copy(final long newID) {
-      ServerMessage m = new ServerMessageImpl(this);
-
-      m.setMessageID(newID);
-
-      return m;
-   }
-
-   @Override
-   public ServerMessage copy() {
-      // This is a simple copy, used only to avoid changing original properties
-      return new ServerMessageImpl(this);
-   }
-
-   public ServerMessage makeCopyForExpiryOrDLA(final long newID,
-                                               MessageReference originalReference,
-                                               final boolean expiry) throws Exception {
-      return makeCopyForExpiryOrDLA(newID, originalReference, expiry, true);
-   }
-
-   @Override
-   public ServerMessage makeCopyForExpiryOrDLA(final long newID,
-                                               MessageReference originalReference,
-                                               final boolean expiry,
-                                               final boolean copyOriginalHeaders) throws Exception {
-      /*
-       We copy the message and send that to the dla/expiry queue - this is
-       because otherwise we may end up with a ref with the same message id in the
-       queue more than once which would barf - this might happen if the same message had been
-       expire from multiple subscriptions of a topic for example
-       We set headers that hold the original message address, expiry time
-       and original message id
-      */
-
-      ServerMessage copy = copy(newID);
-
-      if (copyOriginalHeaders) {
-         copy.setOriginalHeaders(this, originalReference, expiry);
-      }
-
-      return copy;
-   }
-
-   @Override
-   public void setOriginalHeaders(final ServerMessage other,
-                                  final MessageReference originalReference,
-                                  final boolean expiry) {
-      SimpleString originalQueue = other.getSimpleStringProperty(Message.HDR_ORIGINAL_QUEUE);
-
-      if (originalQueue != null) {
-         putStringProperty(Message.HDR_ORIGINAL_QUEUE, originalQueue);
-      } else if (originalReference != null) {
-         putStringProperty(Message.HDR_ORIGINAL_QUEUE, originalReference.getQueue().getName());
-      }
-
-      if (other.containsProperty(Message.HDR_ORIG_MESSAGE_ID)) {
-         putStringProperty(Message.HDR_ORIGINAL_ADDRESS, other.getSimpleStringProperty(Message.HDR_ORIGINAL_ADDRESS));
-
-         putLongProperty(Message.HDR_ORIG_MESSAGE_ID, other.getLongProperty(Message.HDR_ORIG_MESSAGE_ID));
-      } else {
-         putStringProperty(Message.HDR_ORIGINAL_ADDRESS, other.getAddress());
-
-         putLongProperty(Message.HDR_ORIG_MESSAGE_ID, other.getMessageID());
-      }
-
-      // reset expiry
-      setExpiration(0);
-
-      if (expiry) {
-         long actualExpiryTime = System.currentTimeMillis();
-
-         putLongProperty(Message.HDR_ACTUAL_EXPIRY_TIME, actualExpiryTime);
-      }
-
-      bufferValid = false;
-   }
-
-   @Override
-   public void setPagingStore(final PagingStore pagingStore) {
-      this.pagingStore = pagingStore;
-
-      // On the server side, we reset the address to point to the instance of address in the paging store
-      // Otherwise each message would have its own copy of the address String which would take up more memory
-      address = pagingStore.getAddress();
-   }
-
-   @Override
-   public synchronized void forceAddress(final SimpleString address) {
-      this.address = address;
-      bufferValid = false;
-   }
-
-   @Override
-   public PagingStore getPagingStore() {
-      return pagingStore;
-   }
-
-   @Override
-   public boolean storeIsPaging() {
-      if (pagingStore != null) {
-         return pagingStore.isPaging();
-      } else {
-         return false;
-      }
-   }
-
-   @Override
-   public String toString() {
-      try {
-         return "ServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBufferDuplicate().capacity() +
-            ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) +
-            ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this);
-      } catch (Throwable e) {
-         return "ServerMessage[messageID=" + messageID + "]";
-      }
-   }
-
-   private static String toDate(long timestamp) {
-      if (timestamp == 0) {
-         return "0";
-      } else {
-         return new java.util.Date(timestamp).toString();
-      }
-
-   }
-
-   @Override
-   public InputStream getBodyInputStream() {
-      return null;
-   }
-
-   // Encoding stuff
-
-   @Override
-   public void encodeMessageIDToBuffer() {
-      // We first set the message id - this needs to be set on the buffer since this buffer will be re-used
-
-      buffer.setLong(buffer.getInt(MessageImpl.BUFFER_HEADER_SPACE) + DataConstants.SIZE_INT, messageID);
-   }
-
-   @Override
-   public byte[] getDuplicateIDBytes() {
-      Object duplicateID = getDuplicateProperty();
-
-      if (duplicateID == null) {
-         return null;
-      } else {
-         if (duplicateID instanceof SimpleString) {
-            return ((SimpleString) duplicateID).getData();
-         } else {
-            return (byte[]) duplicateID;
-         }
-      }
-   }
-
-   @Override
-   public Object getDuplicateProperty() {
-      return getObjectProperty(Message.HDR_DUPLICATE_DETECTION_ID);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index 52ecda1..27fbdcb 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -31,6 +31,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.artemis.Closeable;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
 import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
@@ -46,7 +47,6 @@ import org.apache.activemq.artemis.core.exception.ActiveMQXAException;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
 import org.apache.activemq.artemis.core.io.IOCallback;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
@@ -66,14 +66,13 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.AddressQueryResult;
 import org.apache.activemq.artemis.core.server.BindingQueryResult;
-import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.TempQueueObserver;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
@@ -155,9 +154,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
    private final SimpleString managementAddress;
 
-   // The current currentLargeMessage being processed
-   private volatile LargeServerMessage currentLargeMessage;
-
    protected final RoutingContext routingContext = new RoutingContextImpl(null);
 
    protected final SessionCallback callback;
@@ -187,6 +183,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
    private Map<SimpleString, RoutingType> prefixes;
 
+   private Set<Closeable> closeables;
+
    public ServerSessionImpl(final String name,
                             final String username,
                             final String password,
@@ -273,6 +271,14 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
    }
 
    @Override
+   public void addCloseable(Closeable closeable) {
+      if (closeables == null) {
+         closeables = new HashSet<>();
+      }
+      this.closeables.add(closeable);
+   }
+
+   @Override
    public void disableSecurity() {
       this.securityEnabled = false;
    }
@@ -376,11 +382,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
       consumers.clear();
 
-      if (currentLargeMessage != null) {
-         try {
-            currentLargeMessage.deleteFile();
-         } catch (Throwable error) {
-            ActiveMQServerLogger.LOGGER.errorDeletingLargeMessageFile(error);
+      if (closeables != null) {
+         for (Closeable closeable : closeables) {
+            closeable.close(failed);
          }
       }
 
@@ -1272,30 +1276,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
    }
 
    @Override
-   public void sendLarge(final MessageInternal message) throws Exception {
-      // need to create the LargeMessage before continue
-      long id = storageManager.generateID();
-
-      LargeServerMessage largeMsg = storageManager.createLargeMessage(id, message);
-
-      if (logger.isTraceEnabled()) {
-         logger.trace("sendLarge::" + largeMsg);
-      }
-
-      if (currentLargeMessage != null) {
-         ActiveMQServerLogger.LOGGER.replacingIncompleteLargeMessage(currentLargeMessage.getMessageID());
-      }
-
-      currentLargeMessage = largeMsg;
-   }
-
-   @Override
-   public RoutingStatus send(final ServerMessage message, final boolean direct) throws Exception {
+   public RoutingStatus send(final Message message, final boolean direct) throws Exception {
       return send(message, direct, false);
    }
 
    @Override
-   public RoutingStatus send(final ServerMessage message,
+   public RoutingStatus send(final Message message,
                              final boolean direct,
                              boolean noAutoCreateQueue) throws Exception {
       return send(getCurrentTransaction(), message, direct, noAutoCreateQueue);
@@ -1303,7 +1289,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
    @Override
    public RoutingStatus send(Transaction tx,
-                             final ServerMessage message,
+                             final Message message,
                              final boolean direct,
                              boolean noAutoCreateQueue) throws Exception {
 
@@ -1319,19 +1305,18 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       //case the id header already generated.
       if (!message.isLargeMessage()) {
          long id = storageManager.generateID();
-
+         // This will re-encode the message
          message.setMessageID(id);
-         message.encodeMessageIDToBuffer();
       }
 
       if (server.getConfiguration().isPopulateValidatedUser() && validatedUser != null) {
          message.putStringProperty(Message.HDR_VALIDATED_USER, SimpleString.toSimpleString(validatedUser));
       }
 
-      SimpleString address = removePrefix(message.getAddress());
+      SimpleString address = removePrefix(message.getAddressSimpleString());
 
       // In case the prefix was removed, we also need to update the message
-      if (address != message.getAddress()) {
+      if (address != message.getAddressSimpleString()) {
          message.setAddress(address);
       }
 
@@ -1340,14 +1325,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       }
 
       if (address == null) {
-         if (message.isDurable()) {
-            // We need to force a re-encode when the message gets persisted or when it gets reloaded
-            // it will have no address
-            message.setAddress(defaultAddress);
-         } else {
-            // We don't want to force a re-encode when the message gets sent to the consumer
-            message.setAddressTransient(defaultAddress);
-         }
+         // We don't want to force a re-encode when the message gets sent to the consumer
+         message.setAddress(defaultAddress);
       }
 
       if (logger.isTraceEnabled()) {
@@ -1359,7 +1338,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
          throw ActiveMQMessageBundle.BUNDLE.noAddress();
       }
 
-      if (message.getAddress().equals(managementAddress)) {
+      if (message.getAddressSimpleString().equals(managementAddress)) {
          // It's a management message
 
          handleManagementMessage(tx, message, direct);
@@ -1369,32 +1348,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       return result;
    }
 
-   @Override
-   public void sendContinuations(final int packetSize,
-                                 final long messageBodySize,
-                                 final byte[] body,
-                                 final boolean continues) throws Exception {
-      if (currentLargeMessage == null) {
-         throw ActiveMQMessageBundle.BUNDLE.largeMessageNotInitialised();
-      }
-
-      // Immediately release the credits for the continuations- these don't contribute to the in-memory size
-      // of the message
-
-      currentLargeMessage.addBytes(body);
-
-      if (!continues) {
-         currentLargeMessage.releaseResources();
-
-         if (messageBodySize >= 0) {
-            currentLargeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, messageBodySize);
-         }
-
-         doSend(tx, currentLargeMessage, false, false);
-
-         currentLargeMessage = null;
-      }
-   }
 
    @Override
    public void requestProducerCredits(SimpleString address, final int credits) throws Exception {
@@ -1566,10 +1519,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       connectionFailed(me, failedOver);
    }
 
-   public void clearLargeMessage() {
-      currentLargeMessage = null;
-   }
-
    private void installJMSHooks() {
    }
 
@@ -1588,10 +1537,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
    }
 
    private RoutingStatus handleManagementMessage(final Transaction tx,
-                                                 final ServerMessage message,
+                                                 final Message message,
                                                  final boolean direct) throws Exception {
       try {
-         securityCheck(removePrefix(message.getAddress()), CheckType.MANAGE, this);
+         securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this);
       } catch (ActiveMQException e) {
          if (!autoCommitSends) {
             tx.markAsRollbackOnly(e);
@@ -1599,7 +1548,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
          throw e;
       }
 
-      ServerMessage reply = managementService.handleMessage(message);
+      Message reply = managementService.handleMessage(message);
 
       SimpleString replyTo = message.getSimpleStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME);
 
@@ -1669,8 +1618,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       theTx.rollback();
    }
 
+   @Override
    public RoutingStatus doSend(final Transaction tx,
-                               final ServerMessage msg,
+                               final Message msg,
                                final boolean direct,
                                final boolean noAutoCreateQueue) throws Exception {
       RoutingStatus result = RoutingStatus.OK;
@@ -1683,7 +1633,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
       if (msg.containsProperty(Message.HDR_ROUTING_TYPE)) {
          routingType = RoutingType.getType(msg.getByteProperty(Message.HDR_ROUTING_TYPE));
       }
-      Pair<SimpleString, RoutingType> art = getAddressAndRoutingType(msg.getAddress(), routingType);
+      Pair<SimpleString, RoutingType> art = getAddressAndRoutingType(msg.getAddressSimpleString(), routingType);
 
       // Consumer
       // check the user has write access to this address.
@@ -1707,12 +1657,14 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
          result = postOffice.route(msg, routingContext, direct);
 
-         Pair<UUID, AtomicLong> value = targetAddressInfos.get(msg.getAddress());
+         Pair<UUID, AtomicLong> value = targetAddressInfos.get(msg.getAddressSimpleString());
 
          if (value == null) {
-            targetAddressInfos.put(msg.getAddress(), new Pair<>(msg.getUserID(), new AtomicLong(1)));
+            // TODO-now: userID
+            targetAddressInfos.put(msg.getAddressSimpleString(), new Pair<>((UUID)msg.getUserID(), new AtomicLong(1)));
          } else {
-            value.setA(msg.getUserID());
+            // TODO-now: userID
+            value.setA((UUID)msg.getUserID());
             value.getB().incrementAndGet();
          }
       } finally {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
index 0222928..84ab636 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementService.java
@@ -21,6 +21,7 @@ import java.util.Set;
 import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
@@ -42,7 +43,7 @@ import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
@@ -128,5 +129,5 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
 
    Object[] getResources(Class<?> resourceType);
 
-   ServerMessage handleMessage(ServerMessage message) throws Exception;
+   Message handleMessage(Message message) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 55f2aea..002b2c7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -34,6 +34,8 @@ import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
 import org.apache.activemq.artemis.api.core.JsonUtil;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.management.AcceptorControl;
@@ -56,6 +58,7 @@ import org.apache.activemq.artemis.core.management.impl.BroadcastGroupControlImp
 import org.apache.activemq.artemis.core.management.impl.ClusterConnectionControlImpl;
 import org.apache.activemq.artemis.core.management.impl.DivertControlImpl;
 import org.apache.activemq.artemis.core.management.impl.QueueControlImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
 import org.apache.activemq.artemis.core.messagecounter.MessageCounterManager;
 import org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterManagerImpl;
@@ -71,13 +74,10 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueFactory;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.server.management.NotificationListener;
@@ -365,9 +365,9 @@ public class ManagementServiceImpl implements ManagementService {
    }
 
    @Override
-   public ServerMessage handleMessage(final ServerMessage message) throws Exception {
+   public Message handleMessage(final Message message) throws Exception {
       // a reply message is sent with the result stored in the message body.
-      ServerMessage reply = new ServerMessageImpl(storageManager.generateID(), 512);
+      Message reply = new CoreMessage(storageManager.generateID(), 512);
 
       String resourceName = message.getStringProperty(ManagementHelper.HDR_RESOURCE_NAME);
       if (logger.isDebugEnabled()) {
@@ -631,7 +631,7 @@ public class ManagementServiceImpl implements ManagementService {
 
                long messageID = storageManager.generateID();
 
-               ServerMessage notificationMessage = new ServerMessageImpl(messageID, 512);
+               Message notificationMessage = new CoreMessage(messageID, 512);
 
                // Notification messages are always durable so the user can choose whether to add a durable queue to
                // consume them in

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
index efe4cf9..e686a2c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
@@ -26,8 +26,9 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.JsonUtil;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
 import org.apache.activemq.artemis.utils.JsonLoader;
 
@@ -97,7 +98,7 @@ public abstract class TransactionDetail {
 
             msgJson.add(KEY_MSG_OP_TYPE, opType);
 
-            ServerMessage msg = ref.getMessage().copy();
+            Message msg = ref.getMessage().copy();
 
             msgJson.add(KEY_MSG_TYPE, decodeMessageType(msg));
             JsonUtil.addToObject(KEY_MSG_PROPERTIES, decodeMessageProperties(msg), msgJson);
@@ -108,7 +109,7 @@ public abstract class TransactionDetail {
       return detailJson.build();
    }
 
-   public abstract String decodeMessageType(ServerMessage msg);
+   public abstract String decodeMessageType(Message msg);
 
-   public abstract Map<String, Object> decodeMessageProperties(ServerMessage msg);
+   public abstract Map<String, Object> decodeMessageProperties(Message msg);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java
index 4730596..c885341 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/CoreTransactionDetail.java
@@ -20,7 +20,7 @@ import javax.transaction.xa.Xid;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.TransactionDetail;
 
@@ -31,7 +31,7 @@ public class CoreTransactionDetail extends TransactionDetail {
    }
 
    @Override
-   public String decodeMessageType(ServerMessage msg) {
+   public String decodeMessageType(Message msg) {
       int type = msg.getType();
       switch (type) {
          case Message.DEFAULT_TYPE: // 0
@@ -52,7 +52,7 @@ public class CoreTransactionDetail extends TransactionDetail {
    }
 
    @Override
-   public Map<String, Object> decodeMessageProperties(ServerMessage msg) {
+   public Map<String, Object> decodeMessageProperties(Message msg) {
       return msg.toMap();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessageConverter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessageConverter.java
index a342e13..3a5e2bf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessageConverter.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessageConverter.java
@@ -16,12 +16,11 @@
  */
 package org.apache.activemq.artemis.spi.core.protocol;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.api.core.Message;
 
-// TODO: use this interface properly on OpenWire
 public interface MessageConverter {
 
-   ServerMessage inbound(Object messageInbound) throws Exception;
+   Message inbound(Object messageInbound) throws Exception;
 
-   Object outbound(ServerMessage messageOutbound, int deliveryCount) throws Exception;
+   Object outbound(Message messageOutbound, int deliveryCount) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java
new file mode 100644
index 0000000..14891f5
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.spi.core.protocol;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.jboss.logging.Logger;
+
+public class MessagePersister implements Persister<Message> {
+
+   private static final Logger logger = Logger.getLogger(MessagePersister.class);
+
+   private static final MessagePersister theInstance = new MessagePersister();
+
+   /** This will be used for reading messages */
+   private static Map<Byte, Persister<Message>> protocols = new ConcurrentHashMap<>();
+
+
+   public static void registerProtocol(ProtocolManagerFactory manager) {
+      Persister<Message> messagePersister = manager.getPersister();
+      if (messagePersister == null) {
+         logger.warn("Cannot find persister for " + manager);
+      } else {
+         registerPersister(manager.getStoreID(), manager.getPersister());
+      }
+   }
+
+   public static void clearPersisters() {
+      protocols.clear();
+   }
+
+   public static void registerPersister(byte recordType, Persister<Message> persister) {
+      protocols.put(recordType, persister);
+   }
+
+   public static MessagePersister getInstance() {
+      return theInstance;
+   }
+
+
+   protected MessagePersister() {
+   }
+
+   protected byte getID() {
+      return (byte)0;
+   }
+
+   @Override
+   public int getEncodeSize(Message record) {
+      return 0;
+   }
+
+
+   /** Sub classes must add the first short as the protocol-id */
+   @Override
+   public void encode(ActiveMQBuffer buffer, Message record) {
+      buffer.writeByte(getID());
+   }
+
+   @Override
+   public Message decode(ActiveMQBuffer buffer, Message record) {
+      byte protocol = buffer.readByte();
+      Persister<Message> persister = protocols.get(protocol);
+      if (persister == null) {
+         throw new NullPointerException("couldn't find factory for type=" + protocol);
+      }
+      return persister.decode(buffer, record);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java
index 890fbfe..c2b7334 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManager.java
@@ -28,6 +28,8 @@ import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 
+/**
+ * Info: ProtocolManager is loaded by {@link org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl#loadProtocolManagerFactories(Iterable)} */
 public interface ProtocolManager<P extends BaseInterceptor> {
 
    ProtocolManagerFactory<P> getFactory();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
index d3b1b2e..9574540 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
@@ -20,10 +20,25 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 
 public interface ProtocolManagerFactory<P extends BaseInterceptor> {
 
+   /** This is to be used to store the protocol-id on Messages.
+    *  Messages are stored on their bare format.
+    *  The protocol manager will be responsible to code or decode messages.
+    *  The caveat here is that the first short-sized bytes need to be this constant. */
+   default byte getStoreID() {
+      return (byte)0;
+   }
+
+   default Persister<Message> getPersister() {
+      return null;
+   }
+
+
    /**
     * When you create the ProtocolManager, you should filter out any interceptors that won't belong
     * to this Protocol.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java
index ee236c7..799e8b0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/SessionCallback.java
@@ -16,10 +16,10 @@
  */
 package org.apache.activemq.artemis.spi.core.protocol;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 
 public interface SessionCallback {
@@ -55,10 +55,10 @@ public interface SessionCallback {
    //       and I wanted to avoid re-fetching paged data in case of GCs on this specific case.
    //
    //       Future developments may change this, but beware why I have chosen to keep the parameter separated here
-   int sendMessage(MessageReference ref, ServerMessage message, ServerConsumer consumerID, int deliveryCount);
+   int sendMessage(MessageReference ref, Message message, ServerConsumer consumerID, int deliveryCount);
 
    int sendLargeMessage(MessageReference reference,
-                        ServerMessage message,
+                        Message message,
                         ServerConsumer consumerID,
                         long bodySize,
                         int deliveryCount);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 0c33a35..6fdef44 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -682,22 +682,6 @@
             </xsd:annotation>
          </xsd:element>
 
-         <xsd:element name="perf-blast-pages" type="xsd:int" default="-1" maxOccurs="1" minOccurs="0">
-            <xsd:annotation>
-               <xsd:documentation>
-                  XXX Only meant to be used by project developers
-               </xsd:documentation>
-            </xsd:annotation>
-         </xsd:element>
-
-         <xsd:element name="run-sync-speed-test" type="xsd:boolean" default="false" maxOccurs="1" minOccurs="0">
-            <xsd:annotation>
-               <xsd:documentation>
-                  XXX Only meant to be used by project developers
-               </xsd:documentation>
-            </xsd:annotation>
-         </xsd:element>
-
          <xsd:element name="server-dump-interval" type="xsd:long" default="-1" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
index f374979..5e9a95a 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
@@ -77,7 +77,6 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
       Assert.assertEquals(ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, conf.getJournalBufferSize_AIO());
       Assert.assertEquals(ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_NIO, conf.getJournalBufferSize_NIO());
       Assert.assertEquals(ActiveMQDefaultConfiguration.isDefaultJournalLogWriteRate(), conf.isLogJournalWriteRate());
-      Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalPerfBlastPages(), conf.getJournalPerfBlastPages());
       Assert.assertEquals(ActiveMQDefaultConfiguration.isDefaultMessageCounterEnabled(), conf.isMessageCounterEnabled());
       Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMessageCounterMaxDayHistory(), conf.getMessageCounterMaxDayHistory());
       Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMessageCounterSamplePeriod(), conf.getMessageCounterSamplePeriod());
@@ -232,10 +231,6 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
          conf.setLogJournalWriteRate(b);
          Assert.assertEquals(b, conf.isLogJournalWriteRate());
 
-         i = RandomUtil.randomInt();
-         conf.setJournalPerfBlastPages(i);
-         Assert.assertEquals(i, conf.getJournalPerfBlastPages());
-
          l = RandomUtil.randomLong();
          conf.setServerDumpInterval(l);
          Assert.assertEquals(l, conf.getServerDumpInterval());
@@ -434,10 +429,6 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
       conf.setLogJournalWriteRate(b);
       Assert.assertEquals(b, conf.isLogJournalWriteRate());
 
-      i = RandomUtil.randomInt();
-      conf.setJournalPerfBlastPages(i);
-      Assert.assertEquals(i, conf.getJournalPerfBlastPages());
-
       l = RandomUtil.randomLong();
       conf.setServerDumpInterval(l);
       Assert.assertEquals(l, conf.getServerDumpInterval());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java
index d73accd..1eb749b 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/filter/impl/FilterTest.java
@@ -18,10 +18,10 @@ package org.apache.activemq.artemis.core.filter.impl;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQInvalidFilterExpressionException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.tests.util.SilentTestCase;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.junit.Assert;
@@ -35,13 +35,13 @@ public class FilterTest extends SilentTestCase {
 
    private Filter filter;
 
-   private ServerMessage message;
+   private Message message;
 
    @Override
    @Before
    public void setUp() throws Exception {
       super.setUp();
-      message = new ServerMessageImpl(1, 1000);
+      message = new CoreMessage().initBuffer(1024).setMessageID(1);
    }
 
    @Test
@@ -59,7 +59,7 @@ public class FilterTest extends SilentTestCase {
 
       message.putStringProperty(new SimpleString("color"), new SimpleString("RED"));
       Assert.assertTrue(filter.match(message));
-      message = new ServerMessageImpl();
+      message = new CoreMessage();
       Assert.assertFalse(filter.match(message));
    }
 
@@ -94,7 +94,7 @@ public class FilterTest extends SilentTestCase {
 
       filter = FilterImpl.createFilter(new SimpleString("AMQDurable='NON_DURABLE'"));
 
-      message = new ServerMessageImpl();
+      message = new CoreMessage();
       message.setDurable(true);
 
       Assert.assertFalse(filter.match(message));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
index 0e9a3f2..92204ce 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
@@ -44,7 +45,7 @@ import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
@@ -329,7 +330,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
       }
 
       @Override
-      public ServerMessage handleMessage(ServerMessage message) throws Exception {
+      public Message handleMessage(Message message) throws Exception {
          return null;
       }
 


[03/29] activemq-artemis git commit: fixing AMQP

Posted by cl...@apache.org.
fixing AMQP


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/99ee2cce
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/99ee2cce
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/99ee2cce

Branch: refs/heads/artemis-1009
Commit: 99ee2cce58a2e8ab3f975469b34ffe4befce208e
Parents: ea358aa
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 16:19:51 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/protocol/amqp/broker/AMQPMessage.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99ee2cce/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index 7fabefd..d39bf9d 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -203,6 +203,10 @@ public class AMQPMessage extends RefCountMessage {
             headerEnd = buffer.position();
             _header = (Header) section;
 
+            if (_header.getTtl() != null) {
+               this.expiration = System.currentTimeMillis() + _header.getTtl().intValue();
+            }
+
             if (!readApplicationProperties) {
                return;
             }
@@ -243,10 +247,6 @@ public class AMQPMessage extends RefCountMessage {
          if (section instanceof Properties) {
             _properties = (Properties) section;
 
-            if (_header.getTtl() != null) {
-               this.expiration = System.currentTimeMillis() + _header.getTtl().intValue();
-            }
-
             if (buffer.hasRemaining()) {
                section = (Section) decoder.readObject();
             } else {


[25/29] activemq-artemis git commit: fixing NPE

Posted by cl...@apache.org.
fixing NPE


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c58a3d0a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c58a3d0a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c58a3d0a

Branch: refs/heads/artemis-1009
Commit: c58a3d0a9bb88414f979d6dd552ee164bd82a5d6
Parents: a333045
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 11:58:47 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c58a3d0a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
index 925181b..a6fd02b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
@@ -62,6 +62,7 @@ public class ReplicationAddTXMessage extends PacketImpl {
       this.id = id;
       this.recordType = recordType;
       this.encodingData = encodingData;
+      this.persister = persister;
    }
 
    // Public --------------------------------------------------------


[20/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/MessageBody.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/MessageBody.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/MessageBody.java
new file mode 100644
index 0000000..f7821b9
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/encode/MessageBody.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.api.core.encode;
+
+import java.nio.ByteBuffer;
+
+public interface MessageBody {
+   Object getBody();
+
+   ByteBuffer getBodyArray();
+
+   BodyType getType();
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ResetLimitWrappedActiveMQBuffer.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ResetLimitWrappedActiveMQBuffer.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ResetLimitWrappedActiveMQBuffer.java
index 900305f..b5d5474 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ResetLimitWrappedActiveMQBuffer.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ResetLimitWrappedActiveMQBuffer.java
@@ -20,18 +20,18 @@ import java.nio.ByteBuffer;
 
 import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 
 /**
  * A ResetLimitWrappedActiveMQBuffer
- * TODO: Move this to commons
  */
 public final class ResetLimitWrappedActiveMQBuffer extends ChannelBufferWrapper {
 
    private final int limit;
 
-   private MessageInternal message;
+   private Message message;
 
    /**
     * We need to turn of notifications of body changes on reset on the server side when dealing with AMQP conversions,
@@ -39,17 +39,17 @@ public final class ResetLimitWrappedActiveMQBuffer extends ChannelBufferWrapper
     *
     * @param message
     */
-   public void setMessage(MessageInternal message) {
+   public void setMessage(Message message) {
       this.message = message;
    }
 
-   public ResetLimitWrappedActiveMQBuffer(final int limit, final ActiveMQBuffer buffer, final MessageInternal message) {
+   public ResetLimitWrappedActiveMQBuffer(final int limit, final ActiveMQBuffer buffer, final Message message) {
       // a wrapped inside a wrapper will increase the stack size.
       // we fixed this here due to some profiling testing
       this(limit, unwrap(buffer.byteBuf()).duplicate(), message);
    }
 
-   public ResetLimitWrappedActiveMQBuffer(final int limit, final ByteBuf buffer, final MessageInternal message) {
+   public ResetLimitWrappedActiveMQBuffer(final int limit, final ByteBuf buffer, final Message message) {
       // a wrapped inside a wrapper will increase the stack size.
       // we fixed this here due to some profiling testing
       super(buffer);
@@ -67,7 +67,7 @@ public final class ResetLimitWrappedActiveMQBuffer extends ChannelBufferWrapper
 
    private void changed() {
       if (message != null) {
-         message.bodyChanged();
+         message.messageChanged();
       }
    }
 
@@ -94,8 +94,6 @@ public final class ResetLimitWrappedActiveMQBuffer extends ChannelBufferWrapper
 
    @Override
    public void resetReaderIndex() {
-      changed();
-
       buffer.readerIndex(limit);
    }
 
@@ -256,6 +254,14 @@ public final class ResetLimitWrappedActiveMQBuffer extends ChannelBufferWrapper
       super.writeBytes(src);
    }
 
+
+   @Override
+   public void writeBytes(final ByteBuf src, final int srcIndex, final int length) {
+      changed();
+
+      super.writeBytes(src, srcIndex, length);
+   }
+
    @Override
    public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
       changed();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java
index c3cbceb..cbfaf6f 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientLargeMessageImpl.java
@@ -59,7 +59,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    @Override
    public int getEncodeSize() {
-      if (bodyBuffer != null) {
+      if (writableBuffer != null) {
          return super.getEncodeSize();
       } else {
          return DataConstants.SIZE_INT + DataConstants.SIZE_INT + getHeadersAndPropertiesEncodeSize();
@@ -93,7 +93,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
          throw new RuntimeException(e.getMessage(), e);
       }
 
-      return bodyBuffer;
+      return writableBuffer;
    }
 
    @Override
@@ -108,7 +108,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    @Override
    public void saveToOutputStream(final OutputStream out) throws ActiveMQException {
-      if (bodyBuffer != null) {
+      if (writableBuffer != null) {
          // The body was rebuilt on the client, so we need to behave as a regular message on this case
          super.saveToOutputStream(out);
       } else {
@@ -118,7 +118,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    @Override
    public ClientLargeMessageImpl setOutputStream(final OutputStream out) throws ActiveMQException {
-      if (bodyBuffer != null) {
+      if (writableBuffer != null) {
          super.setOutputStream(out);
       } else {
          largeMessageController.setOutputStream(out);
@@ -129,7 +129,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    @Override
    public boolean waitOutputStreamCompletion(final long timeMilliseconds) throws ActiveMQException {
-      if (bodyBuffer != null) {
+      if (writableBuffer != null) {
          return super.waitOutputStreamCompletion(timeMilliseconds);
       } else {
          return largeMessageController.waitCompletion(timeMilliseconds);
@@ -138,7 +138,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    @Override
    public void discardBody() {
-      if (bodyBuffer != null) {
+      if (writableBuffer != null) {
          super.discardBody();
       } else {
          largeMessageController.discardUnusedPackets();
@@ -146,17 +146,17 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
    }
 
    private void checkBuffer() throws ActiveMQException {
-      if (bodyBuffer == null) {
+      if (writableBuffer == null) {
 
          long bodySize = this.largeMessageSize + BODY_OFFSET;
          if (bodySize > Integer.MAX_VALUE) {
             bodySize = Integer.MAX_VALUE;
          }
-         createBody((int) bodySize);
+         initBuffer((int) bodySize);
 
-         bodyBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer, this);
+         writableBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer.duplicate(), this);
 
-         largeMessageController.saveBuffer(new ActiveMQOutputStream(bodyBuffer));
+         largeMessageController.saveBuffer(new ActiveMQOutputStream(writableBuffer));
       }
    }
 
@@ -178,7 +178,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
 
    public void retrieveExistingData(ClientMessageInternal clMessage) {
       this.messageID = clMessage.getMessageID();
-      this.address = clMessage.getAddress();
+      this.address = clMessage.getAddressSimpleString();
       this.setUserID(clMessage.getUserID());
       this.setFlowControlSize(clMessage.getFlowControlSize());
       this.setDeliveryCount(clMessage.getDeliveryCount());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
index 7bf8eb7..9472b01 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageImpl.java
@@ -28,14 +28,16 @@ import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.reader.MessageUtil;
+import org.apache.activemq.artemis.utils.TypedProperties;
+import org.apache.activemq.artemis.utils.UUID;
 
 /**
  * A ClientMessageImpl
  */
-public class ClientMessageImpl extends MessageImpl implements ClientMessageInternal {
+public class ClientMessageImpl extends CoreMessage implements ClientMessageInternal {
 
    // added this constant here so that the client package have no dependency on JMS
    public static final SimpleString REPLYTO_HEADER_NAME = MessageUtil.REPLYTO_HEADER_NAME;
@@ -57,6 +59,35 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
    public ClientMessageImpl() {
    }
 
+   protected ClientMessageImpl(ClientMessageImpl other) {
+      super(other);
+   }
+
+   @Override
+   public ClientMessageImpl setDurable(boolean durable) {
+      super.setDurable(durable);
+      return this;
+   }
+
+   @Override
+   public ClientMessageImpl setExpiration(long expiration) {
+      super.setExpiration(expiration);
+      return this;
+   }
+
+   @Override
+   public ClientMessageImpl setPriority(byte priority) {
+      super.setPriority(priority);
+      return this;
+   }
+
+   @Override
+   public ClientMessageImpl setUserID(UUID userID) {
+
+      return this;
+   }
+
+
    /*
     * Construct messages before sending
     */
@@ -66,12 +97,18 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
                             final long timestamp,
                             final byte priority,
                             final int initialMessageBufferSize) {
-      super(type, durable, expiration, timestamp, priority, initialMessageBufferSize);
+      this.setType(type).setExpiration(expiration).setTimestamp(timestamp).setDurable(durable).
+           setPriority(priority).initBuffer(initialMessageBufferSize);
    }
 
    @Override
-   public boolean isServerMessage() {
-      return false;
+   public void setAddressTransient(SimpleString address) {
+      this.address = address;
+   }
+
+   @Override
+   public TypedProperties getProperties() {
+      return this.checkProperties();
    }
 
    @Override
@@ -108,6 +145,11 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
       return this;
    }
 
+
+   @Override
+   public void checkCompletion() throws ActiveMQException {
+   }
+
    @Override
    public int getFlowControlSize() {
       if (flowControlSize < 0) {
@@ -141,7 +183,7 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
 
    @Override
    public String toString() {
-      return getClass().getSimpleName() + "[messageID=" + messageID + ", durable=" + durable + ", address=" + getAddress() + ",userID=" + (getUserID() != null ? getUserID() : "null") + ",properties=" + properties.toString() + "]";
+      return getClass().getSimpleName() + "[messageID=" + messageID + ", durable=" + durable + ", address=" + getAddress() + ",userID=" + (getUserID() != null ? getUserID() : "null") + ",properties=" + getProperties().toString() + "]";
    }
 
    @Override
@@ -189,7 +231,7 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
    }
 
    @Override
-   public BodyEncoder getBodyEncoder() throws ActiveMQException {
+   public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
       return new DecodingContext();
    }
 
@@ -307,15 +349,17 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
 
    @Override
    public ClientMessageImpl writeBodyBufferBytes(byte[] bytes) {
-      return (ClientMessageImpl) super.writeBodyBufferBytes(bytes);
+      getBodyBuffer().writeBytes(bytes);
+      return this;
    }
 
    @Override
    public ClientMessageImpl writeBodyBufferString(String string) {
-      return (ClientMessageImpl) super.writeBodyBufferString(string);
+      getBodyBuffer().writeString(string);
+      return this;
    }
 
-   private final class DecodingContext implements BodyEncoder {
+   private final class DecodingContext implements LargeBodyEncoder {
 
       private DecodingContext() {
       }
@@ -347,9 +391,15 @@ public class ClientMessageImpl extends MessageImpl implements ClientMessageInter
       @Override
       public int encode(final ActiveMQBuffer bufferOut, final int size) {
          byte[] bytes = new byte[size];
-         getWholeBuffer().readBytes(bytes);
+         buffer.readBytes(bytes);
          bufferOut.writeBytes(bytes, 0, size);
          return size;
       }
    }
+
+   @Override
+   public Message copy() {
+      return new ClientMessageImpl(this);
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
index 07d4719..878f799 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientMessageInternal.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.core.client.impl;
 
+import java.io.InputStream;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
 import org.apache.activemq.artemis.utils.TypedProperties;
@@ -44,4 +46,7 @@ public interface ClientMessageInternal extends ClientMessage {
    void discardBody();
 
    boolean isCompressed();
+
+   InputStream getBodyInputStream();
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
index 1dfbe72..ce16011 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java
@@ -27,8 +27,8 @@ import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
 import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.spi.core.remoting.SessionContext;
 import org.apache.activemq.artemis.utils.ActiveMQBufferInputStream;
 import org.apache.activemq.artemis.utils.DeflaterReader;
@@ -217,7 +217,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
       session.startCall();
 
       try {
-         MessageInternal msgI = (MessageInternal) msg;
+         Message msgI = msg;
 
          ClientProducerCredits theCredits;
 
@@ -225,8 +225,8 @@ public class ClientProducerImpl implements ClientProducerInternal {
          // a note about the second check on the writerIndexSize,
          // If it's a server's message, it means this is being done through the bridge or some special consumer on the
          // server's on which case we can't' convert the message into large at the servers
-         if (sessionContext.supportsLargeMessage() && (msgI.getBodyInputStream() != null || msgI.isLargeMessage() ||
-            msgI.getBodyBuffer().writerIndex() > minLargeMessageSize && !msgI.isServerMessage())) {
+         if (sessionContext.supportsLargeMessage() && (getBodyInputStream(msgI) != null || msgI.isLargeMessage() ||
+            msgI.getBodyBuffer().writerIndex() > minLargeMessageSize)) {
             isLarge = true;
          } else {
             isLarge = false;
@@ -258,7 +258,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
          session.workDone();
 
          if (isLarge) {
-            largeMessageSend(sendBlocking, msgI, theCredits, handler);
+            largeMessageSend(sendBlocking, (CoreMessage)msgI, theCredits, handler);
          } else {
             sendRegularMessage(sendingAddress, msgI, sendBlocking, theCredits, handler);
          }
@@ -267,8 +267,12 @@ public class ClientProducerImpl implements ClientProducerInternal {
       }
    }
 
+   private InputStream getBodyInputStream(Message msgI) {
+      return ((ClientMessageInternal)msgI).getBodyInputStream();
+   }
+
    private void sendRegularMessage(final SimpleString sendingAddress,
-                                   final MessageInternal msgI,
+                                   final Message msgI,
                                    final boolean sendBlocking,
                                    final ClientProducerCredits theCredits,
                                    final SendAcknowledgementHandler handler) throws ActiveMQException {
@@ -301,7 +305,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
     * @throws ActiveMQException
     */
    private void largeMessageSend(final boolean sendBlocking,
-                                 final MessageInternal msgI,
+                                 final CoreMessage msgI,
                                  final ClientProducerCredits credits,
                                  SendAcknowledgementHandler handler) throws ActiveMQException {
       logger.tracef("largeMessageSend::%s, Blocking=%s", msgI, sendBlocking);
@@ -313,22 +317,22 @@ public class ClientProducerImpl implements ClientProducerInternal {
       }
 
       // msg.getBody() could be Null on LargeServerMessage
-      if (msgI.getBodyInputStream() == null && msgI.getWholeBuffer() != null) {
-         msgI.getWholeBuffer().readerIndex(0);
+      if (getBodyInputStream(msgI) == null && msgI.getBuffer() != null) {
+         msgI.getBuffer().readerIndex(0);
       }
 
       InputStream input;
 
       if (msgI.isServerMessage()) {
          largeMessageSendServer(sendBlocking, msgI, credits, handler);
-      } else if ((input = msgI.getBodyInputStream()) != null) {
+      } else if ((input = getBodyInputStream(msgI)) != null) {
          largeMessageSendStreamed(sendBlocking, msgI, input, credits, handler);
       } else {
          largeMessageSendBuffered(sendBlocking, msgI, credits, handler);
       }
    }
 
-   private void sendInitialLargeMessageHeader(MessageInternal msgI,
+   private void sendInitialLargeMessageHeader(Message msgI,
                                               ClientProducerCredits credits) throws ActiveMQException {
       int creditsUsed = sessionContext.sendInitialChunkOnLargeMessage(msgI);
 
@@ -348,17 +352,14 @@ public class ClientProducerImpl implements ClientProducerInternal {
     * @throws ActiveMQException
     */
    private void largeMessageSendServer(final boolean sendBlocking,
-                                       final MessageInternal msgI,
+                                       final Message msgI,
                                        final ClientProducerCredits credits,
                                        SendAcknowledgementHandler handler) throws ActiveMQException {
       sendInitialLargeMessageHeader(msgI, credits);
 
-      BodyEncoder context = msgI.getBodyEncoder();
+      LargeBodyEncoder context = msgI.getBodyEncoder();
 
       final long bodySize = context.getLargeBodySize();
-
-      final int reconnectID = sessionContext.getReconnectID();
-
       context.open();
       try {
 
@@ -392,7 +393,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
     * @throws ActiveMQException
     */
    private void largeMessageSendBuffered(final boolean sendBlocking,
-                                         final MessageInternal msgI,
+                                         final Message msgI,
                                          final ClientProducerCredits credits,
                                          SendAcknowledgementHandler handler) throws ActiveMQException {
       msgI.getBodyBuffer().readerIndex(0);
@@ -407,7 +408,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
     * @throws ActiveMQException
     */
    private void largeMessageSendStreamed(final boolean sendBlocking,
-                                         final MessageInternal msgI,
+                                         final Message msgI,
                                          final InputStream inputStreamParameter,
                                          final ClientProducerCredits credits,
                                          SendAcknowledgementHandler handler) throws ActiveMQException {
@@ -478,7 +479,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
                msgI.putLongProperty(Message.HDR_LARGE_BODY_SIZE, deflaterReader.getTotalSize());
 
                msgI.getBodyBuffer().writeBytes(buff, 0, pos);
-               sendRegularMessage(msgI.getAddress(), msgI, sendBlocking, credits, handler);
+               sendRegularMessage(msgI.getAddressSimpleString(), msgI, sendBlocking, credits, handler);
                return;
             } else {
                if (!headerSent) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java
index 55f9129..ce652d2 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/CompressedLargeMessageControllerImpl.java
@@ -513,6 +513,12 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
    }
 
    @Override
+   public void writeBytes(ByteBuf src, int srcIndex, int length) {
+      throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
+   }
+
+
+   @Override
    public ByteBuffer toByteBuffer() {
       throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
index 951aea2..0bb5690 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/LargeMessageControllerImpl.java
@@ -863,6 +863,21 @@ public class LargeMessageControllerImpl implements LargeMessageController {
       throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
    }
 
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the current {@code writerIndex} until the source buffer's position
+    * reaches its limit, and increases the {@code writerIndex} by the
+    * number of the transferred bytes.
+    *
+    * @param src The source buffer
+    * @throws IndexOutOfBoundsException if {@code src.remaining()} is greater than
+    *                                   {@code this.writableBytes}
+    */
+   @Override
+   public void writeBytes(ByteBuf src, int srcIndex, int length) {
+      throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
+   }
+
    public int writeBytes(final InputStream in, final int length) throws IOException {
       throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/BodyEncoder.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/BodyEncoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/BodyEncoder.java
deleted file mode 100644
index baafaac..0000000
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/BodyEncoder.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.message;
-
-import java.nio.ByteBuffer;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQException;
-
-/**
- * Class used to encode message body into buffers.
- * <br>
- * Used to send large streams over the wire
- */
-public interface BodyEncoder {
-
-   /**
-    * This method must not be called directly by ActiveMQ Artemis clients.
-    */
-   void open() throws ActiveMQException;
-
-   /**
-    * This method must not be called directly by ActiveMQ Artemis clients.
-    */
-   void close() throws ActiveMQException;
-
-   /**
-    * This method must not be called directly by ActiveMQ Artemis clients.
-    */
-   int encode(ByteBuffer bufferRead) throws ActiveMQException;
-
-   /**
-    * This method must not be called directly by ActiveMQ Artemis clients.
-    */
-   int encode(ActiveMQBuffer bufferOut, int size) throws ActiveMQException;
-
-   /**
-    * This method must not be called directly by ActiveMQ Artemis clients.
-    */
-   long getLargeBodySize();
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
new file mode 100644
index 0000000..8b96282
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.core.message;
+
+import java.nio.ByteBuffer;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+
+/**
+ * Class used to encode message body into buffers.
+ * <br>
+ * Used to send large streams over the wire
+ */
+public interface LargeBodyEncoder {
+
+   /**
+    * This method must not be called directly by ActiveMQ Artemis clients.
+    */
+   void open() throws ActiveMQException;
+
+   /**
+    * This method must not be called directly by ActiveMQ Artemis clients.
+    */
+   void close() throws ActiveMQException;
+
+   /**
+    * This method must not be called directly by ActiveMQ Artemis clients.
+    */
+   int encode(ByteBuffer bufferRead) throws ActiveMQException;
+
+   /**
+    * This method must not be called directly by ActiveMQ Artemis clients.
+    */
+   int encode(ActiveMQBuffer bufferOut, int size) throws ActiveMQException;
+
+   /**
+    * This method must not be called directly by ActiveMQ Artemis clients.
+    */
+   long getLargeBodySize();
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
new file mode 100644
index 0000000..fd09751
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -0,0 +1,1066 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.message.impl;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RefCountMessage;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.encode.BodyType;
+import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
+import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer;
+import org.apache.activemq.artemis.core.message.LargeBodyEncoder;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
+import org.apache.activemq.artemis.utils.DataConstants;
+import org.apache.activemq.artemis.utils.TypedProperties;
+import org.apache.activemq.artemis.utils.UUID;
+import org.jboss.logging.Logger;
+
+/** Note: you shouldn't change properties using multi-threads. Change your properties before you can send it to multiple
+ *  consumers */
+public class CoreMessage extends RefCountMessage {
+
+   public static final int BUFFER_HEADER_SPACE = PacketImpl.PACKET_HEADERS_SIZE;
+
+   // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
+   // Note, it is only an estimate, it's not possible to be entirely sure with Java
+   // This figure is calculated using the test utilities in org.apache.activemq.tests.unit.util.sizeof
+   // The value is somewhat higher on 64 bit architectures, probably due to different alignment
+   private static final int memoryOffset = 352;
+
+   private volatile int memoryEstimate = -1;
+
+
+   private static final Logger logger = Logger.getLogger(CoreMessage.class);
+
+   // There's an integer with the number of bytes for the body
+   public static final int BODY_OFFSET = DataConstants.SIZE_INT;
+
+   /** That is the encode for the whole message, including properties..
+       it does not include the buffer for the Packet send and receive header on core protocol */
+   protected ByteBuf buffer;
+
+   private volatile boolean validBuffer = false;
+
+   protected volatile ResetLimitWrappedActiveMQBuffer writableBuffer;
+
+   Object body;
+
+   protected int endOfBodyPosition = -1;
+
+   protected int messageIDPosition = -1;
+
+   protected long messageID;
+
+   protected SimpleString address;
+
+   protected byte type;
+
+   protected boolean durable;
+
+   /**
+    * GMT milliseconds at which this message expires. 0 means never expires *
+    */
+   private long expiration;
+
+   protected long timestamp;
+
+   protected byte priority;
+
+   private UUID userID;
+
+   private int propertiesLocation = -1;
+
+   protected volatile TypedProperties properties;
+
+   private Object protocol;
+
+   public CoreMessage() {
+   }
+
+   @Override
+   public CoreMessage setProtocol(Object protocol) {
+      this.protocol = protocol;
+      return this;
+   }
+
+   @Override
+   public Object getProtocol() {
+      return protocol;
+   }
+
+   @Override
+   public Persister<Message> getPersister() {
+      return CoreMessagePersister.getInstance();
+   }
+
+   public CoreMessage initBuffer(final int initialMessageBufferSize) {
+      buffer = ActiveMQBuffers.dynamicBuffer(initialMessageBufferSize).byteBuf();
+
+      // There's a bug in netty which means a dynamic buffer won't resize until you write a byte
+      buffer.writeByte((byte) 0);
+
+      buffer.setIndex(BODY_OFFSET, BODY_OFFSET);
+
+      return this;
+   }
+
+   @Override
+   public void receiveBuffer(ByteBuf buffer) {
+      this.buffer = buffer;
+      this.buffer.retain();
+      decode();
+      this.validBuffer = true;
+   }
+
+   @Override
+   public ActiveMQBuffer getReadOnlyBodyBuffer() {
+      internalWritableBuffer();
+      return new ChannelBufferWrapper(buffer.slice(BODY_OFFSET, endOfBodyPosition - BUFFER_HEADER_SPACE).setIndex(0, endOfBodyPosition - BUFFER_HEADER_SPACE).asReadOnly());
+   }
+
+   /**
+    *
+    * @param sendBuffer
+    * @param deliveryCount Some protocols (AMQP) will have this as part of the message. ignored on core
+    */
+   @Override
+   public void sendBuffer(ByteBuf sendBuffer, int deliveryCount) {
+      checkEncode();
+      sendBuffer.writeBytes(buffer, 0, buffer.writerIndex());
+   }
+
+   private synchronized void checkEncode() {
+      if (!validBuffer) {
+         encode();
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public ActiveMQBuffer getBodyBuffer() {
+      // if using the writable buffer, we must parse properties
+      checkProperties();
+
+      internalWritableBuffer();
+
+      return writableBuffer;
+   }
+
+   private void internalWritableBuffer() {
+      if (writableBuffer == null) {
+         writableBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer.duplicate(), this);
+         if (endOfBodyPosition > 0) {
+            writableBuffer.byteBuf().setIndex(BODY_OFFSET, endOfBodyPosition - BUFFER_HEADER_SPACE + BODY_OFFSET);
+            writableBuffer.resetReaderIndex();
+         }
+      }
+   }
+
+   public int getEndOfBodyPosition() {
+      if (endOfBodyPosition < 0) {
+         endOfBodyPosition = getBodyBuffer().writerIndex();
+      }
+      return endOfBodyPosition;
+   }
+
+
+   public TypedProperties getTypedProperties() {
+      return checkProperties();
+   }
+
+
+   @Override
+   public void messageChanged() {
+      validBuffer = false;
+   }
+
+   protected CoreMessage(CoreMessage other) {
+      this(other, other.properties);
+   }
+
+   public CoreMessage(long id, int bufferSize) {
+      this.initBuffer(bufferSize);
+      this.setMessageID(id);
+   }
+
+   protected CoreMessage(CoreMessage other, TypedProperties copyProperties) {
+      this.body = other.body;
+      this.endOfBodyPosition = other.endOfBodyPosition;
+      this.messageID = other.messageID;
+      this.address = other.address;
+      this.type = other.type;
+      this.durable = other.durable;
+      this.expiration = other.expiration;
+      this.timestamp = other.timestamp;
+      this.priority = other.priority;
+      this.userID = other.userID;
+      if (copyProperties != null) {
+         this.properties = new TypedProperties(copyProperties);
+      }
+      if (other.buffer != null) {
+         this.buffer = other.buffer.copy();
+      }
+   }
+
+   @Override
+   public void copyHeadersAndProperties(final Message msg) {
+      messageID = msg.getMessageID();
+      address = msg.getAddressSimpleString();
+      userID = (UUID)msg.getUserID();
+      type = msg.getType();
+      durable = msg.isDurable();
+      expiration = msg.getExpiration();
+      timestamp = msg.getTimestamp();
+      priority = msg.getPriority();
+
+      if (msg instanceof CoreMessage) {
+         properties = ((CoreMessage)msg).getTypedProperties();
+      } else {
+         // TODO-now: copy stuff
+         logger.warn("Must implement copyHeaderAndProperties for other messages");
+      }
+   }
+
+
+   @Override
+   public Message copy() {
+      return new CoreMessage(this);
+   }
+
+   @Override
+   public Message copy(long newID) {
+      return copy().setMessageID(newID);
+   }
+
+   @Override
+   public long getExpiration() {
+      return expiration;
+   }
+
+   @Override
+   public long getTimestamp() {
+      return timestamp;
+   }
+
+   @Override
+   public CoreMessage setTimestamp(long timestamp) {
+      this.timestamp = timestamp;
+      return this;
+   }
+
+   @Override
+   public long getMessageID() {
+      return messageID;
+   }
+
+   @Override
+   public byte getPriority() {
+      return priority;
+   }
+
+   @Override
+   public UUID getUserID() {
+      return userID;
+   }
+
+   @Override
+   public CoreMessage setUserID(Object uuid) {
+      this.userID = (UUID)uuid;
+      return this;
+   }
+
+   @Override
+   public CoreMessage setMessageID(long messageID) {
+      this.messageID = messageID;
+      if (messageIDPosition >= 0 && validBuffer) {
+         buffer.setLong(messageIDPosition, messageID);
+      }
+      return this;
+   }
+
+   @Override
+   public CoreMessage setAddress(SimpleString address) {
+      if (validBuffer && !address.equals(this.address)) {
+         messageChanged();
+      }
+      this.address = address;
+      return this;
+   }
+
+   @Override
+   public SimpleString getAddressSimpleString() {
+      return address;
+   }
+
+
+   @Override
+   public CoreMessage setExpiration(long expiration) {
+      this.expiration = expiration;
+      return this;
+   }
+
+   @Override
+   public CoreMessage setPriority(byte priority) {
+      this.priority = priority;
+      return this;
+   }
+
+   public CoreMessage setUserID(UUID userID) {
+      this.userID = userID;
+      return this;
+   }
+
+   /**
+    * I am keeping this synchronized as the decode of the Properties is lazy
+    */
+   protected TypedProperties checkProperties() {
+      if (properties == null) {
+         TypedProperties properties = new TypedProperties();
+         if (buffer != null && propertiesLocation >= 0) {
+            properties.decode(buffer.duplicate().readerIndex(propertiesLocation));
+         }
+         this.properties = properties;
+      }
+
+      return this.properties;
+   }
+
+
+   @Override
+   public int getMemoryEstimate() {
+      if (memoryEstimate == -1) {
+         if (buffer == null) {
+            new Exception("It is null").printStackTrace();
+         }
+         if (properties == null) {
+            new Exception("Properties It is null").printStackTrace();
+         }
+         memoryEstimate = memoryOffset +
+            (buffer != null ? buffer.capacity() : 0) +
+            (properties != null ? properties.getMemoryOffset() : 0);
+      }
+
+      return memoryEstimate;
+   }
+
+   @Override
+   public byte getType() {
+      return type;
+   }
+
+   @Override
+   public CoreMessage setType(byte type) {
+      this.type = type;
+      return this;
+   }
+
+   private void decode() {
+      endOfBodyPosition = buffer.readInt();
+
+      buffer.skipBytes(endOfBodyPosition - BUFFER_HEADER_SPACE);
+
+      decodeHeadersAndProperties(buffer, true);
+      buffer.readerIndex(0);
+
+      internalWritableBuffer();
+   }
+
+
+   public void decodeHeadersAndProperties(final ByteBuf buffer) {
+      decodeHeadersAndProperties(buffer, false);
+   }
+
+   private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) {
+      messageIDPosition = buffer.readerIndex();
+      messageID = buffer.readLong();
+
+      address = SimpleString.readNullableSimpleString(buffer);
+      if (buffer.readByte() == DataConstants.NOT_NULL) {
+         byte[] bytes = new byte[16];
+         buffer.readBytes(bytes);
+         userID = new UUID(UUID.TYPE_TIME_BASED, bytes);
+      } else {
+         userID = null;
+      }
+      type = buffer.readByte();
+      durable = buffer.readBoolean();
+      expiration = buffer.readLong();
+      timestamp = buffer.readLong();
+      priority = buffer.readByte();
+      if (lazyProperties) {
+         properties = null;
+         propertiesLocation = buffer.readerIndex();
+      } else {
+         properties = new TypedProperties();
+         properties.decode(buffer);
+      }
+   }
+
+
+   public synchronized CoreMessage encode() {
+
+      checkProperties();
+
+      if (writableBuffer != null) {
+         // The message encode takes into consideration the PacketImpl which is not part of this encoding
+         // so we always need to take the BUFFER_HEADER_SPACE from packet impl into consideration
+         endOfBodyPosition = writableBuffer.writerIndex() + BUFFER_HEADER_SPACE - 4;
+      } else if (endOfBodyPosition <= 0) {
+         endOfBodyPosition = BUFFER_HEADER_SPACE;
+      }
+
+      buffer.setIndex(0, 0);
+      buffer.writeInt(endOfBodyPosition);
+
+      // The end of body position
+      buffer.writerIndex(endOfBodyPosition - BUFFER_HEADER_SPACE + DataConstants.SIZE_INT);
+
+      encodeHeadersAndProperties(buffer);
+
+      validBuffer = true;
+
+      return this;
+   }
+
+   public void encodeHeadersAndProperties(final ByteBuf buffer) {
+      checkProperties();
+      messageIDPosition = buffer.writerIndex();
+      buffer.writeLong(messageID);
+      SimpleString.writeNullableSimpleString(buffer, address);
+      if (userID == null) {
+         buffer.writeByte(DataConstants.NULL);
+      } else {
+         buffer.writeByte(DataConstants.NOT_NULL);
+         buffer.writeBytes(userID.asBytes());
+      }
+      buffer.writeByte(type);
+      buffer.writeBoolean(durable);
+      buffer.writeLong(expiration);
+      buffer.writeLong(timestamp);
+      buffer.writeByte(priority);
+      properties.encode(buffer);
+   }
+
+   @Override
+   public Object getBody() {
+
+      if (body == null) {
+         decodeBody();
+      }
+
+      return body;
+   }
+
+   private void decodeBody() {
+      buffer.readerIndex(DataConstants.SIZE_INT);
+      switch (getBodyType()) {
+         case Text:
+            body = SimpleString.readNullableSimpleString(buffer);
+            break;
+
+         default:
+            break;
+      }
+   }
+
+   public int getHeadersAndPropertiesEncodeSize() {
+      return DataConstants.SIZE_LONG + // Message ID
+         DataConstants.SIZE_BYTE + // user id null?
+         (userID == null ? 0 : 16) +
+             /* address */SimpleString.sizeofNullableString(address) +
+         DataConstants./* Type */SIZE_BYTE +
+         DataConstants./* Durable */SIZE_BOOLEAN +
+         DataConstants./* Expiration */SIZE_LONG +
+         DataConstants./* Timestamp */SIZE_LONG +
+         DataConstants./* Priority */SIZE_BYTE +
+             /* PropertySize and Properties */checkProperties().getEncodeSize();
+   }
+
+   @Override
+   public BodyType getBodyType() {
+      return getBodyType(type);
+   }
+
+   public static BodyType getBodyType(byte type) {
+      switch (type) {
+
+         case Message.DEFAULT_TYPE:
+            return BodyType.Undefined;
+
+         case Message.OBJECT_TYPE:
+            return BodyType.Object;
+
+         case Message.TEXT_TYPE:
+            return BodyType.Text;
+
+         case Message.BYTES_TYPE:
+            return BodyType.Text;
+
+         case Message.MAP_TYPE:
+            return BodyType.Map;
+
+         case Message.STREAM_TYPE:
+            return BodyType.Stream;
+
+         default:
+            return BodyType.Undefined;
+
+      }
+   }
+
+   @Override
+   public int getEncodeSize() {
+      checkEncode();
+      return buffer == null ? -1 : buffer.writerIndex();
+   }
+
+   @Override
+   public CoreMessage setBody(final BodyType bodyType, Object body) {
+      messageChanged();
+
+      this.type = Message.TEXT_TYPE;
+      this.body = body;
+
+      return this;
+   }
+
+   @Override
+   public boolean isLargeMessage() {
+      return false;
+   }
+
+   private void encodeBody(ByteBuf intoBuffer) {
+      intoBuffer.writerIndex(DataConstants.SIZE_INT);
+
+      switch (getBodyType()) {
+
+         // TODO-now implement other types
+         case Text:
+            SimpleString.writeNullableSimpleString(intoBuffer, SimpleString.toSimpleString(body == null ? null : body.toString()));
+            break;
+
+         default:
+            break;
+      }
+
+
+      endOfBodyPosition = buffer.writerIndex() + BUFFER_HEADER_SPACE;
+      buffer.setInt(0, endOfBodyPosition);
+   }
+
+   @Override
+   public String getAddress() {
+      if (address == null) {
+         return null;
+      } else {
+         return address.toString();
+      }
+   }
+
+   @Override
+   public CoreMessage setAddress(String address) {
+      messageChanged();
+      this.address = SimpleString.toSimpleString(address);
+      return this;
+   }
+
+   @Override
+   public CoreMessage setBuffer(ByteBuf buffer) {
+      this.buffer = buffer;
+
+      return this;
+   }
+
+   @Override
+   public ByteBuf getBuffer() {
+      return buffer;
+   }
+
+   @Override
+   public boolean isDurable() {
+      return durable;
+   }
+
+   @Override
+   public CoreMessage setDurable(boolean durable) {
+      messageChanged();
+      this.durable = durable;
+      return this;
+   }
+
+
+   @Override
+   public CoreMessage putBooleanProperty(final String key, final boolean value) {
+      messageChanged();
+      checkProperties();
+      properties.putBooleanProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putBooleanProperty(final SimpleString key, final boolean value) {
+      messageChanged();
+      checkProperties();
+      properties.putBooleanProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public Boolean getBooleanProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getBooleanProperty(key);
+   }
+
+   @Override
+   public Boolean getBooleanProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getBooleanProperty(new SimpleString(key));
+   }
+
+
+   @Override
+   public CoreMessage putByteProperty(final SimpleString key, final byte value) {
+      messageChanged();
+      checkProperties();
+      properties.putByteProperty(key, value);
+      return this;
+   }
+
+
+   @Override
+   public CoreMessage putByteProperty(final String key, final byte value) {
+      messageChanged();
+      checkProperties();
+      properties.putByteProperty(new SimpleString(key), value);
+
+      return this;
+   }
+
+
+   @Override
+   public Byte getByteProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getByteProperty(key);
+   }
+
+   @Override
+   public Byte getByteProperty(final String key) throws ActiveMQPropertyConversionException {
+      return getByteProperty(SimpleString.toSimpleString(key));
+   }
+
+   @Override
+   public CoreMessage putBytesProperty(final SimpleString key, final byte[] value) {
+      messageChanged();
+      checkProperties();
+      properties.putBytesProperty(key, value);
+
+      return this;
+   }
+
+   @Override
+   public CoreMessage putBytesProperty(final String key, final byte[] value) {
+      messageChanged();
+      checkProperties();
+      properties.putBytesProperty(new SimpleString(key), value);
+      return this;
+   }
+
+
+   @Override
+   public byte[] getBytesProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getBytesProperty(key);
+   }
+
+   @Override
+   public byte[] getBytesProperty(final String key) throws ActiveMQPropertyConversionException {
+      return getBytesProperty(new SimpleString(key));
+   }
+
+   @Override
+   public CoreMessage putCharProperty(SimpleString key, char value) {
+      messageChanged();
+      checkProperties();
+      properties.putCharProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putCharProperty(String key, char value) {
+      messageChanged();
+      checkProperties();
+      properties.putCharProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putShortProperty(final SimpleString key, final short value) {
+      messageChanged();
+      checkProperties();
+      properties.putShortProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putShortProperty(final String key, final short value) {
+      messageChanged();
+      checkProperties();
+      properties.putShortProperty(new SimpleString(key), value);
+      return this;
+   }
+
+
+   @Override
+   public CoreMessage putIntProperty(final SimpleString key, final int value) {
+      messageChanged();
+      checkProperties();
+      properties.putIntProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putIntProperty(final String key, final int value) {
+      messageChanged();
+      checkProperties();
+      properties.putIntProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getIntProperty(key);
+   }
+
+   @Override
+   public Integer getIntProperty(final String key) throws ActiveMQPropertyConversionException {
+      return getIntProperty(SimpleString.toSimpleString(key));
+   }
+
+
+   @Override
+   public CoreMessage putLongProperty(final SimpleString key, final long value) {
+      messageChanged();
+      checkProperties();
+      properties.putLongProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putLongProperty(final String key, final long value) {
+      messageChanged();
+      checkProperties();
+      properties.putLongProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public Long getLongProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getLongProperty(key);
+   }
+
+   @Override
+   public Long getLongProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return getLongProperty(SimpleString.toSimpleString(key));
+   }
+
+
+   @Override
+   public CoreMessage putFloatProperty(final SimpleString key, final float value) {
+      messageChanged();
+      checkProperties();
+      properties.putFloatProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putFloatProperty(final String key, final float value) {
+      messageChanged();
+      checkProperties();
+      properties.putFloatProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putDoubleProperty(final SimpleString key, final double value) {
+      messageChanged();
+      checkProperties();
+      properties.putDoubleProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putDoubleProperty(final String key, final double value) {
+      messageChanged();
+      checkProperties();
+      properties.putDoubleProperty(new SimpleString(key), value);
+      return this;
+   }
+
+
+   @Override
+   public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      messageChanged();
+      checkProperties();
+      return properties.getDoubleProperty(key);
+   }
+
+   @Override
+   public Double getDoubleProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return getDoubleProperty(SimpleString.toSimpleString(key));
+   }
+
+   @Override
+   public CoreMessage putStringProperty(final SimpleString key, final SimpleString value) {
+      messageChanged();
+      checkProperties();
+      properties.putSimpleStringProperty(key, value);
+      return this;
+   }
+
+   @Override
+   public CoreMessage putStringProperty(final String key, final String value) {
+      messageChanged();
+      checkProperties();
+      properties.putSimpleStringProperty(new SimpleString(key), SimpleString.toSimpleString(value));
+      return this;
+   }
+
+   @Override
+   public CoreMessage putObjectProperty(final SimpleString key,
+                                        final Object value) throws ActiveMQPropertyConversionException {
+      messageChanged();
+      checkProperties();
+      TypedProperties.setObjectProperty(key, value, properties);
+      return this;
+   }
+
+   @Override
+   public Object getObjectProperty(final String key) {
+      checkProperties();
+      return getObjectProperty(SimpleString.toSimpleString(key));
+   }
+
+   @Override
+   public Object getObjectProperty(final SimpleString key) {
+      checkProperties();
+      return properties.getProperty(key);
+   }
+
+   @Override
+   public CoreMessage putObjectProperty(final String key, final Object value) throws ActiveMQPropertyConversionException {
+      messageChanged();
+      putObjectProperty(new SimpleString(key), value);
+      return this;
+   }
+
+   @Override
+   public Short getShortProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getShortProperty(key);
+   }
+
+   @Override
+   public Short getShortProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getShortProperty(new SimpleString(key));
+   }
+
+   @Override
+   public Float getFloatProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getFloatProperty(key);
+   }
+
+   @Override
+   public Float getFloatProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getFloatProperty(new SimpleString(key));
+   }
+
+   @Override
+   public String getStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      SimpleString str = getSimpleStringProperty(key);
+
+      if (str == null) {
+         return null;
+      } else {
+         return str.toString();
+      }
+   }
+
+   @Override
+   public String getStringProperty(final String key) throws ActiveMQPropertyConversionException {
+      return getStringProperty(new SimpleString(key));
+   }
+
+   @Override
+   public SimpleString getSimpleStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getSimpleStringProperty(key);
+   }
+
+   @Override
+   public SimpleString getSimpleStringProperty(final String key) throws ActiveMQPropertyConversionException {
+      checkProperties();
+      return properties.getSimpleStringProperty(new SimpleString(key));
+   }
+
+   @Override
+   public Object removeProperty(final SimpleString key) {
+      checkProperties();
+      Object oldValue = properties.removeProperty(key);
+      if (oldValue != null) {
+         messageChanged();
+      }
+      return oldValue;
+   }
+
+   @Override
+   public Object removeProperty(final String key) {
+      messageChanged();
+      checkProperties();
+      Object oldValue = properties.removeProperty(new SimpleString(key));
+      if (oldValue != null) {
+         messageChanged();
+      }
+      return oldValue;
+   }
+
+   @Override
+   public boolean containsProperty(final SimpleString key) {
+      checkProperties();
+      return properties.containsProperty(key);
+   }
+
+   @Override
+   public boolean containsProperty(final String key) {
+      checkProperties();
+      return properties.containsProperty(new SimpleString(key));
+   }
+
+   @Override
+   public Set<SimpleString> getPropertyNames() {
+      checkProperties();
+      return properties.getPropertyNames();
+   }
+
+   @Override
+   public LargeBodyEncoder getBodyEncoder() throws ActiveMQException {
+      return new DecodingContext();
+   }
+
+   private final class DecodingContext implements LargeBodyEncoder {
+
+      private int lastPos = 0;
+
+      private DecodingContext() {
+      }
+
+      @Override
+      public void open() {
+      }
+
+      @Override
+      public void close() {
+      }
+
+      @Override
+      public long getLargeBodySize() {
+         return buffer.writerIndex();
+      }
+
+      @Override
+      public int encode(final ByteBuffer bufferRead) throws ActiveMQException {
+         ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(bufferRead);
+         return encode(buffer, bufferRead.capacity());
+      }
+
+      @Override
+      public int encode(final ActiveMQBuffer bufferOut, final int size) {
+         bufferOut.byteBuf().writeBytes(buffer, lastPos, size);
+         lastPos += size;
+         return size;
+      }
+   }
+
+   @Override
+   public int getPersistSize() {
+      checkEncode();
+      return buffer.writerIndex() + DataConstants.SIZE_INT;
+   }
+
+   @Override
+   public void persist(ActiveMQBuffer targetRecord) {
+      targetRecord.writeInt(buffer.writerIndex());
+      targetRecord.writeBytes(buffer, 0, buffer.writerIndex());
+   }
+
+   @Override
+   public void reloadPersistence(ActiveMQBuffer record) {
+      int size = record.readInt();
+      initBuffer(size);
+      buffer.setIndex(0, 0).writeBytes(record.byteBuf(), size);
+      decode();
+
+   }
+
+   @Override
+   public Message toCore() {
+      return this;
+   }
+
+
+
+   @Override
+   public String toString() {
+      try {
+         return "CoreMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority()  +
+            ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) +
+            ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this);
+      } catch (Throwable e) {
+         return "ServerMessage[messageID=" + messageID + "]";
+      }
+   }
+
+
+   private static String toDate(long timestamp) {
+      if (timestamp == 0) {
+         return "0";
+      } else {
+         return new java.util.Date(timestamp).toString();
+      }
+
+   }
+
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessagePersister.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessagePersister.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessagePersister.java
new file mode 100644
index 0000000..ddf39d2
--- /dev/null
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessagePersister.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.core.message.impl;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.persistence.Persister;
+import org.apache.activemq.artemis.utils.DataConstants;
+
+public class CoreMessagePersister implements Persister<Message> {
+
+   public static CoreMessagePersister theInstance = new CoreMessagePersister();
+
+   public static CoreMessagePersister getInstance() {
+      return theInstance;
+   }
+
+   protected CoreMessagePersister() {
+   }
+
+
+   @Override
+   public int getEncodeSize(Message record) {
+      return DataConstants.SIZE_BYTE + record.getPersistSize() +
+         SimpleString.sizeofNullableString(record.getAddressSimpleString()) + DataConstants.SIZE_LONG;
+   }
+
+
+   /** Sub classes must add the first short as the protocol-id */
+   @Override
+   public void encode(ActiveMQBuffer buffer, Message record) {
+      buffer.writeByte((byte)1);
+      buffer.writeLong(record.getMessageID());
+      buffer.writeNullableSimpleString(record.getAddressSimpleString());
+      record.persist(buffer);
+   }
+
+
+   @Override
+   public Message decode(ActiveMQBuffer buffer, Message record) {
+      // the caller must consume the first byte already, as that will be used to decide what persister (protocol) to use
+      long id = buffer.readLong();
+      SimpleString address = buffer.readNullableSimpleString();
+      record = new CoreMessage();
+      record.reloadPersistence(buffer);
+      record.setMessageID(id);
+      record.setAddress(address);
+      return record;
+   }
+}


[11/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
new file mode 100644
index 0000000..1897bdd
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/MessageJournalTest.java
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.journal;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
+import org.apache.activemq.artemis.core.journal.RecordInfo;
+import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManagerFactory;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.qpid.proton.message.Message;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MessageJournalTest extends ActiveMQTestBase {
+
+   @Test
+   public void testStoreCore() throws Throwable {
+      ActiveMQServer server = createServer(true);
+
+      server.start();
+
+      CoreMessage message = new CoreMessage().initBuffer(10 * 1024).setDurable(true);
+
+      message.setMessageID(333);
+
+      CoreProtocolManagerFactory factory = (CoreProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("CORE");
+
+      Assert.assertNotNull(factory);
+
+      message.getBodyBuffer().writeByte((byte)'Z');
+
+      message.setProtocol(factory.createProtocolManager(server, null, null, null));
+
+      server.getStorageManager().storeMessage(message);
+
+      server.getStorageManager().stop();
+
+      JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
+
+      List<RecordInfo> committedRecords = new LinkedList<>();
+
+      List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
+
+      TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {
+         @Override
+         public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
+
+         }
+      };
+
+      try {
+         journalStorageManager.getMessageJournal().start();
+
+         journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
+
+         Assert.assertEquals(1, committedRecords.size());
+      } finally {
+         journalStorageManager.getMessageJournal().stop();
+      }
+
+   }
+
+
+   @Test
+   public void testStoreAMQP() throws Throwable {
+      ActiveMQServer server = createServer(true);
+
+      server.start();
+
+      ProtonProtocolManagerFactory factory = (ProtonProtocolManagerFactory) server.getRemotingService().getProtocolFactoryMap().get("AMQP");
+
+      Message protonJMessage = Message.Factory.create();
+
+      AMQPMessage message = new AMQPMessage(protonJMessage, (ProtonProtocolManager)factory.createProtocolManager(server, null, null, null));
+
+      message.setMessageID(333);
+
+      Assert.assertNotNull(factory);
+
+      server.getStorageManager().storeMessage(message);
+
+      server.getStorageManager().stop();
+
+      JournalStorageManager journalStorageManager = (JournalStorageManager) server.getStorageManager();
+
+      List<RecordInfo> committedRecords = new LinkedList<>();
+
+      List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>();
+
+      TransactionFailureCallback transactionFailure = new TransactionFailureCallback() {
+         @Override
+         public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) {
+
+         }
+      };
+
+      try {
+         journalStorageManager.getMessageJournal().start();
+
+         journalStorageManager.getMessageJournal().load(committedRecords, preparedTransactions, transactionFailure);
+
+         Assert.assertEquals(1, committedRecords.size());
+      } finally {
+         journalStorageManager.getMessageJournal().stop();
+      }
+
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
index 38cc126..a0f23d0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
@@ -43,9 +43,9 @@ import org.apache.activemq.artemis.core.journal.impl.JournalCompactor;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
 import org.apache.activemq.artemis.core.journal.impl.JournalFileImpl;
 import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase;
 import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -1656,13 +1656,13 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
                         long id = seqGenerator.incrementAndGet();
                         values[i] = id;
 
-                        ServerMessageImpl message = new ServerMessageImpl(id, 100);
+                        CoreMessage message = new CoreMessage(id, 100);
 
                         message.getBodyBuffer().writeBytes(new byte[1024]);
 
                         storage.storeMessageTransactional(tx, message);
                      }
-                     ServerMessageImpl message = new ServerMessageImpl(seqGenerator.incrementAndGet(), 100);
+                     CoreMessage message = new CoreMessage(seqGenerator.incrementAndGet(), 100);
 
                      survivingMsgs.add(message.getMessageID());
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
new file mode 100644
index 0000000..f055531
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ContainerBaseTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.TestAddress;
+import org.ops4j.pax.exam.TestContainer;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.TestProbeProvider;
+import org.ops4j.pax.exam.spi.PaxExamRuntime;
+
+/**
+ * This is useful for when you want to automate remote tests.
+ */
+public abstract class ContainerBaseTest extends KarafBaseTest {
+   protected ExamSystem system;
+   protected TestProbeBuilder builder;
+   protected TestAddress testToBeCalled;
+   protected TestProbeProvider probe;
+   protected TestContainer container;
+
+   protected void setupContainer(Class testToCall, String methodToCall, Option[] options) throws IOException {
+      system = PaxExamRuntime.createTestSystem(options);
+      builder = system.createProbe();
+      testToBeCalled = builder.addTest(testToCall, methodToCall);
+      probe = builder.build();
+      container = PaxExamRuntime.createContainer(system);
+      container.start();
+      container.install(probe.getStream());
+   }
+
+   @After
+   public void shutdownContainer() {
+      if (container != null) {
+         container.stop();
+      }
+   }
+
+
+   protected void executeRemoteTest() {
+      container.call(testToBeCalled);
+   }
+
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
new file mode 100644
index 0000000..22f1efc
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/KarafBaseTest.java
@@ -0,0 +1,212 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf;
+
+import javax.inject.Inject;
+import javax.security.auth.Subject;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
+import org.apache.karaf.jaas.boot.principal.UserPrincipal;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.options.UrlReference;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+public class KarafBaseTest extends Assert {
+
+   private static Logger LOG = Logger.getLogger(KarafBaseTest.class.getName());
+
+   public static final long ASSERTION_TIMEOUT = 30000L;
+   public static final long COMMAND_TIMEOUT = 30000L;
+   public static final String USER = "karaf";
+   public static final String PASSWORD = "karaf";
+
+   /**
+    * plug to add more options on sub tests
+    */
+   protected void testOptions(List<Option> options) throws Exception {
+   }
+
+   public Option[] configureArtemisFeatures(boolean debug, String version, String... features) throws Exception {
+
+      ArrayList<String> featureArray = new ArrayList<>();
+      featureArray.addAll(Arrays.asList(features));
+
+      List<Option> optionList = new LinkedList<>();
+
+      optionList.add(karafDistributionConfiguration().
+                                    frameworkUrl(maven().groupId("org.apache.karaf").
+                                       artifactId("apache-karaf").type("tar.gz").
+                                       versionAsInProject()).unpackDirectory(new File("target/containertest/unpack/")));
+      optionList.add(KarafDistributionOption.keepRuntimeFolder());
+      optionList.add(logLevel(LogLevelOption.LogLevel.INFO));
+      optionList.add(editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"));
+
+      if (debug) {
+         // uncomment this to debug it.
+         optionList.add(debugConfiguration("5005", true));
+      }
+
+      optionList.add(features(getArtemisMQKarafFeatureUrl(version), featureArray.toArray(new String[featureArray.size()])));
+
+      testOptions(optionList);
+
+      return optionList.toArray(new Option[optionList.size()]);
+   }
+
+   public UrlReference getArtemisMQKarafFeatureUrl(String version) {
+      String type = "xml/features";
+      UrlReference urlReference;
+
+      if (version == null) {
+         urlReference = mavenBundle().groupId("org.apache.activemq").
+            artifactId("artemis-features").versionAsInProject().type(type);
+      } else {
+         urlReference = mavenBundle().groupId("org.apache.activemq").
+            artifactId("artemis-features").version(version).type(type);
+      }
+      LOG.info("FeatureURL: " + urlReference.getURL());
+      return urlReference;
+   }
+
+   ExecutorService executor = Executors.newCachedThreadPool();
+
+   @Inject
+   BundleContext bundleContext;
+
+   @Inject
+   SessionFactory sessionFactory;
+
+   protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
+      String response;
+      final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+      final PrintStream printStream = new PrintStream(byteArrayOutputStream);
+      final Session commandSession = sessionFactory.create(System.in, printStream, printStream);
+      commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
+      commandSession.put("USER", USER);
+      FutureTask<String> commandFuture = new FutureTask<>(new Callable<String>() {
+         @Override
+         public String call() {
+
+            Subject subject = new Subject();
+            subject.getPrincipals().add(new UserPrincipal("admin"));
+            subject.getPrincipals().add(new RolePrincipal("admin"));
+            subject.getPrincipals().add(new RolePrincipal("manager"));
+            subject.getPrincipals().add(new RolePrincipal("viewer"));
+            return Subject.doAs(subject, new PrivilegedAction<String>() {
+               @Override
+               public String run() {
+                  try {
+                     if (!silent) {
+                        System.out.println(command);
+                        System.out.flush();
+                     }
+                     commandSession.execute(command);
+                  } catch (Exception e) {
+                     e.printStackTrace(System.err);
+                  }
+                  printStream.flush();
+                  return byteArrayOutputStream.toString();
+               }
+            });
+         }
+      });
+
+      try {
+         executor.submit(commandFuture);
+         response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
+      } catch (Exception e) {
+         e.printStackTrace(System.err);
+         response = "SHELL COMMAND TIMED OUT: ";
+      }
+      LOG.info("Execute: " + command + " - Response:" + response);
+      return response;
+   }
+
+   protected String executeCommand(final String command) {
+      return executeCommand(command, COMMAND_TIMEOUT, false);
+   }
+
+   protected boolean withinReason(Callable<Boolean> callable) throws Throwable {
+      long max = System.currentTimeMillis() + ASSERTION_TIMEOUT;
+      while (true) {
+         try {
+            return callable.call();
+         } catch (Throwable t) {
+            if (System.currentTimeMillis() < max) {
+               TimeUnit.SECONDS.sleep(1);
+               continue;
+            } else {
+               throw t;
+            }
+         }
+      }
+   }
+
+   public boolean verifyBundleInstalled(final String bundleName) throws Exception {
+      boolean found = false;
+      for (Bundle bundle : bundleContext.getBundles()) {
+         LOG.debug("Checking: " + bundle.getSymbolicName());
+         if (bundle.getSymbolicName().contains(bundleName)) {
+            found = true;
+            break;
+         }
+      }
+      return found;
+   }
+
+   protected Object waitForService(String filter, long timeout) throws InvalidSyntaxException, InterruptedException {
+      ServiceTracker<Object, Object> st = new ServiceTracker<>(bundleContext, bundleContext.createFilter(filter), null);
+      try {
+         st.open();
+         return st.waitForService(timeout);
+      } finally {
+         st.close();
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
new file mode 100644
index 0000000..b47a6e0
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/ArtemisFeatureTest.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.distribution;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import java.util.concurrent.Callable;
+
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.tests.integration.karaf.KarafBaseTest;
+import org.apache.log4j.Logger;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.Constants;
+
+/**
+ * Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
+ */
+@RunWith(PaxExam.class)
+public class ArtemisFeatureTest extends KarafBaseTest {
+
+   private static Logger LOG = Logger.getLogger(ArtemisFeatureTest.class.getName());
+
+   @ProbeBuilder
+   public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
+      probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.ops4j.pax.exam.options.*,org.apache.felix.service.*;status=provisional");
+      return probe;
+   }
+
+   @Configuration
+   public Option[] configure() throws Exception {
+      return configureArtemisFeatures(false, null, "artemis");
+   }
+   @Test
+   public void testSample() throws Throwable {
+      System.out.println("Hello!!!");
+      ClientMessageImpl message = new ClientMessageImpl();
+   }
+
+   @Test(timeout = 5 * 60 * 1000)
+   public void test() throws Throwable {
+      executeCommand("bundle:list");
+
+      withinReason(new Callable<Boolean>() {
+         @Override
+         public Boolean call() throws Exception {
+            assertTrue("artemis bundle installed", verifyBundleInstalled("artemis-server-osgi"));
+            return true;
+         }
+      });
+
+      Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000);
+      assertNotNull(service);
+      LOG.info("have service " + service);
+
+      executeCommand("service:list -n");
+
+      Connection connection = null;
+      try {
+         JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672");
+         connection = factory.createConnection(USER, PASSWORD);
+         connection.start();
+
+         javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
+         Queue queue = sess.createQueue("exampleQueue");
+         MessageProducer producer = sess.createProducer(queue);
+         producer.send(sess.createTextMessage("TEST"));
+
+         MessageConsumer consumer = sess.createConsumer(queue);
+         Message msg = consumer.receive(5000);
+         assertNotNull(msg);
+      } finally {
+         if (connection != null) {
+            connection.close();
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
new file mode 100644
index 0000000..5af5077
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/distribution/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This contains tests that will validate the Artemis distribution
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.distribution;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
new file mode 100644
index 0000000..7b4eea0
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/ProbeRemoteServer.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.ActiveMQServers;
+import org.apache.activemq.artemis.core.server.JournalType;
+import org.junit.Ignore;
+import org.junit.Test;
+
+// Ignored as this is executed by PaxExam on RemoteTest
+@Ignore
+public class ProbeRemoteServer {
+
+   ActiveMQServer server;
+
+   @Test
+   public void probe1() throws Exception {
+      System.out.println("probe1 with ");
+      ClientMessageImpl message = new ClientMessageImpl();
+
+      ConfigurationImpl config = new ConfigurationImpl().setSecurityEnabled(false).setJournalMinFiles(2).
+         setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO).
+         setJournalDirectory("./data/journal").
+         setBindingsDirectory("./data/binding").
+         setPagingDirectory("./data/paging").
+         setLargeMessagesDirectory("./data/lm").setJournalCompactMinFiles(0).setJournalCompactPercentage(0).setClusterPassword("mycluster").setJournalDatasync(false).setSecurityEnabled(false);
+      config.addAcceptorConfiguration("netty", "tcp://localhost:61616");
+
+      server = ActiveMQServers.newActiveMQServer(config, false);
+
+      server.start();
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
new file mode 100644
index 0000000..10e97b3
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/RemoteTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.integration.karaf.ContainerBaseTest;
+import org.junit.Test;
+
+public class RemoteTest extends ContainerBaseTest {
+
+   @Test
+   public void testValidateRemote() throws Exception {
+      setupContainer(ProbeRemoteServer.class, "probe1", configureArtemisFeatures(false, "1.5.1", "artemis-core"));
+
+      executeRemoteTest();
+
+      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+      factory.createConnection().close();
+
+      container.stop();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
new file mode 100644
index 0000000..be2fac5
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/VersionWireTest.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.version;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.tests.integration.karaf.KarafBaseTest;
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.ProbeBuilder;
+import org.ops4j.pax.exam.TestProbeBuilder;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.ops4j.pax.exam.CoreOptions.vmOptions;
+
+// uncomment this to be able to debug it
+// import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+
+/**
+ * Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class VersionWireTest extends KarafBaseTest {
+
+   File file = new File(System.getProperty("./target/generated.bin", System.getProperty("testFile", "./target/generated.bin")));
+
+
+   private static Logger LOG = Logger.getLogger(VersionWireTest.class.getName());
+
+   /**
+    * plug to add more options on sub tests
+    */
+   @Override
+   protected void testOptions(List<Option> options) throws Exception {
+      options.add(vmOptions("-DtestFile=" + file.getCanonicalPath()));
+   }
+
+   @ProbeBuilder
+   public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) throws Exception {
+
+      file.deleteOnExit();
+      System.out.println("Path::" + file.getCanonicalPath());
+      PrintStream out = new PrintStream(new FileOutputStream(file));
+      out.println("hello");
+      out.close();
+      System.out.println("probing!!!");
+      Message message = new ClientMessageImpl();
+      System.out.println("probed!!!");
+      return probe;
+   }
+
+
+   @Configuration
+   public Option[] configure1_5() throws Exception {
+
+      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+      factory.setBlockOnDurableSend(false);
+
+      return configureArtemisFeatures(false, "1.5.0", "artemis-core");
+
+   }
+
+   @Configuration
+   public Option[] configure13() throws Exception {
+      return configureArtemisFeatures(false, null, "artemis-core");
+   }
+
+
+   @Test
+   public void testSample() throws Throwable {
+      System.out.println("Path::" + file.getCanonicalPath());
+
+      Assert.assertTrue(file.getCanonicalPath() + " don't exist", file.exists());
+      System.out.println("Hello!!!");
+      ClientMessageImpl message = new ClientMessageImpl();
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
new file mode 100644
index 0000000..459e912
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/version/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests to check wire compatibility.
+ */
+package org.apache.activemq.artemis.tests.integration.karaf.version;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
index 1afc732..b6ea147 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java
@@ -16,19 +16,19 @@
  */
 package org.apache.activemq.artemis.tests.integration.management;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.AddressControl;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl;
 import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager;
 import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
@@ -50,10 +50,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
       server.start();
 
       // invoke attribute and operation on the server
-      ServerMessage message = new ServerMessageImpl(1, 100);
+      Message message = new CoreMessage(1, 100);
       ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "createQueue", queue, address);
 
-      ServerMessage reply = server.getManagementService().handleMessage(message);
+      Message reply = server.getManagementService().handleMessage(message);
 
       Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
    }
@@ -66,10 +66,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
       server.start();
 
       // invoke attribute and operation on the server
-      ServerMessage message = new ServerMessageImpl(1, 100);
+      Message message = new CoreMessage(1, 100);
       ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "thereIsNoSuchOperation");
 
-      ServerMessage reply = server.getManagementService().handleMessage(message);
+      Message reply = server.getManagementService().handleMessage(message);
 
       Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
       Assert.assertNotNull(ManagementHelper.getResult(reply));
@@ -83,10 +83,10 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
       server.start();
 
       // invoke attribute and operation on the server
-      ServerMessage message = new ServerMessageImpl(1, 100);
+      Message message = new CoreMessage(1, 100);
       ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");
 
-      ServerMessage reply = server.getManagementService().handleMessage(message);
+      Message reply = server.getManagementService().handleMessage(message);
 
       Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
       Assert.assertNotNull(ManagementHelper.getResult(reply));
@@ -100,11 +100,11 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
       server.start();
 
       // invoke attribute and operation on the server
-      ServerMessage message = new ServerMessageImpl(1, 100);
+      Message message = new CoreMessage(1, 100);
 
       ManagementHelper.putAttribute(message, ResourceNames.BROKER, "started");
 
-      ServerMessage reply = server.getManagementService().handleMessage(message);
+      Message reply = server.getManagementService().handleMessage(message);
 
       Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
       Assert.assertTrue((Boolean) ManagementHelper.getResult(reply));
@@ -118,11 +118,11 @@ public class ManagementServiceImplTest extends ActiveMQTestBase {
       server.start();
 
       // invoke attribute and operation on the server
-      ServerMessage message = new ServerMessageImpl(1, 100);
+      Message message = new CoreMessage(1, 100);
 
       ManagementHelper.putAttribute(message, ResourceNames.BROKER, "attribute.Does.Not.Exist");
 
-      ServerMessage reply = server.getManagementService().handleMessage(message);
+      Message reply = server.getManagementService().handleMessage(message);
 
       Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
       Assert.assertNotNull(ManagementHelper.getResult(reply));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
index 90f7c5f..615a924 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DeleteMessagesOnStartupTest.java
@@ -21,17 +21,17 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.StoreConfiguration;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.persistence.AddressBindingInfo;
 import org.apache.activemq.artemis.core.persistence.GroupingInfo;
 import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
 import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice;
 import org.junit.Assert;
@@ -40,8 +40,6 @@ import org.junit.runners.Parameterized;
 
 public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
 
-   volatile boolean deleteMessages = false;
-
    ArrayList<Long> deletedMessage = new ArrayList<>();
 
    public DeleteMessagesOnStartupTest(StoreConfiguration.StoreType storeType) {
@@ -63,12 +61,12 @@ public class DeleteMessagesOnStartupTest extends StorageManagerTestBase {
       HashMap<Long, Queue> queues = new HashMap<>();
       queues.put(100L, theQueue);
 
-      ServerMessage msg = new ServerMessageImpl(1, 100);
+      Message msg = new CoreMessage(1, 100);
 
       journal.storeMessage(msg);
 
       for (int i = 2; i < 100; i++) {
-         journal.storeMessage(new ServerMessageImpl(i, 100));
+         journal.storeMessage(new CoreMessage(i, 100));
       }
 
       journal.storeReference(100, 1, true);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
index 1ae9527..ab32517 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/replication/ReplicationTest.java
@@ -58,6 +58,7 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
@@ -65,6 +66,7 @@ import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
 import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
 import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
@@ -74,10 +76,8 @@ import org.apache.activemq.artemis.core.replication.ReplicatedJournal;
 import org.apache.activemq.artemis.core.replication.ReplicationManager;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.ClusterController;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -228,7 +228,7 @@ public final class ReplicationTest extends ActiveMQTestBase {
 
       Assert.assertTrue("Expecting no active tokens:" + manager.getActiveTokens(), manager.getActiveTokens().isEmpty());
 
-      ServerMessage msg = new ServerMessageImpl(1, 1024);
+      CoreMessage msg = new CoreMessage().initBuffer(1024).setMessageID(1);
 
       SimpleString dummy = new SimpleString("dummy");
       msg.setAddress(dummy);
@@ -259,12 +259,12 @@ public final class ReplicationTest extends ActiveMQTestBase {
 
       blockOnReplication(storage, manager);
 
-      ServerMessageImpl serverMsg = new ServerMessageImpl();
+      CoreMessage serverMsg = new CoreMessage();
       serverMsg.setMessageID(500);
       serverMsg.setAddress(new SimpleString("tttt"));
 
       ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(100);
-      serverMsg.encodeHeadersAndProperties(buffer);
+      serverMsg.encodeHeadersAndProperties(buffer.byteBuf());
 
       manager.largeMessageBegin(500);
 
@@ -619,6 +619,62 @@ public final class ReplicationTest extends ActiveMQTestBase {
    static final class FakeJournal implements Journal {
 
       @Override
+      public void appendAddRecord(long id,
+                                  byte recordType,
+                                  Persister persister,
+                                  Object record,
+                                  boolean sync) throws Exception {
+
+      }
+
+      @Override
+      public void appendAddRecord(long id,
+                                  byte recordType,
+                                  Persister persister,
+                                  Object record,
+                                  boolean sync,
+                                  IOCompletion completionCallback) throws Exception {
+
+      }
+
+      @Override
+      public void appendUpdateRecord(long id,
+                                     byte recordType,
+                                     Persister persister,
+                                     Object record,
+                                     boolean sync) throws Exception {
+
+      }
+
+      @Override
+      public void appendUpdateRecord(long id,
+                                     byte recordType,
+                                     Persister persister,
+                                     Object record,
+                                     boolean sync,
+                                     IOCompletion callback) throws Exception {
+
+      }
+
+      @Override
+      public void appendAddRecordTransactional(long txID,
+                                               long id,
+                                               byte recordType,
+                                               Persister persister,
+                                               Object record) throws Exception {
+
+      }
+
+      @Override
+      public void appendUpdateRecordTransactional(long txID,
+                                                  long id,
+                                                  byte recordType,
+                                                  Persister persister,
+                                                  Object record) throws Exception {
+
+      }
+
+      @Override
       public void appendAddRecord(final long id,
                                   final byte recordType,
                                   final byte[] record,
@@ -756,11 +812,6 @@ public final class ReplicationTest extends ActiveMQTestBase {
       }
 
       @Override
-      public void perfBlast(final int pages) {
-
-      }
-
-      @Override
       public boolean isStarted() {
 
          return false;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
index c3670c5..67cfe18 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FakeStorageManager.java
@@ -19,8 +19,8 @@ package org.apache.activemq.artemis.tests.integration.server;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 
 public class FakeStorageManager extends NullStorageManager {
 
@@ -29,12 +29,12 @@ public class FakeStorageManager extends NullStorageManager {
    List<Long> ackIds = new ArrayList<>();
 
    @Override
-   public void storeMessage(final ServerMessage message) throws Exception {
+   public void storeMessage(final Message message) throws Exception {
       messageIds.add(message.getMessageID());
    }
 
    @Override
-   public void storeMessageTransactional(final long txID, final ServerMessage message) throws Exception {
+   public void storeMessageTransactional(final long txID, final Message message) throws Exception {
       messageIds.add(message.getMessageID());
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
----------------------------------------------------------------------
diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
index 0ee92e9..0c4dbf5 100644
--- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
+++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
@@ -26,7 +26,9 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagingManager;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider;
@@ -37,8 +39,6 @@ import org.apache.activemq.artemis.core.replication.ReplicationManager;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.server.RouteContextList;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -188,8 +188,9 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
       }
 
       private void storeMessage(long txID, long id) throws Exception {
-         ServerMessage message = new ServerMessageImpl(id, 10 * 1024);
-         message.setPagingStore(fakePagingStore);
+         Message message = new CoreMessage(id, 10 * 1024);
+         // TODO-now: fix this
+         message.setContext(fakePagingStore);
 
          message.getBodyBuffer().writeBytes(new byte[104]);
          message.putStringProperty("hello", "" + id);
@@ -248,6 +249,26 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
    class FakePagingStore implements PagingStore {
 
       @Override
+      public void durableDown(Message message, int durableCount) {
+
+      }
+
+      @Override
+      public void durableUp(Message message, int durableCount) {
+
+      }
+
+      @Override
+      public void nonDurableUp(Message message, int nonDurableCoun) {
+
+      }
+
+      @Override
+      public void nonDurableDown(Message message, int nonDurableCoun) {
+
+      }
+
+      @Override
       public SimpleString getAddress() {
          return null;
       }
@@ -328,7 +349,7 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
       }
 
       @Override
-      public boolean page(ServerMessage message,
+      public boolean page(Message message,
                           Transaction tx,
                           RouteContextList listCtx,
                           ReentrantReadWriteLock.ReadLock readLock) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
----------------------------------------------------------------------
diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
index d902d3c..61c8d30 100644
--- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
+++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/PageCursorStressTest.java
@@ -25,9 +25,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.filter.Filter;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.cursor.PageCache;
 import org.apache.activemq.artemis.core.paging.cursor.PageCursorProvider;
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@@ -39,10 +42,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContex
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
@@ -147,7 +147,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
       PageSubscription cursorEven = createNonPersistentCursor(new Filter() {
 
          @Override
-         public boolean match(ServerMessage message) {
+         public boolean match(Message message) {
             Boolean property = message.getBooleanProperty("even");
             if (property == null) {
                return false;
@@ -166,7 +166,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
       PageSubscription cursorOdd = createNonPersistentCursor(new Filter() {
 
          @Override
-         public boolean match(ServerMessage message) {
+         public boolean match(Message message) {
             Boolean property = message.getBooleanProperty("even");
             if (property == null) {
                return false;
@@ -382,7 +382,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
 
          ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
 
-         ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+         Message msg = new CoreMessage(i, buffer.writerIndex());
          msg.putIntProperty("key", i);
 
          msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -415,7 +415,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
 
             ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
 
-            ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+            Message msg = new CoreMessage(i, buffer.writerIndex());
             msg.putIntProperty("key", i);
 
             msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -445,7 +445,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
 
             ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
 
-            ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+            Message msg = new CoreMessage(i, buffer.writerIndex());
             msg.putIntProperty("key", i + 1);
 
             msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -530,7 +530,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
                      //System.out.println("Sending " + count);
                      ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, count);
 
-                     ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+                     Message msg = new CoreMessage(i, buffer.writerIndex());
                      msg.putIntProperty("key", count++);
 
                      msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
@@ -666,7 +666,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
 
    }
 
-   private int tstProperty(ServerMessage msg) {
+   private int tstProperty(Message msg) {
       return msg.getIntProperty("key").intValue();
    }
 
@@ -747,7 +747,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
             System.out.println("Paged " + i);
          ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
 
-         ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
+         Message msg = new CoreMessage(i, buffer.writerIndex());
          msg.putIntProperty("key", i);
          // to be used on tests that are validating filters
          msg.putBooleanProperty("even", i % 2 == 0);
@@ -850,7 +850,7 @@ public class PageCursorStressTest extends ActiveMQTestBase {
 
       for (int i = start; i < start + NUM_MESSAGES; i++) {
          ActiveMQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1L);
-         ServerMessage msg = new ServerMessageImpl(storage.generateID(), buffer.writerIndex());
+         Message msg = new CoreMessage(storage.generateID(), buffer.writerIndex());
          msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());
          msg.putIntProperty("key", i);
          pageStore.page(msg, ctx.getTransaction(), ctx.getContextListing(ADDRESS), lock);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
----------------------------------------------------------------------
diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
index 34ce7ac..6d73cfd 100644
--- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
+++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java
@@ -19,12 +19,12 @@ package org.apache.activemq.artemis.tests.timing.core.server.impl;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.HandleStatus;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueConfig;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
 import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
 import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer;
@@ -138,9 +138,9 @@ public class QueueConcurrentTest extends ActiveMQTestBase {
          long start = System.currentTimeMillis();
 
          while (System.currentTimeMillis() - start < testTime) {
-            ServerMessage message = generateMessage(i);
+            Message message = generateMessage(i);
 
-            MessageReference ref = message.createReference(queue);
+            MessageReference ref = MessageReference.Factory.createReference(message, queue);
 
             queue.addTail(ref, false);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/unit-tests/pom.xml b/tests/unit-tests/pom.xml
index 32ca63b..803bf39 100644
--- a/tests/unit-tests/pom.xml
+++ b/tests/unit-tests/pom.xml
@@ -54,6 +54,12 @@
       </dependency>
       <dependency>
          <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-amqp-protocol</artifactId>
+         <version>${project.version}</version>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-jms-server</artifactId>
          <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
index d1536d4..39507aa 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java
@@ -2426,7 +2426,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase {
    }
 
    @Test
-   public void testTransactionChangesNotVisibleOutsideTX() throws Exception {
+   public void testTransactionChangesNotVisibleOutsideTXtestTransactionChangesNotVisibleOutsideTX() throws Exception {
       setup(10, 10 * 1024, true);
       createJournal();
       startJournal();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
index 252b0eb..2e0ffac 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java
@@ -24,8 +24,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.junit.Assert;
@@ -63,7 +63,7 @@ public class MessageImplTest extends ActiveMQTestBase {
          final byte priority2 = RandomUtil.randomByte();
 
          message.setAddress(destination);
-         Assert.assertEquals(destination, message.getAddress());
+         Assert.assertEquals(destination, message.getAddressSimpleString());
 
          message.setDurable(durable2);
          Assert.assertEquals(durable2, message.isDurable());
@@ -232,10 +232,9 @@ public class MessageImplTest extends ActiveMQTestBase {
 
    private void internalMessageCopy() throws Exception {
       final long RUNS = 2;
-      final ServerMessageImpl msg = new ServerMessageImpl(123, 18);
+      final CoreMessage msg = new CoreMessage(123, 18);
 
       msg.setMessageID(RandomUtil.randomLong());
-      msg.encodeMessageIDToBuffer();
       msg.setAddress(new SimpleString("Batatantkashf aksjfh aksfjh askfdjh askjfh "));
 
       final AtomicInteger errors = new AtomicInteger(0);
@@ -257,7 +256,7 @@ public class MessageImplTest extends ActiveMQTestBase {
 
             for (int i = 0; i < RUNS; i++) {
                try {
-                  ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy();
+                  Message newMsg = msg.copy();
                } catch (Throwable e) {
                   e.printStackTrace();
                   errors.incrementAndGet();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
index d6e0f72..37e33ed 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java
@@ -17,23 +17,26 @@
 package org.apache.activemq.artemis.tests.unit.core.paging.impl;
 
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.impl.Page;
 import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 public class PageTest extends ActiveMQTestBase {
@@ -47,6 +50,12 @@ public class PageTest extends ActiveMQTestBase {
 
    // Public --------------------------------------------------------
 
+   @Before
+   public void registerProtocols() {
+      MessagePersister.registerPersister(CoreProtocolManagerFactory.ID, CoreMessagePersister.getInstance());
+      MessagePersister.registerPersister((byte)2, AMQPMessagePersister.getInstance());
+   }
+
    @Test
    public void testPageWithNIO() throws Exception {
       recreateDirectory(getTestDir());
@@ -64,6 +73,11 @@ public class PageTest extends ActiveMQTestBase {
       testAdd(new FakeSequentialFileFactory(1, false), 10);
    }
 
+   @Test
+   public void testAddCore() throws Exception {
+      testAdd(new NIOSequentialFileFactory(getTestDirfile(), 1), 1);
+   }
+
    /**
     * Validate if everything we add is recovered
     */
@@ -89,7 +103,7 @@ public class PageTest extends ActiveMQTestBase {
 
       SimpleString simpleDestination = new SimpleString("Test");
 
-      ArrayList<ActiveMQBuffer> buffers = addPageElements(simpleDestination, impl, numberOfElements);
+      addPageElements(simpleDestination, impl, numberOfElements);
 
       impl.sync();
       impl.close();
@@ -105,9 +119,7 @@ public class PageTest extends ActiveMQTestBase {
       Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());
 
       for (int i = 0; i < msgs.size(); i++) {
-         Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress());
-
-         ActiveMQTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i).getMessage().getBodyBuffer().toByteBuffer().array());
+         Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
       }
 
       impl.delete(null);
@@ -130,7 +142,7 @@ public class PageTest extends ActiveMQTestBase {
 
       SimpleString simpleDestination = new SimpleString("Test");
 
-      ArrayList<ActiveMQBuffer> buffers = addPageElements(simpleDestination, impl, numberOfElements);
+      addPageElements(simpleDestination, impl, numberOfElements);
 
       impl.sync();
 
@@ -170,9 +182,7 @@ public class PageTest extends ActiveMQTestBase {
       Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());
 
       for (int i = 0; i < msgs.size(); i++) {
-         Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress());
-
-         ActiveMQTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i).getMessage().getBodyBuffer().toByteBuffer().array());
+         Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
       }
 
       impl.delete(null);
@@ -190,29 +200,25 @@ public class PageTest extends ActiveMQTestBase {
     * @return
     * @throws Exception
     */
-   protected ArrayList<ActiveMQBuffer> addPageElements(final SimpleString simpleDestination,
+   protected void addPageElements(final SimpleString simpleDestination,
                                                        final Page page,
                                                        final int numberOfElements) throws Exception {
-      ArrayList<ActiveMQBuffer> buffers = new ArrayList<>();
 
       int initialNumberOfMessages = page.getNumberOfMessages();
 
       for (int i = 0; i < numberOfElements; i++) {
-         ServerMessage msg = new ServerMessageImpl(i, 100);
+         Message msg = new CoreMessage().initBuffer(100);
 
          for (int j = 0; j < 10; j++) {
             msg.getBodyBuffer().writeByte((byte) 'b');
          }
 
-         buffers.add(msg.getBodyBuffer());
-
          msg.setAddress(simpleDestination);
 
          page.write(new PagedMessageImpl(msg, new long[0]));
 
          Assert.assertEquals(initialNumberOfMessages + i + 1, page.getNumberOfMessages());
       }
-      return buffers;
    }
 
    // Package protected ---------------------------------------------

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
index 10b9a06..654fd89 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java
@@ -22,7 +22,9 @@ import java.util.List;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.paging.PagingStore;
 import org.apache.activemq.artemis.core.paging.impl.Page;
@@ -30,9 +32,7 @@ import org.apache.activemq.artemis.core.paging.impl.PagingManagerImpl;
 import org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryNIO;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
@@ -63,7 +63,7 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
 
       PagingStore store = managerImpl.getPageStore(new SimpleString("simple-test"));
 
-      ServerMessage msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10));
+      Message msg = createMessage(1L, new SimpleString("simple-test"), createRandomBuffer(10));
 
       final RoutingContextImpl ctx = new RoutingContextImpl(null);
       Assert.assertFalse(store.page(msg, ctx.getTransaction(), ctx.getContextListing(store.getStoreName()), lock));
@@ -82,7 +82,7 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
 
       Assert.assertEquals(1, msgs.size());
 
-      ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), msgs.get(0).getMessage().getBodyBuffer().toByteBuffer().array());
+      ActiveMQTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), (msgs.get(0).getMessage()).getBodyBuffer().toByteBuffer().array());
 
       Assert.assertTrue(store.isPaging());
 
@@ -104,10 +104,10 @@ public class PagingManagerImplTest extends ActiveMQTestBase {
       pageDirDir.mkdirs();
    }
 
-   protected ServerMessage createMessage(final long messageId,
-                                         final SimpleString destination,
-                                         final ByteBuffer buffer) {
-      ServerMessage msg = new ServerMessageImpl(messageId, 200);
+   protected Message createMessage(final long messageId,
+                                   final SimpleString destination,
+                                   final ByteBuffer buffer) {
+      Message msg = new CoreMessage(messageId, 200);
 
       msg.setAddress(destination);
 


[17/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java
index 6aa44a4..125a20f 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import javax.jms.BytesMessage;
 
 import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport;
@@ -33,6 +32,7 @@ import org.apache.activemq.artemis.protocol.amqp.converter.message.InboundTransf
 import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingInboundTransformer;
 import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingOutboundTransformer;
 import org.apache.activemq.artemis.protocol.amqp.converter.message.OutboundTransformer;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
 import org.apache.activemq.artemis.utils.IDGenerator;
@@ -52,8 +52,8 @@ public class ProtonMessageConverter implements MessageConverter {
    private final OutboundTransformer outboundTransformer;
 
    @Override
-   public ServerMessage inbound(Object messageSource) throws Exception {
-      EncodedMessage encodedMessageSource = (EncodedMessage) messageSource;
+   public org.apache.activemq.artemis.api.core.Message inbound(Object messageSource) throws Exception {
+      AMQPMessage encodedMessageSource = (AMQPMessage) messageSource;
       ServerJMSMessage transformedMessage = null;
 
       try {
@@ -67,11 +67,11 @@ public class ProtonMessageConverter implements MessageConverter {
 
       transformedMessage.encode();
 
-      return (ServerMessage) transformedMessage.getInnerMessage();
+      return transformedMessage.getInnerMessage();
    }
 
    @Override
-   public Object outbound(ServerMessage messageOutbound, int deliveryCount) throws Exception {
+   public Object outbound(org.apache.activemq.artemis.api.core.Message messageOutbound, int deliveryCount) throws Exception {
       // Useful for testing but not recommended for real life use.
       ByteBuf nettyBuffer = Unpooled.buffer(1024);
       NettyWritable buffer = new NettyWritable(nettyBuffer);
@@ -83,7 +83,7 @@ public class ProtonMessageConverter implements MessageConverter {
       return encoded;
    }
 
-   public Object outbound(ServerMessage messageOutbound, int deliveryCount, WritableBuffer buffer) throws Exception {
+   public Object outbound(org.apache.activemq.artemis.api.core.Message messageOutbound, int deliveryCount, WritableBuffer buffer) throws Exception {
       ServerJMSMessage jmsMessage = AMQPMessageSupport.wrapMessage(messageOutbound.getType(), messageOutbound, deliveryCount);
 
       jmsMessage.decode();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSBytesMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSBytesMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSBytesMessage.java
index abdf808..c3a60f0 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSBytesMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSBytesMessage.java
@@ -19,8 +19,8 @@ package org.apache.activemq.artemis.protocol.amqp.converter.jms;
 import javax.jms.BytesMessage;
 import javax.jms.JMSException;
 
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 
 import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesMessageReset;
 import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesReadBoolean;
@@ -49,13 +49,13 @@ import static org.apache.activemq.artemis.reader.BytesMessageUtil.bytesWriteUTF;
 
 public class ServerJMSBytesMessage extends ServerJMSMessage implements BytesMessage {
 
-   public ServerJMSBytesMessage(MessageInternal message, int deliveryCount) {
+   public ServerJMSBytesMessage(Message message, int deliveryCount) {
       super(message, deliveryCount);
    }
 
    @Override
    public long getBodyLength() throws JMSException {
-      return message.getEndOfBodyPosition() - MessageImpl.BODY_OFFSET;
+      return message.getEndOfBodyPosition() - CoreMessage.BODY_OFFSET;
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java
index 0268065..df79183 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java
@@ -27,7 +27,6 @@ import java.util.Set;
 import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.utils.TypedProperties;
 
 import static org.apache.activemq.artemis.reader.MapMessageUtil.readBodyMap;
@@ -52,7 +51,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe
    /*
     * This constructor is used to construct messages prior to sending
     */
-   public ServerJMSMapMessage(MessageInternal message, int deliveryCount) {
+   public ServerJMSMapMessage(Message message, int deliveryCount) {
       super(message, deliveryCount);
 
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
index f9a94f5..adf4621 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java
@@ -16,18 +16,17 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.converter.jms;
 
-import java.util.Collections;
-import java.util.Enumeration;
-
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
+import java.util.Collections;
+import java.util.Enumeration;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.reader.MessageUtil;
 
@@ -35,16 +34,16 @@ import static org.apache.activemq.artemis.api.core.FilterConstants.NATIVE_MESSAG
 
 public class ServerJMSMessage implements Message {
 
-   protected final MessageInternal message;
+   protected final CoreMessage message;
 
    protected int deliveryCount;
 
-   public MessageInternal getInnerMessage() {
+   public org.apache.activemq.artemis.api.core.Message getInnerMessage() {
       return message;
    }
 
-   public ServerJMSMessage(MessageInternal message, int deliveryCount) {
-      this.message = message;
+   public ServerJMSMessage(org.apache.activemq.artemis.api.core.Message message, int deliveryCount) {
+      this.message = (CoreMessage)message;
       this.deliveryCount = deliveryCount;
    }
 
@@ -60,7 +59,7 @@ public class ServerJMSMessage implements Message {
    protected ActiveMQBuffer getReadBodyBuffer() {
       if (readBodyBuffer == null) {
          // to avoid clashes between multiple threads
-         readBodyBuffer = message.getBodyBufferDuplicate();
+         readBodyBuffer = message.getReadOnlyBodyBuffer();
       }
       return readBodyBuffer;
    }
@@ -140,7 +139,7 @@ public class ServerJMSMessage implements Message {
 
    @Override
    public final Destination getJMSDestination() throws JMSException {
-      SimpleString sdest = message.getAddress();
+      SimpleString sdest = message.getAddressSimpleString();
 
       if (sdest == null) {
          return null;
@@ -152,7 +151,7 @@ public class ServerJMSMessage implements Message {
    @Override
    public final void setJMSDestination(Destination destination) throws JMSException {
       if (destination == null) {
-         message.setAddress(null);
+         message.setAddress((SimpleString)null);
       } else {
          message.setAddress(((ActiveMQDestination) destination).getSimpleAddress());
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java
index d1eaac6..15b04a9 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java
@@ -22,7 +22,6 @@ import javax.jms.JMSException;
 import javax.jms.ObjectMessage;
 
 import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.qpid.proton.amqp.Binary;
 
 public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMessage {
@@ -31,7 +30,7 @@ public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMe
 
    private Binary payload;
 
-   public ServerJMSObjectMessage(MessageInternal message, int deliveryCount) {
+   public ServerJMSObjectMessage(Message message, int deliveryCount) {
       super(message, deliveryCount);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java
index a53fc0e..b092e61 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java
@@ -23,7 +23,6 @@ import javax.jms.StreamMessage;
 
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.utils.DataConstants;
 
 import static org.apache.activemq.artemis.reader.StreamMessageUtil.streamReadBoolean;
@@ -44,7 +43,7 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St
 
    private int bodyLength = 0;
 
-   public ServerJMSStreamMessage(MessageInternal message, int deliveryCount) {
+   public ServerJMSStreamMessage(Message message, int deliveryCount) {
       super(message, deliveryCount);
    }
 
@@ -180,7 +179,7 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St
    @Override
    public Object readObject() throws JMSException {
 
-      if (getReadBodyBuffer().readerIndex() >= message.getEndOfBodyPosition()) {
+      if (getReadBodyBuffer().readerIndex() >= getReadBodyBuffer().writerIndex()) {
          throw new MessageEOFException("");
       }
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java
index eb88de0..058a3e9 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java
@@ -21,7 +21,6 @@ import javax.jms.TextMessage;
 
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 
 import static org.apache.activemq.artemis.reader.TextMessageUtil.readBodyText;
 import static org.apache.activemq.artemis.reader.TextMessageUtil.writeBodyText;
@@ -49,7 +48,7 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag
    /*
     * This constructor is used to construct messages prior to sending
     */
-   public ServerJMSTextMessage(MessageInternal message, int deliveryCount) {
+   public ServerJMSTextMessage(Message message, int deliveryCount) {
       super(message, deliveryCount);
 
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageSupport.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageSupport.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageSupport.java
index 8c4612d..0a39573 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageSupport.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageSupport.java
@@ -16,24 +16,15 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.converter.message;
 
-import static org.apache.activemq.artemis.api.core.Message.BYTES_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.DEFAULT_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.MAP_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.STREAM_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.TEXT_TYPE;
-
+import javax.jms.Destination;
+import javax.jms.JMSException;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Set;
 
-import javax.jms.Destination;
-import javax.jms.JMSException;
-
 import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage;
@@ -48,6 +39,13 @@ import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.messaging.Data;
 import org.apache.qpid.proton.message.Message;
 
+import static org.apache.activemq.artemis.api.core.Message.BYTES_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.DEFAULT_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.MAP_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.STREAM_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.TEXT_TYPE;
+
 /**
  * Support class containing constant values and static methods that are used to map to / from
  * AMQP Message types being sent or received.
@@ -181,7 +179,7 @@ public final class AMQPMessageSupport {
       }
    }
 
-   public static ServerJMSMessage wrapMessage(int messageType, ServerMessage wrapped, int deliveryCount) {
+   public static ServerJMSMessage wrapMessage(int messageType, org.apache.activemq.artemis.api.core.Message wrapped, int deliveryCount) {
       switch (messageType) {
          case STREAM_TYPE:
             return new ServerJMSStreamMessage(wrapped, deliveryCount);
@@ -267,8 +265,8 @@ public final class AMQPMessageSupport {
       return message;
    }
 
-   private static ServerMessageImpl newMessage(IDGenerator idGenerator, byte messageType) {
-      ServerMessageImpl message = new ServerMessageImpl(idGenerator.generateID(), 512);
+   private static CoreMessage newMessage(IDGenerator idGenerator, byte messageType) {
+      CoreMessage message = new CoreMessage(idGenerator.generateID(), 512);
       message.setType(messageType);
       ((ResetLimitWrappedActiveMQBuffer) message.getBodyBuffer()).setMessage(null);
       return message;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeInboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeInboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeInboundTransformer.java
deleted file mode 100644
index 7028547..0000000
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeInboundTransformer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.protocol.amqp.converter.message;
-
-import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
-import org.apache.activemq.artemis.utils.IDGenerator;
-
-public class AMQPNativeInboundTransformer extends AMQPRawInboundTransformer {
-
-   public AMQPNativeInboundTransformer(IDGenerator idGenerator) {
-      super(idGenerator);
-   }
-
-   @Override
-   public String getTransformerName() {
-      return TRANSFORMER_NATIVE;
-   }
-
-   @Override
-   public InboundTransformer getFallbackTransformer() {
-      return new AMQPRawInboundTransformer(idGenerator);
-   }
-
-   @Override
-   public ServerJMSMessage transform(EncodedMessage amqpMessage) throws Exception {
-      org.apache.qpid.proton.message.Message amqp = amqpMessage.decode();
-
-      return populateMessage(super.transform(amqpMessage), amqp);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPRawInboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPRawInboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPRawInboundTransformer.java
deleted file mode 100644
index 445eaca..0000000
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPRawInboundTransformer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.protocol.amqp.converter.message;
-
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.JMS_AMQP_MESSAGE_FORMAT;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.JMS_AMQP_NATIVE;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.createBytesMessage;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-
-import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
-import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
-import org.apache.activemq.artemis.utils.IDGenerator;
-
-public class AMQPRawInboundTransformer extends InboundTransformer {
-
-   public AMQPRawInboundTransformer(IDGenerator idGenerator) {
-      super(idGenerator);
-   }
-
-   @Override
-   public String getTransformerName() {
-      return TRANSFORMER_RAW;
-   }
-
-   @Override
-   public InboundTransformer getFallbackTransformer() {
-      return null;  // No fallback from full raw transform
-   }
-
-   @Override
-   public ServerJMSMessage transform(EncodedMessage amqpMessage) throws Exception {
-      ServerJMSBytesMessage message = createBytesMessage(idGenerator);
-      message.writeBytes(amqpMessage.getArray(), amqpMessage.getArrayOffset(), amqpMessage.getLength());
-
-      // We cannot decode the message headers to check so err on the side of caution
-      // and mark all messages as persistent.
-      message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
-      message.setJMSPriority(Message.DEFAULT_PRIORITY);
-      message.setJMSTimestamp(System.currentTimeMillis());
-
-      message.setLongProperty(JMS_AMQP_MESSAGE_FORMAT, amqpMessage.getMessageFormat());
-      message.setBooleanProperty(JMS_AMQP_NATIVE, true);
-
-      return message;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
index 1316ab7..cec34ef 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/InboundTransformer.java
@@ -37,6 +37,7 @@ import javax.jms.Message;
 
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerDestination;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.Decimal128;
@@ -65,12 +66,10 @@ public abstract class InboundTransformer {
       this.idGenerator = idGenerator;
    }
 
-   public abstract ServerJMSMessage transform(EncodedMessage amqpMessage) throws Exception;
+   public abstract ServerJMSMessage transform(AMQPMessage amqpMessage) throws Exception;
 
    public abstract String getTransformerName();
 
-   public abstract InboundTransformer getFallbackTransformer();
-
    @SuppressWarnings("unchecked")
    protected ServerJMSMessage populateMessage(ServerJMSMessage jms, org.apache.qpid.proton.message.Message amqp) throws Exception {
       Header header = amqp.getHeader();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java
index 629c499..4c7426e 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformer.java
@@ -48,6 +48,7 @@ import java.util.Map;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.messaging.AmqpSequence;
@@ -67,36 +68,21 @@ public class JMSMappingInboundTransformer extends InboundTransformer {
       return TRANSFORMER_JMS;
    }
 
-   @Override
-   public InboundTransformer getFallbackTransformer() {
-      return new AMQPNativeInboundTransformer(idGenerator);
+
+   public ServerJMSMessage transform(EncodedMessage message) throws Exception {
+      AMQPMessage messageEncode = new AMQPMessage(message.getMessageFormat(), message.getArray(), null);
+      return transform(messageEncode);
    }
 
    @Override
-   public ServerJMSMessage transform(EncodedMessage encodedMessage) throws Exception {
-      ServerJMSMessage transformedMessage = null;
-
-      try {
-         Message amqpMessage = encodedMessage.decode();
-         transformedMessage = createServerMessage(amqpMessage);
-         populateMessage(transformedMessage, amqpMessage);
-      } catch (Exception ex) {
-         InboundTransformer transformer = this.getFallbackTransformer();
-
-         while (transformer != null) {
-            try {
-               transformedMessage = transformer.transform(encodedMessage);
-               break;
-            } catch (Exception e) {
-               transformer = transformer.getFallbackTransformer();
-            }
-         }
-      }
+   public ServerJMSMessage transform(AMQPMessage amqpMessage) throws Exception {
+      ServerJMSMessage transformedMessage = createServerMessage(amqpMessage.getProtonMessage());
+      populateMessage(transformedMessage, amqpMessage.getProtonMessage());
 
       // Regardless of the transformer that finally decoded the message we need to ensure that
       // the AMQP Message Format value is preserved for application on retransmit.
-      if (transformedMessage != null && encodedMessage.getMessageFormat() != 0) {
-         transformedMessage.setLongProperty(JMS_AMQP_MESSAGE_FORMAT, encodedMessage.getMessageFormat());
+      if (transformedMessage != null && amqpMessage.getMessageFormat() != 0) {
+         transformedMessage.setLongProperty(JMS_AMQP_MESSAGE_FORMAT, amqpMessage.getMessageFormat());
       }
 
       return transformedMessage;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
index 7dbc6d4..2ef3122 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformer.java
@@ -64,7 +64,6 @@ import javax.jms.TemporaryTopic;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
@@ -510,7 +509,7 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
          // will be unknown so we check for special cases of messages with special data
          // encoded into the server message body.
          if (orignalEncoding == AMQP_UNKNOWN) {
-            MessageInternal internalMessage = message.getInnerMessage();
+            org.apache.activemq.artemis.api.core.Message internalMessage = message.getInnerMessage();
             int readerIndex = internalMessage.getBodyBuffer().readerIndex();
             try {
                Object s = internalMessage.getBodyBuffer().readNullableSimpleString();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
index 6462315..bac3e7e 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
@@ -134,6 +134,10 @@ public class AMQPConnectionContext extends ProtonInitializable {
       handler.flush();
    }
 
+   public void flush(boolean wait) {
+      handler.flush(wait);
+   }
+
    public void close(ErrorCondition errorCondition) {
       handler.close(errorCondition);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerReceiverContext.java
----------------------------------------------------------------------
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 8341de7..34c2c07 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
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.proton;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.PooledByteBufAllocator;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
@@ -25,7 +23,6 @@ import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPExceptio
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException;
 import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle;
-import org.apache.activemq.artemis.protocol.amqp.util.DeliveryUtil;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.messaging.Rejected;
 import org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy;
@@ -144,26 +141,25 @@ public class ProtonServerReceiverContext extends ProtonInitializable implements
          if (delivery.isPartial()) {
             return;
          }
+         byte[] data = new byte[delivery.getDataLength()];
+         Transaction tx = null;
 
-         ByteBuf buffer = PooledByteBufAllocator.DEFAULT.heapBuffer(10 * 1024);
-         try {
-            synchronized (connection.getLock()) {
-               DeliveryUtil.readDelivery(receiver, buffer);
+         synchronized (connection.getLock()) {
+            receiver.recv(data, 0, data.length);
 
-               receiver.advance();
+            receiver.advance();
+         }
 
-               Transaction tx = null;
-               if (delivery.getRemoteState() instanceof TransactionalState) {
+         if (delivery.getRemoteState() instanceof TransactionalState) {
 
-                  TransactionalState txState = (TransactionalState) delivery.getRemoteState();
-                  tx = this.sessionSPI.getTransaction(txState.getTxnId());
-               }
-               sessionSPI.serverSend(tx, receiver, delivery, address, delivery.getMessageFormat(), buffer);
+            TransactionalState txState = (TransactionalState) delivery.getRemoteState();
+            tx = this.sessionSPI.getTransaction(txState.getTxnId());
+         }
 
-               flow(maxCreditAllocation, minCreditRefresh);
-            }
-         } finally {
-            buffer.release();
+         sessionSPI.serverSend(tx, receiver, delivery, address, delivery.getMessageFormat(), data);
+
+         synchronized (connection.getLock()) {
+            flow(maxCreditAllocation, minCreditRefresh);
          }
       } catch (Exception e) {
          log.warn(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
index 2e19f07..15611c3 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
@@ -23,6 +23,7 @@ import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException;
 import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.postoffice.impl.CompositeAddress;
 import org.apache.activemq.artemis.core.server.AddressQueryResult;
@@ -37,6 +38,7 @@ import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternal
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPNotFoundException;
 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.broker.AMQPMessage;
 import org.apache.activemq.artemis.protocol.amqp.util.CreditsSemaphore;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.activemq.artemis.selector.filter.FilterException;
@@ -474,7 +476,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
       if (closed) {
          return;
       }
-      Object message = delivery.getContext();
+      Message message = (Message)delivery.getContext();
 
       boolean preSettle = sender.getRemoteSenderSettleMode() == SenderSettleMode.SETTLED;
 
@@ -566,7 +568,7 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
    /**
     * handle an out going message from ActiveMQ Artemis, send via the Proton Sender
     */
-   public int deliverMessage(Object message, int deliveryCount) throws Exception {
+   public int deliverMessage(Message message, int deliveryCount) throws Exception {
       if (closed) {
          return 0;
       }
@@ -592,13 +594,18 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr
       try {
          long messageFormat = 0;
 
-         // Encode the Server Message into the given Netty Buffer as an AMQP
-         // Message transformed from the internal message model.
-         try {
-            messageFormat = sessionSPI.encodeMessage(message, deliveryCount, new NettyWritable(nettyBuffer));
-         } catch (Throwable e) {
-            log.warn(e.getMessage(), e);
-            throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e);
+
+         if (message instanceof AMQPMessage) {
+            message.sendBuffer(nettyBuffer, deliveryCount);
+         } else {
+            // Encode the Server Message into the given Netty Buffer as an AMQP
+            // Message transformed from the internal message model.
+            try {
+               messageFormat = sessionSPI.encodeMessage(message, deliveryCount, new NettyWritable(nettyBuffer));
+            } catch (Throwable e) {
+               log.warn(e.getMessage(), e);
+               throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e);
+            }
          }
 
          int size = nettyBuffer.writerIndex();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java
index 51f42a3..1afeba8 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonTransactionHandler.java
@@ -22,6 +22,7 @@ import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
 import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException;
 import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle;
 import org.apache.activemq.artemis.protocol.amqp.util.DeliveryUtil;
+import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.messaging.Accepted;
@@ -61,7 +62,7 @@ public class ProtonTransactionHandler implements ProtonDeliveryHandler {
             return;
          }
 
-         DeliveryUtil.readDelivery(receiver, buffer);
+         receiver.recv(new NettyWritable(buffer));
 
          receiver.advance();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index 25ef51e..673a688 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -254,7 +254,7 @@ public class ProtonHandler extends ProtonInitializable {
       flush(false);
    }
 
-   private void flush(boolean wait) {
+   public void flush(boolean wait) {
       synchronized (lock) {
          transport.process();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
index 9257c6b..0ff1d3b 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/DeliveryUtil.java
@@ -17,24 +17,11 @@
 package org.apache.activemq.artemis.protocol.amqp.util;
 
 import io.netty.buffer.ByteBuf;
-import org.apache.qpid.proton.engine.Receiver;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.message.impl.MessageImpl;
 
 public class DeliveryUtil {
 
-   public static int readDelivery(Receiver receiver, ByteBuf buffer) {
-      int initial = buffer.writerIndex();
-      // optimization by norman
-      int count;
-      while ((count = receiver.recv(buffer.array(), buffer.arrayOffset() + buffer.writerIndex(), buffer.writableBytes())) > 0) {
-         // Increment the writer index by the number of bytes written into it while calling recv.
-         buffer.writerIndex(buffer.writerIndex() + count);
-         buffer.ensureWritable(count);
-      }
-      return buffer.writerIndex() - initial;
-   }
-
    public static MessageImpl decodeMessageImpl(ByteBuf buffer) {
       MessageImpl message = (MessageImpl) Message.Factory.create();
       message.decode(buffer.array(), buffer.arrayOffset() + buffer.readerIndex(), buffer.readableBytes());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
new file mode 100644
index 0000000..e0705b4
--- /dev/null
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.protocol.amqp.util;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.qpid.proton.codec.ReadableBuffer;
+
+public class NettyReadable implements ReadableBuffer {
+
+   private static final Charset Charset_UTF8 = Charset.forName("UTF-8");
+
+   private final ByteBuf buffer;
+
+   public NettyReadable(ByteBuf buffer) {
+      this.buffer = buffer;
+   }
+
+   @Override
+   public void put(ReadableBuffer other) {
+      buffer.writeBytes(other.byteBuffer());
+   }
+
+   @Override
+   public byte get() {
+      return buffer.readByte();
+   }
+
+   @Override
+   public int getInt() {
+      return buffer.readInt();
+   }
+
+   @Override
+   public long getLong() {
+      return buffer.readLong();
+   }
+
+   @Override
+   public short getShort() {
+      return buffer.readShort();
+   }
+
+   @Override
+   public float getFloat() {
+      return buffer.readFloat();
+   }
+
+   @Override
+   public double getDouble() {
+      return buffer.readDouble();
+   }
+
+   @Override
+   public ReadableBuffer get(byte[] data, int offset, int length) {
+      buffer.readBytes(data, offset, length);
+      return this;
+   }
+
+   @Override
+   public ReadableBuffer get(byte[] data) {
+      buffer.readBytes(data);
+      return this;
+   }
+
+   @Override
+   public ReadableBuffer position(int position) {
+      buffer.readerIndex(position);
+      return this;
+   }
+
+   @Override
+   public ReadableBuffer slice() {
+      return new NettyReadable(buffer.slice());
+   }
+
+   @Override
+   public ReadableBuffer flip() {
+      return new NettyReadable(buffer.duplicate().setIndex(0, buffer.readerIndex()));
+   }
+
+   @Override
+   public ReadableBuffer limit(int limit) {
+      buffer.writerIndex(limit);
+      return this;
+   }
+
+   @Override
+   public int limit() {
+      return buffer.writerIndex();
+   }
+
+   @Override
+   public int remaining() {
+      return buffer.readableBytes();
+   }
+
+   @Override
+   public int position() {
+      return buffer.readerIndex();
+   }
+
+   @Override
+   public boolean hasRemaining() {
+      return buffer.readableBytes() > 0;
+   }
+
+   @Override
+   public ReadableBuffer duplicate() {
+      return new NettyReadable(buffer.duplicate());
+   }
+
+   @Override
+   public ByteBuffer byteBuffer() {
+      return buffer.nioBuffer(0, buffer.writerIndex());
+   }
+
+   @Override
+   public String readUTF8() {
+      return buffer.toString(Charset_UTF8);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
index 08c46be..9a333c7 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java
@@ -16,12 +16,6 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.converter;
 
-import static org.apache.activemq.artemis.api.core.Message.BYTES_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.MAP_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.STREAM_TYPE;
-import static org.apache.activemq.artemis.api.core.Message.TEXT_TYPE;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.wrapMessage;
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.HashMap;
@@ -29,10 +23,11 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage;
@@ -52,8 +47,11 @@ import org.apache.qpid.proton.message.impl.MessageImpl;
 import org.junit.Assert;
 import org.junit.Test;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.PooledByteBufAllocator;
+import static org.apache.activemq.artemis.api.core.Message.BYTES_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.MAP_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.STREAM_TYPE;
+import static org.apache.activemq.artemis.api.core.Message.TEXT_TYPE;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.wrapMessage;
 
 public class TestConversions extends Assert {
 
@@ -72,10 +70,10 @@ public class TestConversions extends Assert {
 
       message.setBody(new AmqpValue(new Boolean(true)));
 
-      EncodedMessage encodedMessage = encodeMessage(message);
+      AMQPMessage encodedMessage = new AMQPMessage(message, null);
 
       ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0));
-      ServerMessage serverMessage = converter.inbound(encodedMessage);
+      org.apache.activemq.artemis.api.core.Message serverMessage = converter.inbound(encodedMessage);
 
       verifyProperties(new ServerJMSMessage(serverMessage, 0));
 
@@ -101,10 +99,10 @@ public class TestConversions extends Assert {
 
       message.setBody(new Data(new Binary(bodyBytes)));
 
-      EncodedMessage encodedMessage = encodeMessage(message);
+      AMQPMessage encodedMessage = new AMQPMessage(message, null);
 
       ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0));
-      ServerMessage serverMessage = converter.inbound(encodedMessage);
+      org.apache.activemq.artemis.api.core.Message serverMessage = converter.inbound(encodedMessage);
 
       ServerJMSBytesMessage bytesMessage = (ServerJMSBytesMessage) wrapMessage(BYTES_TYPE, serverMessage, 0);
 
@@ -151,10 +149,10 @@ public class TestConversions extends Assert {
 
       message.setBody(new AmqpValue(mapValues));
 
-      EncodedMessage encodedMessage = encodeMessage(message);
+      AMQPMessage encodedMessage = new AMQPMessage(message, null);
 
       ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0));
-      ServerMessage serverMessage = converter.inbound(encodedMessage);
+      org.apache.activemq.artemis.api.core.Message serverMessage = converter.inbound(encodedMessage);
 
       ServerJMSMapMessage mapMessage = (ServerJMSMapMessage) wrapMessage(MAP_TYPE, serverMessage, 0);
       mapMessage.decode();
@@ -188,12 +186,10 @@ public class TestConversions extends Assert {
 
       message.setBody(new AmqpSequence(objects));
 
-      EncodedMessage encodedMessage = encodeMessage(message);
+      AMQPMessage encodedMessage = new AMQPMessage(message, null);
 
       ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0));
-      ServerMessage serverMessage = converter.inbound(encodedMessage);
-
-      simulatePersistence(serverMessage);
+      org.apache.activemq.artemis.api.core.Message serverMessage = converter.inbound(encodedMessage);
 
       ServerJMSStreamMessage streamMessage = (ServerJMSStreamMessage) wrapMessage(STREAM_TYPE, serverMessage, 0);
 
@@ -222,12 +218,10 @@ public class TestConversions extends Assert {
       String text = "someText";
       message.setBody(new AmqpValue(text));
 
-      EncodedMessage encodedMessage = encodeMessage(message);
+      AMQPMessage encodedMessage = new AMQPMessage(message, null);
 
       ProtonMessageConverter converter = new ProtonMessageConverter(new SimpleIDGenerator(0));
-      ServerMessage serverMessage = converter.inbound(encodedMessage);
-
-      simulatePersistence(serverMessage);
+      org.apache.activemq.artemis.api.core.Message serverMessage = converter.inbound(encodedMessage);
 
       ServerJMSTextMessage textMessage = (ServerJMSTextMessage) wrapMessage(TEXT_TYPE, serverMessage, 0);
       textMessage.decode();
@@ -247,13 +241,6 @@ public class TestConversions extends Assert {
       System.out.println("output = " + amqpMessage);
    }
 
-   private void simulatePersistence(ServerMessage serverMessage) {
-      serverMessage.setAddress(new SimpleString("SomeAddress"));
-      // This is just to simulate what would happen during the persistence of the message
-      // We need to still be able to recover the message when we read it back
-      ((EncodingSupport) serverMessage).encode(new EmptyBuffer());
-   }
-
    private ProtonJMessage reEncodeMsg(Object obj) {
       ProtonJMessage objOut = (ProtonJMessage) obj;
 
@@ -263,14 +250,6 @@ public class TestConversions extends Assert {
       return objOut;
    }
 
-   private EncodedMessage encodeMessage(MessageImpl message) {
-      ByteBuf buf = PooledByteBufAllocator.DEFAULT.heapBuffer(1024 * 1024);
-      message.encode(new NettyWritable(buf));
-      byte[] bytesConvert = new byte[buf.writerIndex()];
-      buf.readBytes(bytesConvert);
-      return new EncodedMessage(0, bytesConvert, 0, bytesConvert.length);
-   }
-
    class EmptyBuffer implements ActiveMQBuffer {
 
       @Override
@@ -770,5 +749,10 @@ public class TestConversions extends Assert {
       public void release() {
          //no-op
       }
+
+      @Override
+      public void writeBytes(ByteBuf src, int srcIndex, int length) {
+
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
index d7a948a..bfaec54 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
@@ -44,6 +44,7 @@ import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessa
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.activemq.artemis.utils.SimpleIDGenerator;
 import org.apache.qpid.proton.Proton;
@@ -82,8 +83,9 @@ public class JMSMappingInboundTransformerTest {
       Message message = Message.Factory.create();
       message.setContentType(AMQPMessageSupport.OCTET_STREAM_CONTENT_TYPE);
 
-      EncodedMessage em = encodeMessage(message);
-      javax.jms.Message jmsMessage = transformer.transform(em);
+      AMQPMessage messageEncode = new AMQPMessage(message, null);
+
+      javax.jms.Message jmsMessage = transformer.transform(messageEncode);
 
       assertNotNull("Message should not be null", jmsMessage);
       assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
index 2ece01d..3fe6d70 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
@@ -16,19 +16,7 @@
  */
 package org.apache.activemq.artemis.protocol.amqp.converter.message;
 
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_DATA;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_NULL;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_SEQUENCE;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_UNKNOWN;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_VALUE_BINARY;
-import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.JMS_AMQP_ORIGINAL_ENCODING;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
+import javax.jms.JMSException;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
@@ -39,10 +27,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import javax.jms.JMSException;
-
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
 import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerDestination;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage;
@@ -64,8 +52,18 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_DATA;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_NULL;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_SEQUENCE;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_UNKNOWN;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.AMQP_VALUE_BINARY;
+import static org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPMessageSupport.JMS_AMQP_ORIGINAL_ENCODING;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 public class JMSMappingOutboundTransformerTest {
 
@@ -943,8 +941,8 @@ public class JMSMappingOutboundTransformerTest {
       }
    }
 
-   private ServerMessageImpl newMessage(byte messageType) {
-      ServerMessageImpl message = new ServerMessageImpl(idGenerator.generateID(), 512);
+   private CoreMessage newMessage(byte messageType) {
+      CoreMessage message = new CoreMessage(idGenerator.generateID(), 512);
       message.setType(messageType);
       ((ResetLimitWrappedActiveMQBuffer) message.getBodyBuffer()).setMessage(null);
       return message;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSTransformationSpeedComparisonTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSTransformationSpeedComparisonTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSTransformationSpeedComparisonTest.java
index 99aab33..fdf0129 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSTransformationSpeedComparisonTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSTransformationSpeedComparisonTest.java
@@ -21,8 +21,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.activemq.artemis.utils.SimpleIDGenerator;
@@ -68,11 +68,11 @@ public class JMSTransformationSpeedComparisonTest {
 
       Message message = Proton.message();
       message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
-      EncodedMessage encoded = encode(message);
+      AMQPMessage encoded = encode(message);
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
 
@@ -80,7 +80,7 @@ public class JMSTransformationSpeedComparisonTest {
 
       long startTime = System.nanoTime();
       for (int i = 0; i < PROFILE_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
       totalDuration += System.nanoTime() - startTime;
@@ -99,11 +99,11 @@ public class JMSTransformationSpeedComparisonTest {
       message.setContentType("text/plain");
       message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
 
-      EncodedMessage encoded = encode(message);
+      AMQPMessage encoded = encode(message);
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
 
@@ -111,7 +111,7 @@ public class JMSTransformationSpeedComparisonTest {
 
       long startTime = System.nanoTime();
       for (int i = 0; i < PROFILE_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
       totalDuration += System.nanoTime() - startTime;
@@ -122,11 +122,11 @@ public class JMSTransformationSpeedComparisonTest {
    @Test
    public void testTypicalQpidJMSMessage() throws Exception {
 
-      EncodedMessage encoded = encode(createTypicalQpidJMSMessage());
+      AMQPMessage encoded = encode(createTypicalQpidJMSMessage());
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
 
@@ -134,7 +134,7 @@ public class JMSTransformationSpeedComparisonTest {
 
       long startTime = System.nanoTime();
       for (int i = 0; i < PROFILE_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
       totalDuration += System.nanoTime() - startTime;
@@ -145,11 +145,11 @@ public class JMSTransformationSpeedComparisonTest {
    @Test
    public void testComplexQpidJMSMessage() throws Exception {
 
-      EncodedMessage encoded = encode(createComplexQpidJMSMessage());
+      AMQPMessage encoded = encode(createComplexQpidJMSMessage());
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
 
@@ -157,7 +157,7 @@ public class JMSTransformationSpeedComparisonTest {
 
       long startTime = System.nanoTime();
       for (int i = 0; i < PROFILE_CYCLES; ++i) {
-         ServerMessage intermediate = converter.inbound(encoded);
+         org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
          encode(converter.outbound(intermediate, 1));
       }
       totalDuration += System.nanoTime() - startTime;
@@ -168,7 +168,7 @@ public class JMSTransformationSpeedComparisonTest {
    @Test
    public void testTypicalQpidJMSMessageInBoundOnly() throws Exception {
 
-      EncodedMessage encoded = encode(createTypicalQpidJMSMessage());
+      AMQPMessage encoded = encode(createTypicalQpidJMSMessage());
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
@@ -190,8 +190,8 @@ public class JMSTransformationSpeedComparisonTest {
    @Test
    public void testTypicalQpidJMSMessageOutBoundOnly() throws Exception {
 
-      EncodedMessage encoded = encode(createTypicalQpidJMSMessage());
-      ServerMessage intermediate = converter.inbound(encoded);
+      AMQPMessage encoded = encode(createTypicalQpidJMSMessage());
+      org.apache.activemq.artemis.api.core.Message intermediate = converter.inbound(encoded);
 
       // Warm up
       for (int i = 0; i < WARM_CYCLES; ++i) {
@@ -278,14 +278,14 @@ public class JMSTransformationSpeedComparisonTest {
       return message;
    }
 
-   private EncodedMessage encode(Object target) {
+   private AMQPMessage encode(Object target) {
       if (target instanceof ProtonJMessage) {
          ProtonJMessage amqp = (ProtonJMessage) target;
 
          ByteBuf nettyBuffer = Unpooled.buffer(1024);
          amqp.encode(new NettyWritable(nettyBuffer));
 
-         return new EncodedMessage(0, nettyBuffer.array(), nettyBuffer.arrayOffset() + nettyBuffer.readerIndex(), nettyBuffer.readableBytes());
+         return new AMQPMessage(0, nettyBuffer.array(), null);
       } else {
          return null;
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
index a5a2168..6a0f20c 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
@@ -26,8 +26,8 @@ import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
 import org.apache.activemq.artemis.utils.IDGenerator;
 import org.apache.activemq.artemis.utils.SimpleIDGenerator;
 import org.apache.qpid.proton.Proton;
@@ -87,7 +87,7 @@ public class MessageTransformationTest {
 
       EncodedMessage encoded = encode(incomingMessage);
 
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(encoded);
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, outbound.getLongProperty("JMSXDeliveryCount").intValue())).decode();
 
       // Test that message details are equal
@@ -128,8 +128,7 @@ public class MessageTransformationTest {
 
       incomingMessage.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
 
-      EncodedMessage encoded = encode(incomingMessage);
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(new AMQPMessage(incomingMessage, null));
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, 1)).decode();
 
       assertNull(outboudMessage.getHeader());
@@ -144,8 +143,7 @@ public class MessageTransformationTest {
       incomingMessage.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
       incomingMessage.setMessageId("ID:SomeQualifier:0:0:1");
 
-      EncodedMessage encoded = encode(incomingMessage);
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(new AMQPMessage(incomingMessage, null));
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, 1)).decode();
 
       assertNull(outboudMessage.getHeader());
@@ -160,8 +158,7 @@ public class MessageTransformationTest {
       incomingMessage.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
       incomingMessage.setDurable(true);
 
-      EncodedMessage encoded = encode(incomingMessage);
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(new AMQPMessage(incomingMessage, null));
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, 1)).decode();
 
       assertNotNull(outboudMessage.getHeader());
@@ -175,8 +172,7 @@ public class MessageTransformationTest {
 
       incomingMessage.setBody(new AmqpValue(new Boolean(true)));
 
-      EncodedMessage encoded = encode(incomingMessage);
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(new AMQPMessage(incomingMessage, null));
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, 1)).decode();
 
       Section section = outboudMessage.getBody();
@@ -233,8 +229,7 @@ public class MessageTransformationTest {
       message.setMessageAnnotations(new MessageAnnotations(messageAnnotations));
       message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
 
-      EncodedMessage encoded = encode(message);
-      ServerMessage outbound = converter.inbound(encoded);
+      org.apache.activemq.artemis.api.core.Message outbound = converter.inbound(new AMQPMessage(message, null));
       Message outboudMessage = ((EncodedMessage) converter.outbound(outbound, 1)).decode();
 
       assertNotNull(outboudMessage.getHeader());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java
new file mode 100644
index 0000000..4313eae
--- /dev/null
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/message/AMQPMessageTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.protocol.amqp.message;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
+import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
+import org.apache.qpid.proton.amqp.messaging.Header;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+import org.apache.qpid.proton.message.Message;
+import org.apache.qpid.proton.message.impl.MessageImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AMQPMessageTest {
+
+   @Test
+   public void testVerySimple() {
+      MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
+      protonMessage.setHeader( new Header());
+      Properties properties = new Properties();
+      properties.setTo("someNiceLocal");
+      protonMessage.setProperties(properties);
+      protonMessage.getHeader().setDeliveryCount(new UnsignedInteger(7));
+      protonMessage.getHeader().setDurable(Boolean.TRUE);
+      protonMessage.setApplicationProperties(new ApplicationProperties(new HashedMap()));
+
+      ByteBuf nettyBuffer = Unpooled.buffer(1500);
+
+      protonMessage.encode(new NettyWritable(nettyBuffer));
+
+      byte[] bytes = new byte[nettyBuffer.writerIndex()];
+
+      nettyBuffer.readBytes(bytes);
+
+      AMQPMessage encode = new AMQPMessage(0, bytes, null);
+
+      Assert.assertEquals(7, encode.getHeader().getDeliveryCount().intValue());
+      Assert.assertEquals(true, encode.getHeader().getDurable());
+      Assert.assertEquals("someNiceLocal", encode.getAddress());
+
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
index f0385dc..e619eb9 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
@@ -28,10 +28,9 @@ import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.io.IOCallback;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 
 /**
@@ -112,19 +111,20 @@ public class MQTTPublishManager {
     * to original ID and consumer in the Session state.  This way we can look up the consumer Id and the message Id from
     * the PubAck or PubRec message id. *
     */
-   protected void sendMessage(ServerMessage message, ServerConsumer consumer, int deliveryCount) throws Exception {
+   protected void sendMessage(CoreMessage message, ServerConsumer consumer, int deliveryCount) throws Exception {
       // This is to allow retries of PubRel.
       if (isManagementConsumer(consumer)) {
          sendPubRelMessage(message);
       } else {
          int qos = decideQoS(message, consumer);
          if (qos == 0) {
-            sendServerMessage((int) message.getMessageID(), (ServerMessageImpl) message, deliveryCount, qos);
+            // TODO-now: fix encoding
+            sendServerMessage((int) message.getMessageID(),  message, deliveryCount, qos);
             session.getServerSession().acknowledge(consumer.getID(), message.getMessageID());
          } else if (qos == 1 || qos == 2) {
             int mqttid = outboundStore.generateMqttId(message.getMessageID(), consumer.getID());
             outboundStore.publish(mqttid, message.getMessageID(), consumer.getID());
-            sendServerMessage(mqttid, (ServerMessageImpl) message, deliveryCount, qos);
+            sendServerMessage(mqttid, message, deliveryCount, qos);
          } else {
             // Client must have disconnected and it's Subscription QoS cleared
             consumer.individualCancel(message.getMessageID(), false);
@@ -149,7 +149,7 @@ public class MQTTPublishManager {
     */
    void sendInternal(int messageId, String topic, int qos, ByteBuf payload, boolean retain, boolean internal) throws Exception {
       synchronized (lock) {
-         ServerMessage serverMessage = MQTTUtil.createServerMessageFromByteBuf(session, topic, retain, qos, payload);
+         Message serverMessage = MQTTUtil.createServerMessageFromByteBuf(session, topic, retain, qos, payload);
 
          if (qos > 0) {
             serverMessage.setDurable(MQTTUtil.DURABLE_MESSAGES);
@@ -181,7 +181,7 @@ public class MQTTPublishManager {
       }
    }
 
-   void sendPubRelMessage(ServerMessage message) {
+   void sendPubRelMessage(Message message) {
       int messageId = message.getIntProperty(MQTTUtil.MQTT_MESSAGE_ID_KEY);
       session.getProtocolHandler().sendPubRel(messageId);
    }
@@ -190,7 +190,7 @@ public class MQTTPublishManager {
       try {
          Pair<Long, Long> ref = outboundStore.publishReceived(messageId);
          if (ref != null) {
-            ServerMessage m = MQTTUtil.createPubRelMessage(session, managementAddress, messageId);
+            Message m = MQTTUtil.createPubRelMessage(session, managementAddress, messageId);
             session.getServerSession().send(m, true);
             session.getServerSession().acknowledge(ref.getB(), ref.getA());
          } else {
@@ -246,7 +246,7 @@ public class MQTTPublishManager {
       }
    }
 
-   private void sendServerMessage(int messageId, ServerMessageImpl message, int deliveryCount, int qos) {
+   private void sendServerMessage(int messageId, CoreMessage message, int deliveryCount, int qos) {
       String address = MQTTUtil.convertCoreAddressFilterToMQTT(message.getAddress().toString(), session.getWildcardConfiguration());
 
       ByteBuf payload;
@@ -262,14 +262,14 @@ public class MQTTPublishManager {
                log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
             }
          default:
-            ActiveMQBuffer bufferDup = message.getBodyBufferDuplicate();
+            ActiveMQBuffer bufferDup = message.getReadOnlyBodyBuffer();
             payload = bufferDup.readBytes(message.getEndOfBodyPosition() - bufferDup.readerIndex()).byteBuf();
             break;
       }
       session.getProtocolHandler().send(messageId, address, qos, payload, deliveryCount);
    }
 
-   private int decideQoS(ServerMessage message, ServerConsumer consumer) {
+   private int decideQoS(Message message, ServerConsumer consumer) {
 
       int subscriptionQoS = -1;
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java
index 596670b..0b52a0b 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTRetainMessageManager.java
@@ -17,12 +17,12 @@
 
 package org.apache.activemq.artemis.core.protocol.mqtt;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
@@ -44,7 +44,7 @@ public class MQTTRetainMessageManager {
     * the subscription queue for the consumer.  When a new retained message is received the message will be sent to
     * the retained queue and the previous retain message consumed to remove it from the queue.
     */
-   void handleRetainedMessage(ServerMessage message, String address, boolean reset, Transaction tx) throws Exception {
+   void handleRetainedMessage(Message message, String address, boolean reset, Transaction tx) throws Exception {
       SimpleString retainAddress = new SimpleString(MQTTUtil.convertMQTTAddressFilterToCoreRetain(address, session.getWildcardConfiguration()));
 
       Queue queue = session.getServer().locateQueue(retainAddress);
@@ -82,7 +82,7 @@ public class MQTTRetainMessageManager {
                Queue retainedQueue = session.getServer().locateQueue(retainedQueueName);
                try (LinkedListIterator<MessageReference> i = retainedQueue.iterator()) {
                   if (i.hasNext()) {
-                     ServerMessage message = i.next().getMessage().copy(session.getServer().getStorageManager().generateID());
+                     Message message = i.next().getMessage().copy(session.getServer().getStorageManager().generateID());
                      sendToQueue(message, queue, tx);
                   }
                }
@@ -95,7 +95,7 @@ public class MQTTRetainMessageManager {
       tx.commit();
    }
 
-   private void sendToQueue(ServerMessage message, Queue queue, Transaction tx) throws Exception {
+   private void sendToQueue(Message message, Queue queue, Transaction tx) throws Exception {
       RoutingContext context = new RoutingContextImpl(tx);
       queue.route(message, context);
       session.getServer().getPostOffice().processRoute(message, context, false);


[07/29] activemq-artemis git commit: Removing Aeroegear

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java
deleted file mode 100644
index 5855abe..0000000
--- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearBundle.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.aerogear;
-
-import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
-import org.jboss.logging.Messages;
-import org.jboss.logging.annotations.Message;
-import org.jboss.logging.annotations.MessageBundle;
-
-/**
- * Logger Code 23
- * <br>
- * each message id must be 6 digits long starting with 10, the 3rd digit should be 9
- * <br>
- * so 239000 to 239999
- */
-@MessageBundle(projectCode = "AMQ")
-public interface ActiveMQAeroGearBundle {
-
-   ActiveMQAeroGearBundle BUNDLE = Messages.getBundle(ActiveMQAeroGearBundle.class);
-
-   @Message(id = 239000, value = "endpoint can not be null")
-   ActiveMQIllegalStateException endpointNull();
-
-   @Message(id = 239001, value = "application-id can not be null")
-   ActiveMQIllegalStateException applicationIdNull();
-
-   @Message(id = 239002, value = "master-secret can not be null")
-   ActiveMQIllegalStateException masterSecretNull();
-
-   @Message(id = 239003, value = "{0}: queue {1} not found", format = Message.Format.MESSAGE_FORMAT)
-   ActiveMQIllegalStateException noQueue(String connectorName, String queueName);
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearLogger.java
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearLogger.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearLogger.java
deleted file mode 100644
index 66c000e..0000000
--- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/ActiveMQAeroGearLogger.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.aerogear;
-
-import org.jboss.logging.BasicLogger;
-import org.jboss.logging.Logger;
-import org.jboss.logging.annotations.LogMessage;
-import org.jboss.logging.annotations.Message;
-import org.jboss.logging.annotations.MessageLogger;
-
-/**
- * Logger Code 23
- *
- * each message id must be 6 digits long starting with 18, the 3rd digit donates the level so
- *
- * INF0  1
- * WARN  2
- * DEBUG 3
- * ERROR 4
- * TRACE 5
- * FATAL 6
- *
- * so an INFO message would be 181000 to 181999
- */
-@MessageLogger(projectCode = "AMQ")
-public interface ActiveMQAeroGearLogger extends BasicLogger {
-
-   /**
-    * The aerogear logger.
-    */
-   ActiveMQAeroGearLogger LOGGER = Logger.getMessageLogger(ActiveMQAeroGearLogger.class, ActiveMQAeroGearLogger.class.getPackage().getName());
-
-   @LogMessage(level = Logger.Level.INFO)
-   @Message(id = 231001, value = "aerogear connector connected to {0}", format = Message.Format.MESSAGE_FORMAT)
-   void connected(String endpoint);
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 232003, value = "removing aerogear connector as credentials are invalid", format = Message.Format.MESSAGE_FORMAT)
-   void reply401();
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 232004, value = "removing aerogear connector as endpoint is invalid", format = Message.Format.MESSAGE_FORMAT)
-   void reply404();
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 232005, value = "removing aerogear connector as unexpected response {0} returned", format = Message.Format.MESSAGE_FORMAT)
-   void replyUnknown(int status);
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 232006, value = "unable to connect to aerogear server, retrying in {0} seconds", format = Message.Format.MESSAGE_FORMAT)
-   void sendFailed(int retry);
-
-   @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 232007, value = "removing aerogear connector unable to connect after {0} attempts, giving up", format = Message.Format.MESSAGE_FORMAT)
-   void unableToReconnect(int retryAttempt);
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java
deleted file mode 100644
index 5191524..0000000
--- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorService.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.aerogear;
-
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
-import org.apache.activemq.artemis.core.postoffice.Binding;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.Consumer;
-import org.apache.activemq.artemis.core.server.HandleStatus;
-import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.utils.ConfigurationHelper;
-import org.jboss.aerogear.unifiedpush.JavaSender;
-import org.jboss.aerogear.unifiedpush.SenderClient;
-import org.jboss.aerogear.unifiedpush.message.MessageResponseCallback;
-import org.jboss.aerogear.unifiedpush.message.UnifiedMessage;
-
-public class AeroGearConnectorService implements ConnectorService, Consumer, MessageResponseCallback {
-
-   private final String connectorName;
-
-   private final PostOffice postOffice;
-
-   private final ScheduledExecutorService scheduledThreadPool;
-
-   private final String queueName;
-
-   private final String endpoint;
-
-   private final String applicationId;
-
-   private final String applicationMasterSecret;
-
-   private final int ttl;
-
-   private final String badge;
-
-   private final String sound;
-
-   private final boolean contentAvailable;
-
-   private final String actionCategory;
-
-   private String[] variants;
-
-   private String[] aliases;
-
-   private String[] deviceTypes;
-
-   private final String filterString;
-
-   private final int retryInterval;
-
-   private final int retryAttempts;
-
-   private Queue queue;
-
-   private Filter filter;
-
-   private volatile boolean handled = false;
-
-   private boolean started = false;
-
-   private boolean reconnecting = false;
-
-   public AeroGearConnectorService(String connectorName,
-                                   Map<String, Object> configuration,
-                                   PostOffice postOffice,
-                                   ScheduledExecutorService scheduledThreadPool) {
-      this.connectorName = connectorName;
-      this.postOffice = postOffice;
-      this.scheduledThreadPool = scheduledThreadPool;
-      this.queueName = ConfigurationHelper.getStringProperty(AeroGearConstants.QUEUE_NAME, null, configuration);
-      this.endpoint = ConfigurationHelper.getStringProperty(AeroGearConstants.ENDPOINT_NAME, null, configuration);
-      this.applicationId = ConfigurationHelper.getStringProperty(AeroGearConstants.APPLICATION_ID_NAME, null, configuration);
-      this.applicationMasterSecret = ConfigurationHelper.getStringProperty(AeroGearConstants.APPLICATION_MASTER_SECRET_NAME, null, configuration);
-      this.ttl = ConfigurationHelper.getIntProperty(AeroGearConstants.TTL_NAME, AeroGearConstants.DEFAULT_TTL, configuration);
-      this.badge = ConfigurationHelper.getStringProperty(AeroGearConstants.BADGE_NAME, null, configuration);
-      this.sound = ConfigurationHelper.getStringProperty(AeroGearConstants.SOUND_NAME, AeroGearConstants.DEFAULT_SOUND, configuration);
-      this.contentAvailable = ConfigurationHelper.getBooleanProperty(AeroGearConstants.CONTENT_AVAILABLE_NAME, false, configuration);
-      this.actionCategory = ConfigurationHelper.getStringProperty(AeroGearConstants.ACTION_CATEGORY_NAME, null, configuration);
-      this.filterString = ConfigurationHelper.getStringProperty(AeroGearConstants.FILTER_NAME, null, configuration);
-      this.retryInterval = ConfigurationHelper.getIntProperty(AeroGearConstants.RETRY_INTERVAL_NAME, AeroGearConstants.DEFAULT_RETRY_INTERVAL, configuration);
-      this.retryAttempts = ConfigurationHelper.getIntProperty(AeroGearConstants.RETRY_ATTEMPTS_NAME, AeroGearConstants.DEFAULT_RETRY_ATTEMPTS, configuration);
-      String variantsString = ConfigurationHelper.getStringProperty(AeroGearConstants.VARIANTS_NAME, null, configuration);
-      if (variantsString != null) {
-         variants = variantsString.split(",");
-      }
-      String aliasesString = ConfigurationHelper.getStringProperty(AeroGearConstants.ALIASES_NAME, null, configuration);
-      if (aliasesString != null) {
-         aliases = aliasesString.split(",");
-      }
-      String deviceTypeString = ConfigurationHelper.getStringProperty(AeroGearConstants.DEVICE_TYPE_NAME, null, configuration);
-      if (deviceTypeString != null) {
-         deviceTypes = deviceTypeString.split(",");
-      }
-   }
-
-   @Override
-   public String getName() {
-      return connectorName;
-   }
-
-   @Override
-   public void start() throws Exception {
-      if (started) {
-         return;
-      }
-      if (filterString != null) {
-         filter = FilterImpl.createFilter(filterString);
-      }
-
-      if (endpoint == null || endpoint.isEmpty()) {
-         throw ActiveMQAeroGearBundle.BUNDLE.endpointNull();
-      }
-      if (applicationId == null || applicationId.isEmpty()) {
-         throw ActiveMQAeroGearBundle.BUNDLE.applicationIdNull();
-      }
-      if (applicationMasterSecret == null || applicationMasterSecret.isEmpty()) {
-         throw ActiveMQAeroGearBundle.BUNDLE.masterSecretNull();
-      }
-
-      Binding b = postOffice.getBinding(new SimpleString(queueName));
-      if (b == null) {
-         throw ActiveMQAeroGearBundle.BUNDLE.noQueue(connectorName, queueName);
-      }
-
-      queue = (Queue) b.getBindable();
-
-      queue.addConsumer(this);
-
-      started = true;
-   }
-
-   @Override
-   public void stop() throws Exception {
-      if (!started) {
-         return;
-      }
-      queue.removeConsumer(this);
-   }
-
-   @Override
-   public boolean isStarted() {
-      return started;
-   }
-
-   @Override
-   public HandleStatus handle(final MessageReference reference) throws Exception {
-      if (reconnecting) {
-         return HandleStatus.BUSY;
-      }
-      ServerMessage message = reference.getMessage();
-
-      if (filter != null && !filter.match(message)) {
-         if (ActiveMQServerLogger.LOGGER.isTraceEnabled()) {
-            ActiveMQServerLogger.LOGGER.trace("Reference " + reference + " is a noMatch on consumer " + this);
-         }
-         return HandleStatus.NO_MATCH;
-      }
-
-      //we only accept if the alert is set
-      if (!message.containsProperty(AeroGearConstants.AEROGEAR_ALERT)) {
-         return HandleStatus.NO_MATCH;
-      }
-
-      String alert = message.getTypedProperties().getProperty(AeroGearConstants.AEROGEAR_ALERT).toString();
-
-      JavaSender sender = new SenderClient.Builder(endpoint).build();
-
-      UnifiedMessage.Builder builder = new UnifiedMessage.Builder();
-
-      builder.pushApplicationId(applicationId).masterSecret(applicationMasterSecret).alert(alert);
-
-      String sound = message.containsProperty(AeroGearConstants.AEROGEAR_SOUND) ? message.getStringProperty(AeroGearConstants.AEROGEAR_SOUND) : this.sound;
-
-      if (sound != null) {
-         builder.sound(sound);
-      }
-
-      String badge = message.containsProperty(AeroGearConstants.AEROGEAR_BADGE) ? message.getStringProperty(AeroGearConstants.AEROGEAR_BADGE) : this.badge;
-
-      if (badge != null) {
-         builder.badge(badge);
-      }
-
-      boolean contentAvailable = message.containsProperty(AeroGearConstants.AEROGEAR_CONTENT_AVAILABLE) ? message.getBooleanProperty(AeroGearConstants.AEROGEAR_CONTENT_AVAILABLE) : this.contentAvailable;
-
-      if (contentAvailable) {
-         builder.contentAvailable();
-      }
-
-      String actionCategory = message.containsProperty(AeroGearConstants.AEROGEAR_ACTION_CATEGORY) ? message.getStringProperty(AeroGearConstants.AEROGEAR_ACTION_CATEGORY) : this.actionCategory;
-
-      if (actionCategory != null) {
-         builder.actionCategory(actionCategory);
-      }
-
-      Integer ttl = message.containsProperty(AeroGearConstants.AEROGEAR_TTL) ? message.getIntProperty(AeroGearConstants.AEROGEAR_TTL) : this.ttl;
-
-      if (ttl != null) {
-         builder.timeToLive(ttl);
-      }
-
-      String variantsString = message.containsProperty(AeroGearConstants.AEROGEAR_VARIANTS) ? message.getStringProperty(AeroGearConstants.AEROGEAR_VARIANTS) : null;
-
-      String[] variants = variantsString != null ? variantsString.split(",") : this.variants;
-
-      if (variants != null) {
-         builder.variants(Arrays.asList(variants));
-      }
-
-      String aliasesString = message.containsProperty(AeroGearConstants.AEROGEAR_ALIASES) ? message.getStringProperty(AeroGearConstants.AEROGEAR_ALIASES) : null;
-
-      String[] aliases = aliasesString != null ? aliasesString.split(",") : this.aliases;
-
-      if (aliases != null) {
-         builder.aliases(Arrays.asList(aliases));
-      }
-
-      String deviceTypesString = message.containsProperty(AeroGearConstants.AEROGEAR_DEVICE_TYPES) ? message.getStringProperty(AeroGearConstants.AEROGEAR_DEVICE_TYPES) : null;
-
-      String[] deviceTypes = deviceTypesString != null ? deviceTypesString.split(",") : this.deviceTypes;
-
-      if (deviceTypes != null) {
-         builder.deviceType(Arrays.asList(deviceTypes));
-      }
-
-      Set<SimpleString> propertyNames = message.getPropertyNames();
-
-      for (SimpleString propertyName : propertyNames) {
-         String nameString = propertyName.toString();
-         if (nameString.startsWith("AEROGEAR_") && !AeroGearConstants.ALLOWABLE_PROPERTIES.contains(nameString)) {
-            Object property = message.getTypedProperties().getProperty(propertyName);
-            builder.attribute(nameString, property.toString());
-         }
-      }
-
-      UnifiedMessage unifiedMessage = builder.build();
-
-      sender.send(unifiedMessage, this);
-
-      if (handled) {
-         reference.acknowledge();
-         return HandleStatus.HANDLED;
-      } else if (!started) {
-         //if we have been stopped we must return no match as we have been removed as a consumer,
-         // anything else will cause an exception
-         return HandleStatus.NO_MATCH;
-      }
-      //we must be reconnecting
-      return HandleStatus.BUSY;
-   }
-
-   @Override
-   public void onComplete(int statusCode) {
-      if (statusCode != 200) {
-         handled = false;
-         if (statusCode == 401) {
-            ActiveMQAeroGearLogger.LOGGER.reply401();
-         } else if (statusCode == 404) {
-            ActiveMQAeroGearLogger.LOGGER.reply404();
-         } else {
-            ActiveMQAeroGearLogger.LOGGER.replyUnknown(statusCode);
-         }
-
-         queue.removeConsumer(this);
-         started = false;
-      } else {
-         handled = true;
-      }
-   }
-
-   @Override
-   public void onError(Throwable throwable) {
-      ActiveMQAeroGearLogger.LOGGER.sendFailed(retryInterval);
-      handled = false;
-      reconnecting = true;
-      scheduledThreadPool.schedule(new ReconnectRunnable(0), retryInterval, TimeUnit.SECONDS);
-   }
-
-   private class ReconnectRunnable implements Runnable {
-
-      private int retryAttempt;
-
-      private ReconnectRunnable(int retryAttempt) {
-         this.retryAttempt = retryAttempt;
-      }
-
-      @Override
-      public void run() {
-         try {
-            HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();
-            conn.connect();
-            reconnecting = false;
-            ActiveMQAeroGearLogger.LOGGER.connected(endpoint);
-            queue.deliverAsync();
-         } catch (Exception e) {
-            retryAttempt++;
-            if (retryAttempts == -1 || retryAttempt < retryAttempts) {
-               scheduledThreadPool.schedule(this, retryInterval, TimeUnit.SECONDS);
-            } else {
-               ActiveMQAeroGearLogger.LOGGER.unableToReconnect(retryAttempt);
-               started = false;
-            }
-         }
-      }
-   }
-
-   @Override
-   public List<MessageReference> getDeliveringMessages() {
-      return Collections.emptyList();
-   }
-
-   @Override
-   public void proceedDeliver(MessageReference reference) throws Exception {
-      //noop
-   }
-
-   @Override
-   public Filter getFilter() {
-      return filter;
-   }
-
-   @Override
-   public String debug() {
-      return "aerogear connected to " + endpoint;
-   }
-
-   @Override
-   public String toManagementString() {
-      return "aerogear connected to " + endpoint;
-   }
-
-   @Override
-   public void disconnect() {
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java
deleted file mode 100644
index 749c87a..0000000
--- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConnectorServiceFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.aerogear;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.activemq.artemis.core.persistence.StorageManager;
-import org.apache.activemq.artemis.core.postoffice.PostOffice;
-import org.apache.activemq.artemis.core.server.ConnectorService;
-import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
-
-public class AeroGearConnectorServiceFactory implements ConnectorServiceFactory {
-
-   @Override
-   public ConnectorService createConnectorService(String connectorName,
-                                                  Map<String, Object> configuration,
-                                                  StorageManager storageManager,
-                                                  PostOffice postOffice,
-                                                  ScheduledExecutorService scheduledThreadPool) {
-      return new AeroGearConnectorService(connectorName, configuration, postOffice, scheduledThreadPool);
-   }
-
-   @Override
-   public Set<String> getAllowableProperties() {
-      return AeroGearConstants.ALLOWABLE_PROPERTIES;
-   }
-
-   @Override
-   public Set<String> getRequiredProperties() {
-      return AeroGearConstants.REQUIRED_PROPERTIES;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java
----------------------------------------------------------------------
diff --git a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java b/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java
deleted file mode 100644
index 07eda77..0000000
--- a/integration/activemq-aerogear-integration/src/main/java/org/apache/activemq/artemis/integration/aerogear/AeroGearConstants.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.integration.aerogear;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-
-public class AeroGearConstants {
-
-   public static final Set<String> ALLOWABLE_PROPERTIES = new HashSet<>();
-   public static final Set<String> REQUIRED_PROPERTIES = new HashSet<>();
-
-   public static final String QUEUE_NAME = "queue";
-   public static final String ENDPOINT_NAME = "endpoint";
-   public static final String APPLICATION_ID_NAME = "application-id";
-   public static final String APPLICATION_MASTER_SECRET_NAME = "master-secret";
-   public static final String TTL_NAME = "ttl";
-   public static final String BADGE_NAME = "badge";
-   public static final String SOUND_NAME = "sound";
-   public static final String CONTENT_AVAILABLE_NAME = "content-available";
-   public static final String ACTION_CATEGORY_NAME = "action-category";
-   public static final String FILTER_NAME = "filter";
-   public static final String RETRY_INTERVAL_NAME = "retry-interval";
-   public static final String RETRY_ATTEMPTS_NAME = "retry-attempts";
-   public static final String VARIANTS_NAME = "variants";
-   public static final String ALIASES_NAME = "aliases";
-   public static final String DEVICE_TYPE_NAME = "device-types";
-
-   public static final SimpleString AEROGEAR_ALERT = new SimpleString("AEROGEAR_ALERT");
-   public static final SimpleString AEROGEAR_SOUND = new SimpleString("AEROGEAR_SOUND");
-   public static final SimpleString AEROGEAR_CONTENT_AVAILABLE = new SimpleString("AEROGEAR_CONTENT_AVAILABLE");
-   public static final SimpleString AEROGEAR_ACTION_CATEGORY = new SimpleString("AEROGEAR_ACTION_CATEGORY");
-   public static final SimpleString AEROGEAR_BADGE = new SimpleString("AEROGEAR_BADGE");
-   public static final SimpleString AEROGEAR_TTL = new SimpleString("AEROGEAR_TTL");
-   public static final SimpleString AEROGEAR_VARIANTS = new SimpleString("AEROGEAR_VARIANTS");
-   public static final SimpleString AEROGEAR_ALIASES = new SimpleString("AEROGEAR_ALIASES");
-   public static final SimpleString AEROGEAR_DEVICE_TYPES = new SimpleString("AEROGEAR_DEVICE_TYPES");
-
-   public static final String DEFAULT_SOUND = "default";
-   public static final Integer DEFAULT_TTL = 3600;
-   public static final int DEFAULT_RETRY_INTERVAL = 5;
-   public static final int DEFAULT_RETRY_ATTEMPTS = 5;
-
-   static {
-      ALLOWABLE_PROPERTIES.add(QUEUE_NAME);
-      ALLOWABLE_PROPERTIES.add(ENDPOINT_NAME);
-      ALLOWABLE_PROPERTIES.add(APPLICATION_ID_NAME);
-      ALLOWABLE_PROPERTIES.add(APPLICATION_MASTER_SECRET_NAME);
-      ALLOWABLE_PROPERTIES.add(TTL_NAME);
-      ALLOWABLE_PROPERTIES.add(BADGE_NAME);
-      ALLOWABLE_PROPERTIES.add(SOUND_NAME);
-      ALLOWABLE_PROPERTIES.add(CONTENT_AVAILABLE_NAME);
-      ALLOWABLE_PROPERTIES.add(ACTION_CATEGORY_NAME);
-      ALLOWABLE_PROPERTIES.add(FILTER_NAME);
-      ALLOWABLE_PROPERTIES.add(RETRY_INTERVAL_NAME);
-      ALLOWABLE_PROPERTIES.add(RETRY_ATTEMPTS_NAME);
-      ALLOWABLE_PROPERTIES.add(VARIANTS_NAME);
-      ALLOWABLE_PROPERTIES.add(ALIASES_NAME);
-      ALLOWABLE_PROPERTIES.add(DEVICE_TYPE_NAME);
-
-      REQUIRED_PROPERTIES.add(QUEUE_NAME);
-      REQUIRED_PROPERTIES.add(ENDPOINT_NAME);
-      REQUIRED_PROPERTIES.add(APPLICATION_ID_NAME);
-      REQUIRED_PROPERTIES.add(APPLICATION_MASTER_SECRET_NAME);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d182bbb..5b056ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,7 +53,6 @@
       <module>artemis-maven-plugin</module>
       <module>artemis-server-osgi</module>
       <module>integration/activemq-spring-integration</module>
-      <module>integration/activemq-aerogear-integration</module>
       <module>artemis-distribution</module>
       <module>artemis-tools</module>
       <module>tests</module>
@@ -734,7 +733,6 @@
             <module>artemis-maven-plugin</module>
             <module>artemis-jdbc-store</module>
             <module>integration/activemq-spring-integration</module>
-            <module>integration/activemq-aerogear-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -769,7 +767,6 @@
             <module>artemis-service-extensions</module>
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
-            <module>integration/activemq-aerogear-integration</module>
             <module>examples</module>
             <module>tests</module>
             <module>artemis-distribution</module>
@@ -827,7 +824,6 @@
             <module>artemis-service-extensions</module>
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
-            <module>integration/activemq-aerogear-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -869,7 +865,6 @@
             <module>artemis-service-extensions</module>
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
-            <module>integration/activemq-aerogear-integration</module>
             <module>tests</module>
          </modules>
          <properties>
@@ -903,7 +898,6 @@
             <module>artemis-service-extensions</module>
             <module>artemis-maven-plugin</module>
             <module>integration/activemq-spring-integration</module>
-            <module>integration/activemq-aerogear-integration</module>
             <module>tests</module>
             <module>examples</module>
          </modules>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index afdaee2..33d82b2 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -177,11 +177,6 @@
       <!-- END MQTT Deps -->
 
       <dependency>
-         <groupId>org.apache.activemq</groupId>
-         <artifactId>artemis-aerogear-integration</artifactId>
-         <version>${project.version}</version>
-      </dependency>
-      <dependency>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
       </dependency>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/02906b56/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
deleted file mode 100644
index 91b6718..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.tests.integration.aerogear;
-
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.artemis.api.core.JsonUtil;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.client.ClientConsumer;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.client.ClientProducer;
-import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
-import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.core.config.Configuration;
-import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
-import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
-import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory;
-import org.apache.activemq.artemis.integration.aerogear.AeroGearConstants;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-
-public class AeroGearBasicServerTest extends ActiveMQTestBase {
-
-   private ActiveMQServer server;
-   private ServerLocator locator;
-   private Server jetty;
-
-   @Override
-   @Before
-   public void setUp() throws Exception {
-      super.setUp();
-      /*
-      * there will be a thread kept alive by the http connection, we could disable the thread check but this means that the tests
-      * interfere with one another, we just have to wait for it to be killed
-      * */
-      jetty = new Server();
-      SelectChannelConnector connector0 = new SelectChannelConnector();
-      connector0.setPort(8080);
-      connector0.setMaxIdleTime(30000);
-      connector0.setHost("localhost");
-      jetty.addConnector(connector0);
-      jetty.start();
-      HashMap<String, Object> params = new HashMap<>();
-      params.put(AeroGearConstants.QUEUE_NAME, "testQueue");
-      params.put(AeroGearConstants.ENDPOINT_NAME, "http://localhost:8080");
-      params.put(AeroGearConstants.APPLICATION_ID_NAME, "9d646a12-e601-4452-9e05-efb0fccdfd08");
-      params.put(AeroGearConstants.APPLICATION_MASTER_SECRET_NAME, "ed75f17e-cf3c-4c9b-a503-865d91d60d40");
-      params.put(AeroGearConstants.RETRY_ATTEMPTS_NAME, 2);
-      params.put(AeroGearConstants.RETRY_INTERVAL_NAME, 1);
-      params.put(AeroGearConstants.BADGE_NAME, "99");
-      params.put(AeroGearConstants.ALIASES_NAME, "me,him,them");
-      params.put(AeroGearConstants.DEVICE_TYPE_NAME, "android,ipad");
-      params.put(AeroGearConstants.SOUND_NAME, "sound1");
-      params.put(AeroGearConstants.VARIANTS_NAME, "variant1,variant2");
-
-      Configuration configuration = createDefaultInVMConfig().addConnectorServiceConfiguration(new ConnectorServiceConfiguration().setFactoryClassName(AeroGearConnectorServiceFactory.class.getName()).setParams(params).setName("TestAeroGearService")).addQueueConfiguration(new CoreQueueConfiguration().setAddress("testQueue").setName("testQueue"));
-
-      server = addServer(createServer(configuration));
-      server.start();
-
-   }
-
-   @Override
-   @After
-   public void tearDown() throws Exception {
-      if (jetty != null) {
-         jetty.stop();
-      }
-      super.tearDown();
-   }
-
-   @Test
-   public void aerogearSimpleReceiveTest() throws Exception {
-      CountDownLatch latch = new CountDownLatch(1);
-      AeroGearHandler aeroGearHandler = new AeroGearHandler(latch);
-      jetty.addHandler(aeroGearHandler);
-      locator = createInVMNonHALocator();
-      ClientSessionFactory sf = createSessionFactory(locator);
-      ClientSession session = sf.createSession(false, true, true);
-      ClientProducer producer = session.createProducer("testQueue");
-      ClientMessage m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "hello from ActiveMQ!");
-      m.putStringProperty("AEROGEAR_PROP1", "prop1");
-      m.putBooleanProperty("AEROGEAR_PROP2", true);
-
-      producer.send(m);
-
-      assertTrue(latch.await(5, TimeUnit.SECONDS));
-      assertNotNull(aeroGearHandler.jsonObject);
-      JsonObject body = aeroGearHandler.jsonObject.getJsonObject("message");
-      assertNotNull(body);
-      String prop1 = body.getString("AEROGEAR_PROP1");
-      assertNotNull(prop1);
-      assertEquals(prop1, "prop1");
-      prop1 = body.getString("AEROGEAR_PROP2");
-      assertNotNull(prop1);
-      assertEquals(prop1, "true");
-      String alert = body.getString("alert");
-      assertNotNull(alert);
-      assertEquals(alert, "hello from ActiveMQ!");
-      String sound = body.getString("sound");
-      assertNotNull(sound);
-      assertEquals(sound, "sound1");
-      int badge = body.getInt("badge");
-      assertNotNull(badge);
-      assertEquals(badge, 99);
-      JsonArray jsonArray = aeroGearHandler.jsonObject.getJsonArray("variants");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "variant1");
-      assertEquals(jsonArray.getString(1), "variant2");
-      jsonArray = aeroGearHandler.jsonObject.getJsonArray("alias");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "me");
-      assertEquals(jsonArray.getString(1), "him");
-      assertEquals(jsonArray.getString(2), "them");
-      jsonArray = aeroGearHandler.jsonObject.getJsonArray("deviceType");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "android");
-      assertEquals(jsonArray.getString(1), "ipad");
-      int ttl = aeroGearHandler.jsonObject.getInt("ttl");
-      assertEquals(ttl, 3600);
-      latch = new CountDownLatch(1);
-      aeroGearHandler.resetLatch(latch);
-
-      //now override the properties
-      m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "another hello from ActiveMQ!");
-      m.putStringProperty(AeroGearConstants.AEROGEAR_BADGE.toString(), "111");
-      m.putStringProperty(AeroGearConstants.AEROGEAR_SOUND.toString(), "s1");
-      m.putIntProperty(AeroGearConstants.AEROGEAR_TTL.toString(), 10000);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALIASES.toString(), "alias1,alias2");
-      m.putStringProperty(AeroGearConstants.AEROGEAR_DEVICE_TYPES.toString(), "dev1,dev2");
-      m.putStringProperty(AeroGearConstants.AEROGEAR_VARIANTS.toString(), "v1,v2");
-
-      producer.send(m);
-      assertTrue(latch.await(5, TimeUnit.SECONDS));
-      assertNotNull(aeroGearHandler.jsonObject);
-      body = aeroGearHandler.jsonObject.getJsonObject("message");
-      assertNotNull(body);
-      alert = body.getString("alert");
-      assertNotNull(alert);
-      assertEquals(alert, "another hello from ActiveMQ!");
-      sound = body.getString("sound");
-      assertNotNull(sound);
-      assertEquals(sound, "s1");
-      badge = body.getInt("badge");
-      assertEquals(badge, 111);
-      jsonArray = aeroGearHandler.jsonObject.getJsonArray("variants");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "v1");
-      assertEquals(jsonArray.getString(1), "v2");
-      jsonArray = aeroGearHandler.jsonObject.getJsonArray("alias");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "alias1");
-      assertEquals(jsonArray.getString(1), "alias2");
-      jsonArray = aeroGearHandler.jsonObject.getJsonArray("deviceType");
-      assertNotNull(jsonArray);
-      assertEquals(jsonArray.getString(0), "dev1");
-      assertEquals(jsonArray.getString(1), "dev2");
-      ttl = aeroGearHandler.jsonObject.getInt("ttl");
-      assertEquals(ttl, 10000);
-      session.start();
-      ClientMessage message = session.createConsumer("testQueue").receiveImmediate();
-      assertNull(message);
-   }
-
-   class AeroGearHandler extends AbstractHandler {
-
-      JsonObject jsonObject;
-      private CountDownLatch latch;
-
-      AeroGearHandler(CountDownLatch latch) {
-         this.latch = latch;
-      }
-
-      @Override
-      public void handle(String target,
-                         HttpServletRequest httpServletRequest,
-                         HttpServletResponse httpServletResponse,
-                         int i) throws IOException, ServletException {
-         Request request = (Request) httpServletRequest;
-         httpServletResponse.setContentType("text/html");
-         httpServletResponse.setStatus(HttpServletResponse.SC_OK);
-         request.setHandled(true);
-         byte[] bytes = new byte[httpServletRequest.getContentLength()];
-         httpServletRequest.getInputStream().read(bytes);
-         String json = new String(bytes);
-         jsonObject = JsonUtil.readJsonObject(json);
-         latch.countDown();
-      }
-
-      public void resetLatch(CountDownLatch latch) {
-         this.latch = latch;
-      }
-   }
-
-   @Test
-   public void aerogearReconnectTest() throws Exception {
-      jetty.stop();
-      final CountDownLatch reconnectLatch = new CountDownLatch(1);
-      jetty.addHandler(new AbstractHandler() {
-         @Override
-         public void handle(String target,
-                            HttpServletRequest httpServletRequest,
-                            HttpServletResponse httpServletResponse,
-                            int i) throws IOException, ServletException {
-            Request request = (Request) httpServletRequest;
-            httpServletResponse.setContentType("text/html");
-            httpServletResponse.setStatus(HttpServletResponse.SC_OK);
-            request.setHandled(true);
-            reconnectLatch.countDown();
-         }
-
-      });
-      locator = createInVMNonHALocator();
-      ClientSessionFactory sf = createSessionFactory(locator);
-      ClientSession session = sf.createSession(false, true, true);
-      ClientProducer producer = session.createProducer("testQueue");
-      final CountDownLatch latch = new CountDownLatch(2);
-      ClientMessage m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "hello from ActiveMQ!");
-
-      producer.send(m, new SendAcknowledgementHandler() {
-         @Override
-         public void sendAcknowledged(Message message) {
-            latch.countDown();
-         }
-      });
-      m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "another hello from ActiveMQ!");
-
-      producer.send(m, new SendAcknowledgementHandler() {
-         @Override
-         public void sendAcknowledged(Message message) {
-            latch.countDown();
-         }
-      });
-      latch.await(5, TimeUnit.SECONDS);
-      Thread.sleep(1000);
-      jetty.start();
-      reconnectLatch.await(5, TimeUnit.SECONDS);
-      session.start();
-      ClientMessage message = session.createConsumer("testQueue").receiveImmediate();
-      assertNull(message);
-   }
-
-   @Test
-   public void aerogear401() throws Exception {
-      final CountDownLatch latch = new CountDownLatch(1);
-      jetty.addHandler(new AbstractHandler() {
-         @Override
-         public void handle(String target,
-                            HttpServletRequest httpServletRequest,
-                            HttpServletResponse httpServletResponse,
-                            int i) throws IOException, ServletException {
-            Request request = (Request) httpServletRequest;
-            httpServletResponse.setContentType("text/html");
-            httpServletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
-            request.setHandled(true);
-            latch.countDown();
-         }
-
-      });
-      locator = createInVMNonHALocator();
-      ClientSessionFactory sf = createSessionFactory(locator);
-      ClientSession session = sf.createSession(false, true, true);
-      ClientProducer producer = session.createProducer("testQueue");
-      ClientMessage m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "hello from ActiveMQ!");
-
-      producer.send(m);
-      m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "another hello from ActiveMQ!");
-
-      producer.send(m);
-      assertTrue(latch.await(5, TimeUnit.SECONDS));
-      session.start();
-      ClientConsumer consumer = session.createConsumer("testQueue");
-      ClientMessage message = consumer.receive(5000);
-      assertNotNull(message);
-      message = consumer.receive(5000);
-      assertNotNull(message);
-   }
-
-   @Test
-   public void aerogear404() throws Exception {
-      jetty.addHandler(new AbstractHandler() {
-         @Override
-         public void handle(String target,
-                            HttpServletRequest httpServletRequest,
-                            HttpServletResponse httpServletResponse,
-                            int i) throws IOException, ServletException {
-            Request request = (Request) httpServletRequest;
-            httpServletResponse.setContentType("text/html");
-            httpServletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
-            request.setHandled(true);
-         }
-
-      });
-      locator = createInVMNonHALocator();
-      ClientSessionFactory sf = createSessionFactory(locator);
-      ClientSession session = sf.createSession(false, true, true);
-      ClientProducer producer = session.createProducer("testQueue");
-      ClientMessage m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "hello from ActiveMQ!");
-
-      producer.send(m);
-      m = session.createMessage(true);
-      m.putStringProperty(AeroGearConstants.AEROGEAR_ALERT.toString(), "another hello from ActiveMQ!");
-
-      producer.send(m);
-      session.start();
-      ClientConsumer consumer = session.createConsumer("testQueue");
-      ClientMessage message = consumer.receive(5000);
-      assertNotNull(message);
-      message = consumer.receive(5000);
-      assertNotNull(message);
-   }
-}


[19/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java
deleted file mode 100644
index f93086c..0000000
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageImpl.java
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.message.impl;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
-import org.apache.activemq.artemis.api.core.ActiveMQException;
-import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
-import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
-import org.apache.activemq.artemis.utils.ByteUtil;
-import org.apache.activemq.artemis.utils.DataConstants;
-import org.apache.activemq.artemis.utils.TypedProperties;
-import org.apache.activemq.artemis.utils.UUID;
-
-/**
- * A concrete implementation of a message
- * <p>
- * All messages handled by ActiveMQ Artemis core are of this type
- */
-public abstract class MessageImpl implements MessageInternal {
-
-   public static final SimpleString HDR_ROUTE_TO_IDS = new SimpleString("_AMQ_ROUTE_TO");
-
-   public static final SimpleString HDR_SCALEDOWN_TO_IDS = new SimpleString("_AMQ_SCALEDOWN_TO");
-
-   public static final SimpleString HDR_ROUTE_TO_ACK_IDS = new SimpleString("_AMQ_ACK_ROUTE_TO");
-
-   // used by the bridges to set duplicates
-   public static final SimpleString HDR_BRIDGE_DUPLICATE_ID = new SimpleString("_AMQ_BRIDGE_DUP");
-
-   public static final int BUFFER_HEADER_SPACE = PacketImpl.PACKET_HEADERS_SIZE;
-
-   public static final int BODY_OFFSET = BUFFER_HEADER_SPACE + DataConstants.SIZE_INT;
-
-   protected long messageID;
-
-   protected SimpleString address;
-
-   protected byte type;
-
-   protected boolean durable;
-
-   /**
-    * GMT milliseconds at which this message expires. 0 means never expires *
-    */
-   private long expiration;
-
-   protected long timestamp;
-
-   protected TypedProperties properties;
-
-   protected byte priority;
-
-   protected volatile ActiveMQBuffer buffer;
-
-   protected volatile ResetLimitWrappedActiveMQBuffer bodyBuffer;
-
-   protected volatile boolean bufferValid;
-
-   private int endOfBodyPosition = -1;
-
-   private int endOfMessagePosition;
-
-   private UUID userID;
-
-   // Constructors --------------------------------------------------
-
-   protected MessageImpl() {
-      properties = new TypedProperties();
-   }
-
-   /**
-    * overridden by the client message, we need access to the connection so we can create the appropriate ActiveMQBuffer.
-    *
-    * @param type
-    * @param durable
-    * @param expiration
-    * @param timestamp
-    * @param priority
-    * @param initialMessageBufferSize
-    */
-   protected MessageImpl(final byte type,
-                         final boolean durable,
-                         final long expiration,
-                         final long timestamp,
-                         final byte priority,
-                         final int initialMessageBufferSize) {
-      this();
-      this.type = type;
-      this.durable = durable;
-      this.expiration = expiration;
-      this.timestamp = timestamp;
-      this.priority = priority;
-      createBody(initialMessageBufferSize);
-   }
-
-   protected MessageImpl(final int initialMessageBufferSize) {
-      this();
-      createBody(initialMessageBufferSize);
-   }
-
-   /*
-    * Copy constructor
-    */
-   protected MessageImpl(final MessageImpl other) {
-      this(other, other.getProperties());
-   }
-
-   /*
-    * Copy constructor
-    */
-   protected MessageImpl(final MessageImpl other, TypedProperties properties) {
-      messageID = other.getMessageID();
-      userID = other.getUserID();
-      address = other.getAddress();
-      type = other.getType();
-      durable = other.isDurable();
-      expiration = other.getExpiration();
-      timestamp = other.getTimestamp();
-      priority = other.getPriority();
-      this.properties = new TypedProperties(properties);
-
-      // This MUST be synchronized using the monitor on the other message to prevent it running concurrently
-      // with getEncodedBuffer(), otherwise can introduce race condition when delivering concurrently to
-      // many subscriptions and bridging to other nodes in a cluster
-      synchronized (other) {
-         bufferValid = false;
-         endOfBodyPosition = -1;
-         endOfMessagePosition = other.endOfMessagePosition;
-
-         if (other.buffer != null) {
-            // We need to copy the underlying buffer too, since the different messsages thereafter might have different
-            // properties set on them, making their encoding different
-            buffer = other.buffer.copy(0, other.buffer.capacity());
-
-            buffer.setIndex(other.buffer.readerIndex(), buffer.capacity());
-
-            bodyBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer, this);
-
-            bodyBuffer.readerIndex(BODY_OFFSET);
-            bodyBuffer.writerIndex(other.getBodyBuffer().writerIndex());
-            endOfBodyPosition = other.endOfBodyPosition;
-         }
-      }
-   }
-
-   // Message implementation ----------------------------------------
-
-   @Override
-   public int getEncodeSize() {
-      int headersPropsSize = getHeadersAndPropertiesEncodeSize();
-
-      int bodyPos = getEndOfBodyPosition();
-
-      int bodySize = bodyPos - BUFFER_HEADER_SPACE - DataConstants.SIZE_INT;
-
-      return DataConstants.SIZE_INT + bodySize + DataConstants.SIZE_INT + headersPropsSize;
-   }
-
-   @Override
-   public int getHeadersAndPropertiesEncodeSize() {
-      return DataConstants.SIZE_LONG + // Message ID
-         DataConstants.SIZE_BYTE + // user id null?
-         (userID == null ? 0 : 16) +
-             /* address */SimpleString.sizeofNullableString(address) +
-         DataConstants./* Type */SIZE_BYTE +
-         DataConstants./* Durable */SIZE_BOOLEAN +
-         DataConstants./* Expiration */SIZE_LONG +
-         DataConstants./* Timestamp */SIZE_LONG +
-         DataConstants./* Priority */SIZE_BYTE +
-             /* PropertySize and Properties */properties.getEncodeSize();
-   }
-
-   @Override
-   public void encodeHeadersAndProperties(final ActiveMQBuffer buffer) {
-      buffer.writeLong(messageID);
-      buffer.writeNullableSimpleString(address);
-      if (userID == null) {
-         buffer.writeByte(DataConstants.NULL);
-      } else {
-         buffer.writeByte(DataConstants.NOT_NULL);
-         buffer.writeBytes(userID.asBytes());
-      }
-      buffer.writeByte(type);
-      buffer.writeBoolean(durable);
-      buffer.writeLong(expiration);
-      buffer.writeLong(timestamp);
-      buffer.writeByte(priority);
-      properties.encode(buffer);
-   }
-
-   @Override
-   public void decodeHeadersAndProperties(final ActiveMQBuffer buffer) {
-      messageID = buffer.readLong();
-      address = buffer.readNullableSimpleString();
-      if (buffer.readByte() == DataConstants.NOT_NULL) {
-         byte[] bytes = new byte[16];
-         buffer.readBytes(bytes);
-         userID = new UUID(UUID.TYPE_TIME_BASED, bytes);
-      } else {
-         userID = null;
-      }
-      type = buffer.readByte();
-      durable = buffer.readBoolean();
-      expiration = buffer.readLong();
-      timestamp = buffer.readLong();
-      priority = buffer.readByte();
-      properties.decode(buffer);
-   }
-
-   public void copyHeadersAndProperties(final MessageInternal msg) {
-      messageID = msg.getMessageID();
-      address = msg.getAddress();
-      userID = msg.getUserID();
-      type = msg.getType();
-      durable = msg.isDurable();
-      expiration = msg.getExpiration();
-      timestamp = msg.getTimestamp();
-      priority = msg.getPriority();
-      properties = msg.getTypedProperties();
-   }
-
-   @Override
-   public ActiveMQBuffer getBodyBuffer() {
-      if (bodyBuffer == null) {
-         bodyBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer, this);
-      }
-
-      return bodyBuffer;
-   }
-
-   @Override
-   public Message writeBodyBufferBytes(byte[] bytes) {
-      getBodyBuffer().writeBytes(bytes);
-
-      return this;
-   }
-
-   @Override
-   public Message writeBodyBufferString(String string) {
-      getBodyBuffer().writeString(string);
-
-      return this;
-   }
-
-   public void checkCompletion() throws ActiveMQException {
-      // no op on regular messages
-   }
-
-   @Override
-   public synchronized ActiveMQBuffer getBodyBufferDuplicate() {
-
-      // Must copy buffer before sending it
-
-      ByteBuf byteBuf = ChannelBufferWrapper.unwrap(getBodyBuffer().byteBuf());
-      byteBuf = byteBuf.duplicate();
-      byteBuf.readerIndex(getBodyBuffer().readerIndex());
-      byteBuf.writerIndex(getBodyBuffer().writerIndex());
-
-      return new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, byteBuf, null);
-   }
-
-   @Override
-   public long getMessageID() {
-      return messageID;
-   }
-
-   @Override
-   public UUID getUserID() {
-      return userID;
-   }
-
-   @Override
-   public MessageImpl setUserID(final UUID userID) {
-      this.userID = userID;
-      return this;
-   }
-
-   /**
-    * this doesn't need to be synchronized as setAddress is protecting the buffer,
-    * not the address
-    */
-   @Override
-   public SimpleString getAddress() {
-      return address;
-   }
-
-   /**
-    * The only reason this is synchronized is because of encoding a message versus invalidating the buffer.
-    * This synchronization can probably be removed since setAddress is always called from a single thread.
-    * However I will keep it as it's harmless and it's been well tested
-    */
-   @Override
-   public Message setAddress(final SimpleString address) {
-      // This is protecting the buffer
-      synchronized (this) {
-         if (this.address != address) {
-            this.address = address;
-
-            bufferValid = false;
-         }
-      }
-
-      return this;
-   }
-
-   @Override
-   public byte getType() {
-      return type;
-   }
-
-   public void setType(byte type) {
-      this.type = type;
-   }
-
-   @Override
-   public boolean isDurable() {
-      return durable;
-   }
-
-   @Override
-   public MessageImpl setDurable(final boolean durable) {
-      if (this.durable != durable) {
-         this.durable = durable;
-
-         bufferValid = false;
-      }
-      return this;
-   }
-
-   @Override
-   public long getExpiration() {
-      return expiration;
-   }
-
-   @Override
-   public MessageImpl setExpiration(final long expiration) {
-      if (this.expiration != expiration) {
-         this.expiration = expiration;
-
-         bufferValid = false;
-      }
-      return this;
-   }
-
-   @Override
-   public long getTimestamp() {
-      return timestamp;
-   }
-
-   @Override
-   public MessageImpl setTimestamp(final long timestamp) {
-      if (this.timestamp != timestamp) {
-         this.timestamp = timestamp;
-
-         bufferValid = false;
-      }
-      return this;
-   }
-
-   @Override
-   public byte getPriority() {
-      return priority;
-   }
-
-   @Override
-   public MessageImpl setPriority(final byte priority) {
-      if (this.priority != priority) {
-         this.priority = priority;
-
-         bufferValid = false;
-      }
-      return this;
-   }
-
-   @Override
-   public boolean isExpired() {
-      if (expiration == 0) {
-         return false;
-      }
-
-      return System.currentTimeMillis() - expiration >= 0;
-   }
-
-   @Override
-   public Map<String, Object> toMap() {
-      Map<String, Object> map = new HashMap<>();
-
-      map.put("messageID", messageID);
-      if (userID != null) {
-         map.put("userID", "ID:" + userID.toString());
-      }
-      map.put("address", address.toString());
-      map.put("type", type);
-      map.put("durable", durable);
-      map.put("expiration", expiration);
-      map.put("timestamp", timestamp);
-      map.put("priority", priority);
-      map.putAll(toPropertyMap());
-      return map;
-   }
-
-   @Override
-   public Map<String, Object> toPropertyMap() {
-      Map<String, Object> map = new HashMap<>();
-      for (SimpleString propName : properties.getPropertyNames()) {
-         map.put(propName.toString(), properties.getProperty(propName));
-      }
-      return map;
-   }
-
-   @Override
-   public void decodeFromBuffer(final ActiveMQBuffer buffer) {
-
-      this.buffer = copyMessageBuffer(buffer);
-
-      decode();
-
-      //synchronize indexes
-      buffer.setIndex(this.buffer.readerIndex(),this.buffer.writerIndex());
-
-      // Setting up the BodyBuffer based on endOfBodyPosition set from decode
-      ResetLimitWrappedActiveMQBuffer tmpbodyBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, this.buffer, null);
-      tmpbodyBuffer.readerIndex(BODY_OFFSET);
-      tmpbodyBuffer.writerIndex(endOfBodyPosition);
-      // only set this after the writer and reader is set,
-      // otherwise the buffer would be reset through the listener
-      tmpbodyBuffer.setMessage(this);
-      this.bodyBuffer = tmpbodyBuffer;
-
-   }
-
-   private ActiveMQBuffer copyMessageBuffer(ActiveMQBuffer buffer) {
-      ActiveMQBuffer copiedBuffer;
-
-      ByteBuf newNettyBuffer = Unpooled.buffer( buffer.byteBuf().capacity() );
-
-      int read = buffer.byteBuf().readerIndex();
-      int writ = buffer.byteBuf().writerIndex();
-
-      int readArt = buffer.readerIndex();
-      int writArt = buffer.writerIndex();
-      buffer.byteBuf().readerIndex( 0 );
-
-      buffer.byteBuf().readBytes( newNettyBuffer, 0, buffer.byteBuf().writerIndex() );
-      buffer.byteBuf().setIndex( read, writ );
-      newNettyBuffer.setIndex( read, writ );
-
-      copiedBuffer = new ChannelBufferWrapper( newNettyBuffer );
-
-      buffer.setIndex( readArt, writArt );
-      copiedBuffer.setIndex( readArt, writArt );
-
-      return copiedBuffer;
-   }
-
-   @Override
-   public void bodyChanged() {
-      bufferValid = false;
-
-      endOfBodyPosition = -1;
-   }
-
-   @Override
-   public int getEndOfMessagePosition() {
-      return endOfMessagePosition;
-   }
-
-   @Override
-   public int getEndOfBodyPosition() {
-      if (endOfBodyPosition < 0) {
-         endOfBodyPosition = getBodyBuffer().writerIndex();
-      }
-      return endOfBodyPosition;
-   }
-
-   // Encode to journal or paging
-   public void encode(final ActiveMQBuffer buff) {
-      encodeToBuffer();
-
-      buff.writeBytes(buffer, BUFFER_HEADER_SPACE, endOfMessagePosition - BUFFER_HEADER_SPACE);
-   }
-
-   // Decode from journal or paging
-   public void decode(final ActiveMQBuffer buff) {
-      int start = buff.readerIndex();
-
-      endOfBodyPosition = buff.readInt();
-
-      endOfMessagePosition = buff.getInt(endOfBodyPosition - BUFFER_HEADER_SPACE + start);
-
-      int length = endOfMessagePosition - BUFFER_HEADER_SPACE;
-
-      buffer.setIndex(0, BUFFER_HEADER_SPACE);
-
-      buffer.writeBytes(buff, start, length);
-
-      decode();
-
-      buff.readerIndex(start + length);
-   }
-
-   @Override
-   public synchronized ActiveMQBuffer getEncodedBuffer() {
-      ActiveMQBuffer buff = encodeToBuffer();
-      return buff.duplicate();
-   }
-
-   @Override
-   public void setAddressTransient(final SimpleString address) {
-      this.address = address;
-   }
-
-   // Properties
-   // ---------------------------------------------------------------------------------------
-
-   @Override
-   public Message putBooleanProperty(final SimpleString key, final boolean value) {
-      properties.putBooleanProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putByteProperty(final SimpleString key, final byte value) {
-      properties.putByteProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putBytesProperty(final SimpleString key, final byte[] value) {
-      properties.putBytesProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putCharProperty(SimpleString key, char value) {
-      properties.putCharProperty(key, value);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putCharProperty(String key, char value) {
-      properties.putCharProperty(new SimpleString(key), value);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putShortProperty(final SimpleString key, final short value) {
-      properties.putShortProperty(key, value);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putIntProperty(final SimpleString key, final int value) {
-      properties.putIntProperty(key, value);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putLongProperty(final SimpleString key, final long value) {
-      properties.putLongProperty(key, value);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putFloatProperty(final SimpleString key, final float value) {
-      properties.putFloatProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putDoubleProperty(final SimpleString key, final double value) {
-      properties.putDoubleProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putStringProperty(final SimpleString key, final SimpleString value) {
-      properties.putSimpleStringProperty(key, value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putObjectProperty(final SimpleString key,
-                                    final Object value) throws ActiveMQPropertyConversionException {
-      TypedProperties.setObjectProperty(key, value, properties);
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putObjectProperty(final String key, final Object value) throws ActiveMQPropertyConversionException {
-      putObjectProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putBooleanProperty(final String key, final boolean value) {
-      properties.putBooleanProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putByteProperty(final String key, final byte value) {
-      properties.putByteProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putBytesProperty(final String key, final byte[] value) {
-      properties.putBytesProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putShortProperty(final String key, final short value) {
-      properties.putShortProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putIntProperty(final String key, final int value) {
-      properties.putIntProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putLongProperty(final String key, final long value) {
-      properties.putLongProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putFloatProperty(final String key, final float value) {
-      properties.putFloatProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putDoubleProperty(final String key, final double value) {
-      properties.putDoubleProperty(new SimpleString(key), value);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Message putStringProperty(final String key, final String value) {
-      properties.putSimpleStringProperty(new SimpleString(key), SimpleString.toSimpleString(value));
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   public Message putTypedProperties(final TypedProperties otherProps) {
-      properties.putTypedProperties(otherProps);
-
-      bufferValid = false;
-
-      return this;
-   }
-
-   @Override
-   public Object getObjectProperty(final SimpleString key) {
-      return properties.getProperty(key);
-   }
-
-   @Override
-   public Boolean getBooleanProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getBooleanProperty(key);
-   }
-
-   @Override
-   public Boolean getBooleanProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getBooleanProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Byte getByteProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getByteProperty(key);
-   }
-
-   @Override
-   public Byte getByteProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getByteProperty(new SimpleString(key));
-   }
-
-   @Override
-   public byte[] getBytesProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getBytesProperty(key);
-   }
-
-   @Override
-   public byte[] getBytesProperty(final String key) throws ActiveMQPropertyConversionException {
-      return getBytesProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getDoubleProperty(key);
-   }
-
-   @Override
-   public Double getDoubleProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getDoubleProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getIntProperty(key);
-   }
-
-   @Override
-   public Integer getIntProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getIntProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Long getLongProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getLongProperty(key);
-   }
-
-   @Override
-   public Long getLongProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getLongProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Short getShortProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getShortProperty(key);
-   }
-
-   @Override
-   public Short getShortProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getShortProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Float getFloatProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getFloatProperty(key);
-   }
-
-   @Override
-   public Float getFloatProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getFloatProperty(new SimpleString(key));
-   }
-
-   @Override
-   public String getStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      SimpleString str = getSimpleStringProperty(key);
-
-      if (str == null) {
-         return null;
-      } else {
-         return str.toString();
-      }
-   }
-
-   @Override
-   public String getStringProperty(final String key) throws ActiveMQPropertyConversionException {
-      return getStringProperty(new SimpleString(key));
-   }
-
-   @Override
-   public SimpleString getSimpleStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
-      return properties.getSimpleStringProperty(key);
-   }
-
-   @Override
-   public SimpleString getSimpleStringProperty(final String key) throws ActiveMQPropertyConversionException {
-      return properties.getSimpleStringProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Object getObjectProperty(final String key) {
-      return properties.getProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Object removeProperty(final SimpleString key) {
-      bufferValid = false;
-
-      return properties.removeProperty(key);
-   }
-
-   @Override
-   public Object removeProperty(final String key) {
-      bufferValid = false;
-
-      return properties.removeProperty(new SimpleString(key));
-   }
-
-   @Override
-   public boolean containsProperty(final SimpleString key) {
-      return properties.containsProperty(key);
-   }
-
-   @Override
-   public boolean containsProperty(final String key) {
-      return properties.containsProperty(new SimpleString(key));
-   }
-
-   @Override
-   public Set<SimpleString> getPropertyNames() {
-      return properties.getPropertyNames();
-   }
-
-   @Override
-   public ActiveMQBuffer getWholeBuffer() {
-      return buffer;
-   }
-
-   @Override
-   public BodyEncoder getBodyEncoder() throws ActiveMQException {
-      return new DecodingContext();
-   }
-
-   @Override
-   public TypedProperties getTypedProperties() {
-      return this.properties;
-   }
-
-   @Override
-   public boolean equals(Object other) {
-
-      if (this == other) {
-         return true;
-      }
-
-      if (other instanceof MessageImpl) {
-         MessageImpl message = (MessageImpl) other;
-
-         if (this.getMessageID() == message.getMessageID())
-            return true;
-      }
-
-      return false;
-   }
-
-   /**
-    * Debug Helper!!!!
-    *
-    * I'm leaving this message here without any callers for a reason:
-    * During debugs it's important eventually to identify what's on the bodies, and this method will give you a good idea about them.
-    * Add the message.bodyToString() to the Watch variables on the debugger view and this will show up like a charm!!!
-    *
-    * @return
-    */
-   public String bodyToString() {
-      getEndOfBodyPosition();
-      int readerIndex1 = this.buffer.readerIndex();
-      buffer.readerIndex(0);
-      byte[] buffer1 = new byte[buffer.writerIndex()];
-      buffer.readBytes(buffer1);
-      buffer.readerIndex(readerIndex1);
-
-      byte[] buffer2 = null;
-      if (bodyBuffer != null) {
-         int readerIndex2 = this.bodyBuffer.readerIndex();
-         bodyBuffer.readerIndex(0);
-         buffer2 = new byte[bodyBuffer.writerIndex() - bodyBuffer.readerIndex()];
-         bodyBuffer.readBytes(buffer2);
-         bodyBuffer.readerIndex(readerIndex2);
-         return "ServerMessage@" + Integer.toHexString(System.identityHashCode(this)) + "[writerIndex=" + buffer.writerIndex() + ",capacity=" + buffer.capacity() + ",bodyStart=" + getEndOfBodyPosition() + " buffer=" + ByteUtil.bytesToHex(buffer1, 1) + ", bodyBuffer=" + ByteUtil.bytesToHex(buffer2, 1);
-      } else {
-         return "ServerMessage@" + Integer.toHexString(System.identityHashCode(this)) + "[writerIndex=" + buffer.writerIndex() + ",capacity=" + buffer.capacity() + ",bodyStart=" + getEndOfBodyPosition() + " buffer=" + ByteUtil.bytesToHex(buffer1, 1);
-      }
-
-   }
-
-   @Override
-   public int hashCode() {
-      return 31 + (int) (messageID ^ (messageID >>> 32));
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   public TypedProperties getProperties() {
-      return properties;
-   }
-
-   // This must be synchronized as it can be called concurrently id the message is being delivered
-   // concurrently to
-   // many queues - the first caller in this case will actually encode it
-   private synchronized ActiveMQBuffer encodeToBuffer() {
-      if (!bufferValid) {
-         int bodySize = getEndOfBodyPosition();
-
-         // write it
-         buffer.setInt(BUFFER_HEADER_SPACE, bodySize);
-
-         // Position at end of body and skip past the message end position int.
-         // check for enough room in the buffer even though it is dynamic
-         if ((bodySize + 4) > buffer.capacity()) {
-            buffer.setIndex(0, bodySize);
-            buffer.writeInt(0);
-         } else {
-            buffer.setIndex(0, bodySize + DataConstants.SIZE_INT);
-         }
-
-         encodeHeadersAndProperties(buffer);
-
-         // Write end of message position
-
-         endOfMessagePosition = buffer.writerIndex();
-
-         buffer.setInt(bodySize, endOfMessagePosition);
-
-         bufferValid = true;
-      }
-
-      return buffer;
-   }
-
-   private void decode() {
-      endOfBodyPosition = buffer.getInt(BUFFER_HEADER_SPACE);
-
-      buffer.readerIndex(endOfBodyPosition + DataConstants.SIZE_INT);
-
-      decodeHeadersAndProperties(buffer);
-
-      endOfMessagePosition = buffer.readerIndex();
-
-      bufferValid = true;
-   }
-
-   public void createBody(final int initialMessageBufferSize) {
-      buffer = ActiveMQBuffers.dynamicBuffer(initialMessageBufferSize);
-
-      // There's a bug in netty which means a dynamic buffer won't resize until you write a byte
-      buffer.writeByte((byte) 0);
-
-      buffer.setIndex(BODY_OFFSET, BODY_OFFSET);
-   }
-
-   // Inner classes -------------------------------------------------
-
-   private final class DecodingContext implements BodyEncoder {
-
-      private int lastPos = 0;
-
-      private DecodingContext() {
-      }
-
-      @Override
-      public void open() {
-      }
-
-      @Override
-      public void close() {
-      }
-
-      @Override
-      public long getLargeBodySize() {
-         return buffer.writerIndex();
-      }
-
-      @Override
-      public int encode(final ByteBuffer bufferRead) throws ActiveMQException {
-         ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(bufferRead);
-         return encode(buffer, bufferRead.capacity());
-      }
-
-      @Override
-      public int encode(final ActiveMQBuffer bufferOut, final int size) {
-         bufferOut.writeBytes(getWholeBuffer(), lastPos, size);
-         lastPos += size;
-         return size;
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageInternal.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageInternal.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageInternal.java
deleted file mode 100644
index a7b2199..0000000
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/MessageInternal.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.message.impl;
-
-import java.io.InputStream;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQException;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.BodyEncoder;
-import org.apache.activemq.artemis.utils.TypedProperties;
-
-public interface MessageInternal extends Message {
-
-   void decodeFromBuffer(ActiveMQBuffer buffer);
-
-   int getEndOfMessagePosition();
-
-   int getEndOfBodyPosition();
-
-   void bodyChanged();
-
-   boolean isServerMessage();
-
-   ActiveMQBuffer getEncodedBuffer();
-
-   int getHeadersAndPropertiesEncodeSize();
-
-   ActiveMQBuffer getWholeBuffer();
-
-   void encodeHeadersAndProperties(ActiveMQBuffer buffer);
-
-   void decodeHeadersAndProperties(ActiveMQBuffer buffer);
-
-   BodyEncoder getBodyEncoder() throws ActiveMQException;
-
-   InputStream getBodyInputStream();
-
-   void setAddressTransient(SimpleString address);
-
-   TypedProperties getTypedProperties();
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
index ae1cf71..9975a5b 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java
@@ -32,6 +32,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
 import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
@@ -45,7 +46,7 @@ import org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal;
 import org.apache.activemq.artemis.core.client.impl.ClientMessageInternal;
 import org.apache.activemq.artemis.core.client.impl.ClientProducerCreditsImpl;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionImpl;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.core.Channel;
 import org.apache.activemq.artemis.core.protocol.core.ChannelHandler;
 import org.apache.activemq.artemis.core.protocol.core.CommandConfirmationHandler;
@@ -103,7 +104,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAR
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXASetTimeoutMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXASetTimeoutResponseMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAStartMessage;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
@@ -422,12 +422,12 @@ public class ActiveMQSessionContext extends SessionContext {
    }
 
    @Override
-   public int getCreditsOnSendingFull(MessageInternal msgI) {
+   public int getCreditsOnSendingFull(Message msgI) {
       return msgI.getEncodeSize();
    }
 
    @Override
-   public void sendFullMessage(MessageInternal msgI,
+   public void sendFullMessage(Message msgI,
                                boolean sendBlocking,
                                SendAcknowledgementHandler handler,
                                SimpleString defaultAddress) throws ActiveMQException {
@@ -441,16 +441,16 @@ public class ActiveMQSessionContext extends SessionContext {
    }
 
    @Override
-   public int sendInitialChunkOnLargeMessage(MessageInternal msgI) throws ActiveMQException {
+   public int sendInitialChunkOnLargeMessage(Message msgI) throws ActiveMQException {
       SessionSendLargeMessage initialChunk = new SessionSendLargeMessage(msgI);
 
       sessionChannel.send(initialChunk);
 
-      return msgI.getHeadersAndPropertiesEncodeSize();
+      return ((CoreMessage)msgI).getHeadersAndPropertiesEncodeSize();
    }
 
    @Override
-   public int sendLargeMessageChunk(MessageInternal msgI,
+   public int sendLargeMessageChunk(Message msgI,
                                     long messageBodySize,
                                     boolean sendBlocking,
                                     boolean lastChunk,
@@ -471,7 +471,7 @@ public class ActiveMQSessionContext extends SessionContext {
    }
 
    @Override
-   public int sendServerLargeMessageChunk(MessageInternal msgI,
+   public int sendServerLargeMessageChunk(Message msgI,
                                           long messageBodySize,
                                           boolean sendBlocking,
                                           boolean lastChunk,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java
index 0f5cdf0..e95227d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java
@@ -371,6 +371,7 @@ public final class ChannelImpl implements Channel {
             if (logger.isTraceEnabled()) {
                logger.trace("Sending blocking " + packet);
             }
+
             connection.getTransportConnection().write(buffer, false, false);
 
             long toWait = connection.getBlockingCallTimeout();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
index 9025210..08c17e4 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/PacketImpl.java
@@ -16,8 +16,11 @@
  */
 package org.apache.activemq.artemis.core.protocol.core.impl;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.DataConstants;
@@ -25,6 +28,7 @@ import org.apache.activemq.artemis.utils.DataConstants;
 public class PacketImpl implements Packet {
    // Constants -------------------------------------------------------------------------
 
+
    public static final int ADDRESSING_CHANGE_VERSION = 129;
 
    public static final SimpleString OLD_QUEUE_PREFIX = new SimpleString("jms.queue.");
@@ -310,7 +314,7 @@ public class PacketImpl implements Packet {
 
    @Override
    public ActiveMQBuffer encode(final RemotingConnection connection, boolean usePooled) {
-      ActiveMQBuffer buffer = connection.createTransportBuffer(PacketImpl.INITIAL_PACKET_SIZE, usePooled);
+      ActiveMQBuffer buffer = createPacket(connection, usePooled);
 
       // The standard header fields
 
@@ -330,6 +334,14 @@ public class PacketImpl implements Packet {
       return buffer;
    }
 
+   protected ActiveMQBuffer createPacket(RemotingConnection connection, boolean usePooled) {
+      if (connection == null) {
+         return new ChannelBufferWrapper(Unpooled.buffer(INITIAL_PACKET_SIZE));
+      } else {
+         return connection.createTransportBuffer(PacketImpl.INITIAL_PACKET_SIZE, usePooled);
+      }
+   }
+
    @Override
    public void decode(final ActiveMQBuffer buffer) {
       channelID = buffer.readLong();
@@ -339,6 +351,22 @@ public class PacketImpl implements Packet {
       size = buffer.readerIndex();
    }
 
+   protected ByteBuf copyMessageBuffer(ByteBuf buffer, int skipBytes) {
+
+      ByteBuf newNettyBuffer = Unpooled.buffer(buffer.capacity() - PACKET_HEADERS_SIZE - skipBytes);
+
+      int read = buffer.readerIndex();
+      int writ = buffer.writerIndex();
+      buffer.readerIndex(PACKET_HEADERS_SIZE);
+
+      newNettyBuffer.writeBytes(buffer, buffer.readableBytes() - skipBytes);
+      buffer.setIndex( read, writ );
+      newNettyBuffer.setIndex( 0, writ - PACKET_HEADERS_SIZE - skipBytes);
+
+      return newNettyBuffer;
+   }
+
+
    @Override
    public int getPacketSize() {
       if (size == -1) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
index 8bd62ca..cada061 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java
@@ -353,6 +353,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
          }
 
          dataReceived = true;
+
          doBufferReceived(packet);
 
          super.bufferReceived(connectionID, buffer);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java
index 6a52a27..ec2520a 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/MessagePacket.java
@@ -16,15 +16,19 @@
  */
 package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
+
+import io.netty.buffer.Unpooled;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
+import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 
 public abstract class MessagePacket extends PacketImpl implements MessagePacketI {
 
-   protected MessageInternal message;
+   protected Message message;
 
-   public MessagePacket(final byte type, final MessageInternal message) {
+   public MessagePacket(final byte type, final Message message) {
       super(type);
 
       this.message = message;
@@ -40,4 +44,12 @@ public abstract class MessagePacket extends PacketImpl implements MessagePacketI
       return super.getParentString() + ", message=" + message;
    }
 
+   protected ActiveMQBuffer internalCreatePacket(int size, RemotingConnection connection, boolean usePooled) {
+      if (connection == null) {
+         return new ChannelBufferWrapper(Unpooled.buffer(size));
+      } else {
+         return connection.createTransportBuffer(size, usePooled);
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveClientLargeMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveClientLargeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveClientLargeMessage.java
index 66e509c..e9e3138 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveClientLargeMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveClientLargeMessage.java
@@ -17,12 +17,13 @@
 package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 
 public class SessionReceiveClientLargeMessage extends SessionReceiveLargeMessage {
 
-   public SessionReceiveClientLargeMessage(MessageInternal message) {
+   public SessionReceiveClientLargeMessage(Message message) {
       super(message);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java
index 64f96f9..dc2c458 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveLargeMessage.java
@@ -18,12 +18,12 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 
 public class SessionReceiveLargeMessage extends PacketImpl implements MessagePacketI {
 
-   private final MessageInternal message;
+   private final Message message;
 
    /**
     * Since we receive the message before the entire message was received,
@@ -35,13 +35,13 @@ public class SessionReceiveLargeMessage extends PacketImpl implements MessagePac
    private int deliveryCount;
 
    // To be used on decoding at the client while receiving a large message
-   public SessionReceiveLargeMessage(final MessageInternal message) {
+   public SessionReceiveLargeMessage(final Message message) {
       super(SESS_RECEIVE_LARGE_MSG);
       this.message = message;
    }
 
    public SessionReceiveLargeMessage(final long consumerID,
-                                     final MessageInternal message,
+                                     final Message message,
                                      final long largeMessageSize,
                                      final int deliveryCount) {
       super(SESS_RECEIVE_LARGE_MSG);
@@ -55,7 +55,7 @@ public class SessionReceiveLargeMessage extends PacketImpl implements MessagePac
       this.largeMessageSize = largeMessageSize;
    }
 
-   public MessageInternal getLargeMessage() {
+   public Message getLargeMessage() {
       return message;
    }
 
@@ -85,7 +85,7 @@ public class SessionReceiveLargeMessage extends PacketImpl implements MessagePac
       buffer.writeInt(deliveryCount);
       buffer.writeLong(largeMessageSize);
       if (message != null) {
-         message.encodeHeadersAndProperties(buffer);
+         ((CoreMessage)message).encodeHeadersAndProperties(buffer.byteBuf());
       }
    }
 
@@ -94,7 +94,7 @@ public class SessionReceiveLargeMessage extends PacketImpl implements MessagePac
       consumerID = buffer.readLong();
       deliveryCount = buffer.readInt();
       largeMessageSize = buffer.readLong();
-      message.decodeHeadersAndProperties(buffer);
+      ((CoreMessage)message).decodeHeadersAndProperties(buffer.byteBuf());
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveMessage.java
index c21ebda..c03d3c8 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionReceiveMessage.java
@@ -17,7 +17,8 @@
 package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.DataConstants;
 
@@ -30,7 +31,7 @@ public class SessionReceiveMessage extends MessagePacket {
 
    private int deliveryCount;
 
-   public SessionReceiveMessage(final long consumerID, final MessageInternal message, final int deliveryCount) {
+   public SessionReceiveMessage(final long consumerID, final Message message, final int deliveryCount) {
       super(SESS_RECEIVE_MSG, message);
 
       this.consumerID = consumerID;
@@ -38,7 +39,7 @@ public class SessionReceiveMessage extends MessagePacket {
       this.deliveryCount = deliveryCount;
    }
 
-   public SessionReceiveMessage(final MessageInternal message) {
+   public SessionReceiveMessage(final Message message) {
       super(SESS_RECEIVE_MSG, message);
    }
 
@@ -53,53 +54,28 @@ public class SessionReceiveMessage extends MessagePacket {
    }
 
    @Override
-   public ActiveMQBuffer encode(final RemotingConnection connection) {
-      ActiveMQBuffer buffer = message.getEncodedBuffer();
-
-      ActiveMQBuffer bufferWrite = connection.createTransportBuffer(buffer.writerIndex() + DataConstants.SIZE_LONG + DataConstants.SIZE_INT, true);
-      bufferWrite.writeBytes(buffer, 0, buffer.capacity());
-      bufferWrite.setIndex(buffer.readerIndex(), buffer.writerIndex());
-
-      // Sanity check
-      if (bufferWrite.writerIndex() != message.getEndOfMessagePosition()) {
-         throw new IllegalStateException("Wrong encode position");
-      }
-
-      bufferWrite.writeLong(consumerID);
-      bufferWrite.writeInt(deliveryCount);
-
-      size = bufferWrite.writerIndex();
-
-      // Write standard headers
-
-      int len = size - DataConstants.SIZE_INT;
-      bufferWrite.setInt(0, len);
-      bufferWrite.setByte(DataConstants.SIZE_INT, getType());
-      bufferWrite.setLong(DataConstants.SIZE_INT + DataConstants.SIZE_BYTE, channelID);
-
-      // Position reader for reading by Netty
-      bufferWrite.setIndex(0, size);
-
-      return bufferWrite;
+   protected ActiveMQBuffer createPacket(RemotingConnection connection, boolean usePooled) {
+      return internalCreatePacket(message.getEncodeSize() + PACKET_HEADERS_SIZE + DataConstants.SIZE_LONG + DataConstants.SIZE_INT, connection, usePooled);
    }
 
    @Override
-   public void decode(final ActiveMQBuffer buffer) {
-      channelID = buffer.readLong();
-
-      message.decodeFromBuffer(buffer);
-
-      consumerID = buffer.readLong();
+   public void encodeRest(ActiveMQBuffer buffer) {
+      message.sendBuffer(buffer.byteBuf(), deliveryCount);
+      buffer.writeLong(consumerID);
+      buffer.writeInt(deliveryCount);
+   }
 
-      deliveryCount = buffer.readInt();
+   @Override
+   public void decodeRest(final ActiveMQBuffer buffer) {
+      // Buffer comes in after having read standard headers and positioned at Beginning of body part
 
-      size = buffer.readerIndex();
+      message.receiveBuffer(copyMessageBuffer(buffer.byteBuf(), DataConstants.SIZE_LONG + DataConstants.SIZE_INT));
 
-      // Need to position buffer for reading
+      buffer.readerIndex(buffer.capacity() - DataConstants.SIZE_LONG - DataConstants.SIZE_INT);
+      this.consumerID = buffer.readLong();
+      this.deliveryCount = buffer.readInt();
 
-      buffer.setIndex(PACKET_HEADERS_SIZE + DataConstants.SIZE_INT, message.getEndOfBodyPosition());
    }
-
    @Override
    public int hashCode() {
       final int prime = 31;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java
index b4ec027..0ecfe33 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendContinuationMessage.java
@@ -17,8 +17,8 @@
 package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 
 /**
  * A SessionSendContinuationMessage<br>
@@ -28,7 +28,7 @@ public class SessionSendContinuationMessage extends SessionContinuationMessage {
    private boolean requiresResponse;
 
    // Used on confirmation handling
-   private MessageInternal message;
+   private Message message;
    /**
     * In case, we are using a different handler than the one set on the {@link org.apache.activemq.artemis.api.core.client.ClientSession}
     * <br>
@@ -58,7 +58,7 @@ public class SessionSendContinuationMessage extends SessionContinuationMessage {
     * @param continues
     * @param requiresResponse
     */
-   public SessionSendContinuationMessage(final MessageInternal message,
+   public SessionSendContinuationMessage(final Message message,
                                          final byte[] body,
                                          final boolean continues,
                                          final boolean requiresResponse,
@@ -87,7 +87,7 @@ public class SessionSendContinuationMessage extends SessionContinuationMessage {
    /**
     * @return the message
     */
-   public MessageInternal getMessage() {
+   public Message getMessage() {
       return message;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java
index bf4290b..869940c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendLargeMessage.java
@@ -18,7 +18,7 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 
 public class SessionSendLargeMessage extends PacketImpl implements MessagePacketI {
@@ -26,13 +26,13 @@ public class SessionSendLargeMessage extends PacketImpl implements MessagePacket
    /**
     * Used only if largeMessage
     */
-   private final MessageInternal largeMessage;
+   private final Message largeMessage;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
-   public SessionSendLargeMessage(final MessageInternal largeMessage) {
+   public SessionSendLargeMessage(final Message largeMessage) {
       super(SESS_SEND_LARGE);
 
       this.largeMessage = largeMessage;
@@ -40,7 +40,7 @@ public class SessionSendLargeMessage extends PacketImpl implements MessagePacket
 
    // Public --------------------------------------------------------
 
-   public MessageInternal getLargeMessage() {
+   public Message getLargeMessage() {
       return largeMessage;
    }
 
@@ -51,12 +51,12 @@ public class SessionSendLargeMessage extends PacketImpl implements MessagePacket
 
    @Override
    public void encodeRest(final ActiveMQBuffer buffer) {
-      largeMessage.encodeHeadersAndProperties(buffer);
+      ((CoreMessage)largeMessage).encodeHeadersAndProperties(buffer.byteBuf());
    }
 
    @Override
    public void decodeRest(final ActiveMQBuffer buffer) {
-      largeMessage.decodeHeadersAndProperties(buffer);
+      ((CoreMessage)largeMessage).decodeHeadersAndProperties(buffer.byteBuf());
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java
index c7bb30e..8182b90 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/SessionSendMessage.java
@@ -16,11 +16,12 @@
  */
 package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
-import org.apache.activemq.artemis.utils.DataConstants;
 
 public class SessionSendMessage extends MessagePacket {
 
@@ -36,7 +37,8 @@ public class SessionSendMessage extends MessagePacket {
     */
    private final transient SendAcknowledgementHandler handler;
 
-   public SessionSendMessage(final MessageInternal message,
+   /** This will be using the CoreMessage because it is meant for the core-protocol */
+   public SessionSendMessage(final Message message,
                              final boolean requiresResponse,
                              final SendAcknowledgementHandler handler) {
       super(SESS_SEND, message);
@@ -44,7 +46,7 @@ public class SessionSendMessage extends MessagePacket {
       this.requiresResponse = requiresResponse;
    }
 
-   public SessionSendMessage(final MessageInternal message) {
+   public SessionSendMessage(final CoreMessage message) {
       super(SESS_SEND, message);
       this.handler = null;
    }
@@ -60,53 +62,29 @@ public class SessionSendMessage extends MessagePacket {
    }
 
    @Override
-   public ActiveMQBuffer encode(final RemotingConnection connection) {
-      ActiveMQBuffer buffer = message.getEncodedBuffer();
-
-      ActiveMQBuffer bufferWrite;
-      if (connection == null) {
-         // this is for unit tests only
-         bufferWrite = buffer.copy(0, buffer.capacity());
-      } else {
-         bufferWrite = connection.createTransportBuffer(buffer.writerIndex() + 1, true); // 1 for the requireResponse
-      }
-      bufferWrite.writeBytes(buffer, 0, buffer.writerIndex());
-      bufferWrite.setIndex(buffer.readerIndex(), buffer.writerIndex());
-
-      // Sanity check
-      if (bufferWrite.writerIndex() != message.getEndOfMessagePosition()) {
-         throw new IllegalStateException("Wrong encode position");
-      }
-
-      bufferWrite.writeBoolean(requiresResponse);
-
-      size = bufferWrite.writerIndex();
-
-      // Write standard headers
+   protected ActiveMQBuffer createPacket(RemotingConnection connection, boolean usePooled) {
+      return internalCreatePacket(message.getEncodeSize() + PACKET_HEADERS_SIZE + 1, connection, usePooled);
+   }
 
-      int len = size - DataConstants.SIZE_INT;
-      bufferWrite.setInt(0, len);
-      bufferWrite.setByte(DataConstants.SIZE_INT, getType());
-      bufferWrite.setLong(DataConstants.SIZE_INT + DataConstants.SIZE_BYTE, channelID);
+   @Override
+   public void encodeRest(ActiveMQBuffer buffer) {
+      message.sendBuffer(buffer.byteBuf(), 0);
+      buffer.writeBoolean(requiresResponse);
 
-      // Position reader for reading by Netty
-      bufferWrite.readerIndex(0);
 
-      return bufferWrite;
    }
 
    @Override
    public void decodeRest(final ActiveMQBuffer buffer) {
       // Buffer comes in after having read standard headers and positioned at Beginning of body part
 
-      message.decodeFromBuffer(buffer);
+      ByteBuf messageBuffer = copyMessageBuffer(buffer.byteBuf(), 1);
+      message.receiveBuffer(messageBuffer);
 
-      int ri = buffer.readerIndex();
+      buffer.readerIndex(buffer.capacity() - 1);
 
       requiresResponse = buffer.readBoolean();
 
-      buffer.readerIndex(ri);
-
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MapMessageUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MapMessageUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MapMessageUtil.java
index 65aeccb..8560f5d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MapMessageUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/reader/MapMessageUtil.java
@@ -26,7 +26,7 @@ public class MapMessageUtil extends MessageUtil {
     */
    public static void writeBodyMap(ActiveMQBuffer message, TypedProperties properties) {
       message.resetWriterIndex();
-      properties.encode(message);
+      properties.encode(message.byteBuf());
    }
 
    /**
@@ -43,7 +43,7 @@ public class MapMessageUtil extends MessageUtil {
     */
    public static void readBodyMap(ActiveMQBuffer message, TypedProperties map) {
       message.resetReaderIndex();
-      map.decode(message);
+      map.decode(message.byteBuf());
    }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/SessionContext.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/SessionContext.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/SessionContext.java
index 72795b7..8bb0081 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/SessionContext.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/SessionContext.java
@@ -33,7 +33,6 @@ import org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal;
 import org.apache.activemq.artemis.core.client.impl.ClientMessageInternal;
 import org.apache.activemq.artemis.core.client.impl.ClientProducerCreditsImpl;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.IDGenerator;
@@ -128,9 +127,9 @@ public abstract class SessionContext {
 
    }
 
-   public abstract int getCreditsOnSendingFull(MessageInternal msgI);
+   public abstract int getCreditsOnSendingFull(Message msgI);
 
-   public abstract void sendFullMessage(MessageInternal msgI,
+   public abstract void sendFullMessage(Message msgI,
                                         boolean sendBlocking,
                                         SendAcknowledgementHandler handler,
                                         SimpleString defaultAddress) throws ActiveMQException;
@@ -142,9 +141,9 @@ public abstract class SessionContext {
     * @return
     * @throws ActiveMQException
     */
-   public abstract int sendInitialChunkOnLargeMessage(MessageInternal msgI) throws ActiveMQException;
+   public abstract int sendInitialChunkOnLargeMessage(Message msgI) throws ActiveMQException;
 
-   public abstract int sendLargeMessageChunk(MessageInternal msgI,
+   public abstract int sendLargeMessageChunk(Message msgI,
                                              long messageBodySize,
                                              boolean sendBlocking,
                                              boolean lastChunk,
@@ -152,7 +151,7 @@ public abstract class SessionContext {
                                              int reconnectID,
                                              SendAcknowledgementHandler messageHandler) throws ActiveMQException;
 
-   public abstract int sendServerLargeMessageChunk(MessageInternal msgI,
+   public abstract int sendServerLargeMessageChunk(Message msgI,
                                                    long messageBodySize,
                                                    boolean sendBlocking,
                                                    boolean lastChunk,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-core-client/src/test/java/org/apache/activemq/artemis/message/CoreMessageTest.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/message/CoreMessageTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/message/CoreMessageTest.java
new file mode 100644
index 0000000..5e92eaf
--- /dev/null
+++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/message/CoreMessageTest.java
@@ -0,0 +1,365 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.message;
+
+import java.util.LinkedList;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.artemis.core.message.impl.CoreMessage;
+import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage;
+import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
+import org.apache.activemq.artemis.reader.TextMessageUtil;
+import org.apache.activemq.artemis.utils.Base64;
+import org.apache.activemq.artemis.utils.ByteUtil;
+import org.apache.activemq.artemis.utils.UUID;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CoreMessageTest {
+
+   public static final SimpleString ADDRESS = new SimpleString("this.local.address");
+   public static final byte MESSAGE_TYPE = Message.TEXT_TYPE;
+   public static final boolean DURABLE = true;
+   public static final long EXPIRATION = 123L;
+   public static final long TIMESTAMP = 321L;
+   public static final byte PRIORITY = (byte) 3;
+   public static final String TEXT = "hi";
+   public static final String BIGGER_TEXT = "AAAAAAAAAAAAAAAAAAAAAAAAA ASDF ASDF ASF ASD ASF ASDF ASDF ASDF ASF ADSF ASDF";
+   public static final String SMALLER_TEXT = "H";
+   public static final UUID uuid = new UUID(UUID.TYPE_TIME_BASED, new byte[]{0, 0, 0, 0,
+      0, 0, 0, 0,
+      0, 0, 0, 0,
+      0, 0, 0, 1});
+   public static final SimpleString PROP1_NAME = new SimpleString("t1");
+   public static final SimpleString PROP1_VALUE = new SimpleString("value-t1");
+
+   /**
+    * This encode was generated by {@link #generate()}.
+    * Run it manually with a right-click on the IDE to eventually update it
+    * */
+   // body = "hi";
+   private final String STRING_ENCODE = "AAAAFgEAAAAEaABpAAAAAAAAAAAAAQAAACR0AGgAaQBzAC4AbABvAGMAYQBsAC4AYQBkAGQAcgBlAHMAcwAAAwEAAAAAAAAAewAAAAAAAAFBAwEAAAABAAAABHQAMQAKAAAAEHYAYQBsAHUAZQAtAHQAMQA=";
+
+   private ByteBuf BYTE_ENCODE;
+
+
+   @Before
+   public void before() {
+      BYTE_ENCODE = Unpooled.wrappedBuffer(Base64.decode(STRING_ENCODE, Base64.DONT_BREAK_LINES | Base64.URL_SAFE));
+      // some extra caution here, nothing else, to make sure we would get the same encoding back
+      Assert.assertEquals(STRING_ENCODE, encodeString(BYTE_ENCODE.array()));
+      BYTE_ENCODE.readerIndex(0).writerIndex(BYTE_ENCODE.capacity());
+   }
+
+   /** The message is received, then sent to the other side untouched */
+   @Test
+   public void testPassThrough() {
+      CoreMessage decodedMessage = decodeMessage();
+
+      Assert.assertEquals(TEXT, TextMessageUtil.readBodyText(decodedMessage.getReadOnlyBodyBuffer()).toString());
+   }
+
+   /** The message is received, then sent to the other side untouched */
+   @Test
+   public void sendThroughPackets() {
+      CoreMessage decodedMessage = decodeMessage();
+
+      int encodeSize = decodedMessage.getEncodeSize();
+      Assert.assertEquals(BYTE_ENCODE.capacity(), encodeSize);
+
+      SessionSendMessage sendMessage = new SessionSendMessage(decodedMessage, true, null);
+      sendMessage.setChannelID(777);
+
+      ActiveMQBuffer buffer = sendMessage.encode(null);
+
+      byte[] byteArray = buffer.byteBuf().array();
+      System.out.println("Sending " + ByteUtil.bytesToHex(buffer.toByteBuffer().array(), 1) + ", bytes = " + byteArray.length);
+
+      buffer.readerIndex(5);
+
+      SessionSendMessage sendMessageReceivedSent = new SessionSendMessage(new CoreMessage());
+
+      sendMessageReceivedSent.decode(buffer);
+
+      Assert.assertEquals(encodeSize, sendMessageReceivedSent.getMessage().getEncodeSize());
+
+      Assert.assertTrue(sendMessageReceivedSent.isRequiresResponse());
+
+      Assert.assertEquals(TEXT, TextMessageUtil.readBodyText(sendMessageReceivedSent.getMessage().getReadOnlyBodyBuffer()).toString());
+   }
+
+   /** The message is received, then sent to the other side untouched */
+   @Test
+   public void sendThroughPacketsClient() {
+      CoreMessage decodedMessage = decodeMessage();
+
+      int encodeSize = decodedMessage.getEncodeSize();
+      Assert.assertEquals(BYTE_ENCODE.capacity(), encodeSize);
+
+      SessionReceiveMessage sendMessage = new SessionReceiveMessage(33, decodedMessage, 7);
+      sendMessage.setChannelID(777);
+
+      ActiveMQBuffer buffer = sendMessage.encode(null);
+
+      buffer.readerIndex(5);
+
+      SessionReceiveMessage sendMessageReceivedSent = new SessionReceiveMessage(new CoreMessage());
+
+      sendMessageReceivedSent.decode(buffer);
+
+      Assert.assertEquals(33, sendMessageReceivedSent.getConsumerID());
+
+      Assert.assertEquals(7, sendMessageReceivedSent.getDeliveryCount());
+
+      Assert.assertEquals(encodeSize, sendMessageReceivedSent.getMessage().getEncodeSize());
+
+      Assert.assertEquals(TEXT, TextMessageUtil.readBodyText(sendMessageReceivedSent.getMessage().getReadOnlyBodyBuffer()).toString());
+   }
+
+   private CoreMessage decodeMessage() {
+
+      ByteBuf newBuffer = Unpooled.buffer(BYTE_ENCODE.capacity());
+      newBuffer.writeBytes(BYTE_ENCODE, 0, BYTE_ENCODE.writerIndex());
+
+      CoreMessage coreMessage = internalDecode(newBuffer);
+
+      int encodeSize = coreMessage.getEncodeSize();
+
+      Assert.assertEquals(newBuffer.capacity(), encodeSize);
+
+      Assert.assertEquals(ADDRESS, coreMessage.getAddressSimpleString());
+
+      Assert.assertEquals(PROP1_VALUE.toString(), coreMessage.getStringProperty(PROP1_NAME));
+
+      ByteBuf destinedBuffer = Unpooled.buffer(BYTE_ENCODE.array().length);
+      coreMessage.sendBuffer(destinedBuffer, 0);
+
+      byte[] destinedArray = destinedBuffer.array();
+      byte[] sourceArray = BYTE_ENCODE.array();
+
+      CoreMessage newDecoded = internalDecode(Unpooled.wrappedBuffer(destinedArray));
+
+      Assert.assertEquals(encodeSize, newDecoded.getEncodeSize());
+
+      Assert.assertArrayEquals(sourceArray, destinedArray);
+
+      return coreMessage;
+   }
+
+   private CoreMessage internalDecode(ByteBuf bufferOrigin) {
+      CoreMessage coreMessage = new CoreMessage();
+//      System.out.println("Bytes from test " + ByteUtil.bytesToHex(bufferOrigin.array(), 1));
+      coreMessage.receiveBuffer(bufferOrigin);
+      return coreMessage;
+   }
+
+   /** The message is received, then sent to the other side untouched */
+   @Test
+   public void testChangeBodyStringSameSize() {
+      testChangeBodyString(TEXT.toUpperCase());
+   }
+
+   @Test
+   public void testChangeBodyBiggerString() {
+      testChangeBodyString(BIGGER_TEXT);
+   }
+
+   @Test
+   public void testGenerateEmpty() {
+      CoreMessage empty = new CoreMessage().initBuffer(100);
+      ByteBuf buffer = Unpooled.buffer(200);
+      empty.sendBuffer(buffer, 0);
+
+      CoreMessage empty2 = new CoreMessage();
+      empty2.receiveBuffer(buffer);
+
+      try {
+         empty2.getBodyBuffer().readByte();
+         Assert.fail("should throw exception");
+      } catch (Exception expected) {
+
+      }
+   }
+
+   @Test
+   public void testSaveReceiveLimitedBytes() {
+      CoreMessage empty = new CoreMessage().initBuffer(100);
+      System.out.println("R " + empty.getBodyBuffer().readerIndex() + " W " + empty.getBodyBuffer().writerIndex());
+      empty.getBodyBuffer().writeByte((byte)7);
+      System.out.println("R " + empty.getBodyBuffer().readerIndex() + " W " + empty.getBodyBuffer().writerIndex());
+
+      ByteBuf buffer = Unpooled.buffer(200);
+      empty.sendBuffer(buffer, 0);
+
+      CoreMessage empty2 = new CoreMessage();
+      empty2.receiveBuffer(buffer);
+
+      Assert.assertEquals((byte)7, empty2.getBodyBuffer().readByte());
+
+      System.out.println("Readable :: " + empty2.getBodyBuffer().readerIndex() + " writer :" + empty2.getBodyBuffer().writerIndex());
+
+      try {
+         empty2.getBodyBuffer().readByte();
+         Assert.fail("should throw exception");
+      } catch (Exception expected) {
+
+      }
+   }
+
+   @Test
+   public void testChangeBodySmallerString() {
+      testChangeBodyString(SMALLER_TEXT);
+   }
+
+   public void testChangeBodyString(String newString) {
+      CoreMessage coreMessage = decodeMessage();
+
+      coreMessage.putStringProperty("newProperty", "newValue");
+      ActiveMQBuffer legacyBuffer = coreMessage.getBodyBuffer();
+      legacyBuffer.resetWriterIndex();
+      legacyBuffer.clear();
+
+      TextMessageUtil.writeBodyText(legacyBuffer, SimpleString.toSimpleString(newString));
+
+      ByteBuf newbuffer = Unpooled.buffer(150000);
+
+      coreMessage.sendBuffer(newbuffer, 0);
+      newbuffer.readerIndex(0);
+
+      CoreMessage newCoreMessage = new CoreMessage();
+      newCoreMessage.receiveBuffer(newbuffer);
+
+
+      SimpleString newText = TextMessageUtil.readBodyText(newCoreMessage.getReadOnlyBodyBuffer());
+
+      Assert.assertEquals(newString, newText.toString());
+
+//      coreMessage.putStringProperty()
+   }
+
+   @Test
+   public void testPassThroughMultipleThreads() throws Throwable {
+      CoreMessage coreMessage = new CoreMessage();
+      coreMessage.receiveBuffer(BYTE_ENCODE);
+
+      LinkedList<Throwable> errors = new LinkedList<>();
+
+      Thread[] threads = new Thread[50];
+      for (int i = 0; i < threads.length; i++) {
+         threads[i] = new Thread(() -> {
+            try {
+               for (int j = 0; j < 50; j++) {
+                  Assert.assertEquals(ADDRESS, coreMessage.getAddressSimpleString());
+                  Assert.assertEquals(PROP1_VALUE.toString(), coreMessage.getStringProperty(PROP1_NAME));
+
+                  ByteBuf destinedBuffer = Unpooled.buffer(BYTE_ENCODE.array().length);
+                  coreMessage.sendBuffer(destinedBuffer, 0);
+
+                  byte[] destinedArray = destinedBuffer.array();
+                  byte[] sourceArray = BYTE_ENCODE.array();
+
+                  Assert.assertArrayEquals(sourceArray, destinedArray);
+
+                  Assert.assertEquals(TEXT, TextMessageUtil.readBodyText(coreMessage.getReadOnlyBodyBuffer()).toString());
+               }
+            } catch (Throwable e) {
+               e.printStackTrace();
+               errors.add(e);
+            }
+         });
+      }
+
+      for (Thread t : threads) {
+         t.start();
+      }
+
+      for (Thread t : threads) {
+         t.join();
+      }
+
+      for (Throwable e: errors) {
+         throw e;
+      }
+
+   }
+
+   // This is to compare the original encoding with the current version
+   @Test
+   public void compareOriginal() throws Exception {
+      String generated = generate(TEXT);
+
+      Assert.assertEquals(STRING_ENCODE, generated);
+
+      for (int i = 0; i < generated.length(); i++) {
+         Assert.assertEquals("Chart at " + i + " was " + generated.charAt(i) + " instead of " + STRING_ENCODE.charAt(i), generated.charAt(i), STRING_ENCODE.charAt(i));
+      }
+   }
+
+   /** Use this method to update the encode for the known message */
+   @Ignore
+   @Test
+   public void generate() throws Exception {
+
+      printVariable(TEXT, generate(TEXT));
+      printVariable(SMALLER_TEXT, generate(SMALLER_TEXT));
+      printVariable(BIGGER_TEXT, generate(BIGGER_TEXT));
+
+   }
+
+   private void printVariable(String body, String encode) {
+      System.out.println("// body = \"" + body + "\";");
+      System.out.println("private final String STRING_ENCODE = \"" + encode + "\";");
+
+   }
+
+   public String generate(String body) throws Exception {
+
+      ClientMessageImpl message = new ClientMessageImpl(MESSAGE_TYPE, DURABLE, EXPIRATION, TIMESTAMP, PRIORITY, 10 * 1024);
+      TextMessageUtil.writeBodyText(message.getBodyBuffer(), SimpleString.toSimpleString(body));
+
+      message.setAddress(ADDRESS);
+      message.setUserID(uuid);
+      message.getProperties().putSimpleStringProperty(PROP1_NAME, PROP1_VALUE);
+
+
+      ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(10 * 1024);
+      message.sendBuffer(buffer.byteBuf(), 0);
+
+      byte[] bytes = new byte[buffer.byteBuf().writerIndex()];
+      buffer.byteBuf().readBytes(bytes);
+
+      return encodeString(bytes);
+
+      // replace the code
+
+
+   }
+
+   private String encodeString(byte[] bytes) {
+      return Base64.encodeBytes(bytes, 0, bytes.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
+   }
+
+}


[14/29] activemq-artemis git commit: ARTEMIS-1009 Pure Message Encoding.

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
index d09f62f..2295987 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
@@ -25,9 +25,11 @@ import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
 import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
 import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException;
 import org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.exception.ActiveMQXAException;
 import org.apache.activemq.artemis.core.io.IOCallback;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
+import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManager;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
@@ -81,9 +83,9 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.BindingQueryResult;
+import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.jboss.logging.Logger;
@@ -137,13 +139,23 @@ public class ServerSessionPacketHandler implements ChannelHandler {
 
    private volatile CoreRemotingConnection remotingConnection;
 
+   private final CoreProtocolManager manager;
+
+   // The current currentLargeMessage being processed
+   private volatile LargeServerMessage currentLargeMessage;
+
    private final boolean direct;
 
-   public ServerSessionPacketHandler(final ServerSession session,
+   public ServerSessionPacketHandler(final CoreProtocolManager manager,
+                                     final ServerSession session,
                                      final StorageManager storageManager,
                                      final Channel channel) {
+      this.manager = manager;
+
       this.session = session;
 
+      session.addCloseable((boolean failed) -> clearLargeMessage());
+
       this.storageManager = storageManager;
 
       this.channel = channel;
@@ -159,6 +171,16 @@ public class ServerSessionPacketHandler implements ChannelHandler {
       }
    }
 
+   private void clearLargeMessage() {
+      if (currentLargeMessage != null) {
+         try {
+            currentLargeMessage.deleteFile();
+         } catch (Throwable error) {
+            ActiveMQServerLogger.LOGGER.errorDeletingLargeMessageFile(error);
+         }
+      }
+   }
+
    public ServerSession getSession() {
       return session;
    }
@@ -469,7 +491,8 @@ public class ServerSessionPacketHandler implements ChannelHandler {
                case SESS_SEND: {
                   SessionSendMessage message = (SessionSendMessage) packet;
                   requiresResponse = message.isRequiresResponse();
-                  session.send((ServerMessage) message.getMessage(), direct);
+                  message.getMessage().setProtocol(manager);
+                  session.send(message.getMessage(), direct);
                   if (requiresResponse) {
                      response = new NullResponseMessage();
                   }
@@ -477,13 +500,13 @@ public class ServerSessionPacketHandler implements ChannelHandler {
                }
                case SESS_SEND_LARGE: {
                   SessionSendLargeMessage message = (SessionSendLargeMessage) packet;
-                  session.sendLarge(message.getLargeMessage());
+                  sendLarge(message.getLargeMessage());
                   break;
                }
                case SESS_SEND_CONTINUATION: {
                   SessionSendContinuationMessage message = (SessionSendContinuationMessage) packet;
                   requiresResponse = message.isRequiresResponse();
-                  session.sendContinuations(message.getPacketSize(), message.getMessageBodySize(), message.getBody(), message.isContinues());
+                  sendContinuations(message.getPacketSize(), message.getMessageBodySize(), message.getBody(), message.isContinues());
                   if (requiresResponse) {
                      response = new NullResponseMessage();
                   }
@@ -681,4 +704,53 @@ public class ServerSessionPacketHandler implements ChannelHandler {
 
       return serverLastReceivedCommandID;
    }
+
+   // Large Message is part of the core protocol, we have these functions here as part of Packet handler
+   private void sendLarge(final Message message) throws Exception {
+      // need to create the LargeMessage before continue
+      long id = storageManager.generateID();
+
+      LargeServerMessage largeMsg = storageManager.createLargeMessage(id, message);
+
+      if (logger.isTraceEnabled()) {
+         logger.trace("sendLarge::" + largeMsg);
+      }
+
+      if (currentLargeMessage != null) {
+         ActiveMQServerLogger.LOGGER.replacingIncompleteLargeMessage(currentLargeMessage.getMessageID());
+      }
+
+      currentLargeMessage = largeMsg;
+   }
+
+
+
+   private void sendContinuations(final int packetSize,
+                                 final long messageBodySize,
+                                 final byte[] body,
+                                 final boolean continues) throws Exception {
+      if (currentLargeMessage == null) {
+         throw ActiveMQMessageBundle.BUNDLE.largeMessageNotInitialised();
+      }
+
+      // Immediately release the credits for the continuations- these don't contribute to the in-memory size
+      // of the message
+
+      currentLargeMessage.addBytes(body);
+
+      if (!continues) {
+         currentLargeMessage.releaseResources();
+
+         if (messageBodySize >= 0) {
+            currentLargeMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, messageBodySize);
+         }
+
+
+         session.doSend(session.getCurrentTransaction(), currentLargeMessage, false, false);
+
+         currentLargeMessage = null;
+      }
+   }
+
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java
index e6595a5..919d84e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java
@@ -168,7 +168,7 @@ public class ActiveMQPacketHandler implements ChannelHandler {
 
          ServerSession session = server.createSession(request.getName(), activeMQPrincipal == null ? request.getUsername() : activeMQPrincipal.getUserName(), activeMQPrincipal == null ? request.getPassword() : activeMQPrincipal.getPassword(), request.getMinLargeMessageSize(), connection, request.isAutoCommitSends(), request.isAutoCommitAcks(), request.isPreAcknowledge(), request.isXA(), request.getDefaultAddress(), new CoreSessionCallback(request.getName(), protocolManager, channel, connection), true, sessionOperationContext, routingTypeMap);
 
-         ServerSessionPacketHandler handler = new ServerSessionPacketHandler(session, server.getStorageManager(), channel);
+         ServerSessionPacketHandler handler = new ServerSessionPacketHandler(protocolManager, session, server.getStorageManager(), channel);
          channel.setHandler(handler);
 
          // TODO - where is this removed?

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManagerFactory.java
index 7fed534..7560917 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManagerFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManagerFactory.java
@@ -21,7 +21,10 @@ import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.Interceptor;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
+import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.spi.core.protocol.AbstractProtocolManagerFactory;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
@@ -29,10 +32,21 @@ import org.apache.activemq.artemis.utils.uri.BeanSupport;
 
 public class CoreProtocolManagerFactory extends AbstractProtocolManagerFactory<Interceptor> {
 
+   public static final byte ID = 1;
    private static String[] SUPPORTED_PROTOCOLS = {ActiveMQClient.DEFAULT_CORE_PROTOCOL};
 
    private static final String MODULE_NAME = "artemis-server";
 
+   @Override
+   public byte getStoreID() {
+      return ID;
+   }
+
+   @Override
+   public Persister<Message> getPersister() {
+      return CoreMessagePersister.getInstance();
+   }
+
    /**
     * {@inheritDoc} *
     *

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java
index a6c73eb..3a09e91 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreSessionCallback.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.protocol.core.impl;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.protocol.core.Channel;
 import org.apache.activemq.artemis.core.protocol.core.Packet;
@@ -28,7 +29,6 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionRec
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
@@ -66,7 +66,7 @@ public final class CoreSessionCallback implements SessionCallback {
 
    @Override
    public int sendLargeMessage(MessageReference ref,
-                               ServerMessage message,
+                               Message message,
                                ServerConsumer consumer,
                                long bodySize,
                                int deliveryCount) {
@@ -92,7 +92,9 @@ public final class CoreSessionCallback implements SessionCallback {
    }
 
    @Override
-   public int sendMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, int deliveryCount) {
+   public int sendMessage(MessageReference ref, Message message, ServerConsumer consumer, int deliveryCount) {
+
+      // TODO-now: fix this
       Packet packet = new SessionReceiveMessage(consumer.getID(), message, deliveryCount);
 
       int size = 0;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
index 89d2863..8d22fab 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddMessage.java
@@ -19,7 +19,7 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 import java.util.Arrays;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.replication.ReplicationManager.ADD_OPERATION_TYPE;
 
@@ -36,7 +36,9 @@ public final class ReplicationAddMessage extends PacketImpl {
 
    private byte journalRecordType;
 
-   private EncodingSupport encodingData;
+   private Persister persister;
+
+   private Object encodingData;
 
    private byte[] recordData;
 
@@ -48,12 +50,14 @@ public final class ReplicationAddMessage extends PacketImpl {
                                 final ADD_OPERATION_TYPE operation,
                                 final long id,
                                 final byte journalRecordType,
-                                final EncodingSupport encodingData) {
+                                final Persister persister,
+                                final Object encodingData) {
       this();
       this.journalID = journalID;
       this.operation = operation;
       this.id = id;
       this.journalRecordType = journalRecordType;
+      this.persister = persister;
       this.encodingData = encodingData;
    }
 
@@ -66,8 +70,8 @@ public final class ReplicationAddMessage extends PacketImpl {
       buffer.writeBoolean(operation.toBoolean());
       buffer.writeLong(id);
       buffer.writeByte(journalRecordType);
-      buffer.writeInt(encodingData.getEncodeSize());
-      encodingData.encode(buffer);
+      buffer.writeInt(persister.getEncodeSize(encodingData));
+      persister.encode(buffer, encodingData);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
index 59475e0..925181b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationAddTXMessage.java
@@ -19,7 +19,7 @@ package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
 import java.util.Arrays;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.replication.ReplicationManager.ADD_OPERATION_TYPE;
 
@@ -36,7 +36,9 @@ public class ReplicationAddTXMessage extends PacketImpl {
 
    private byte recordType;
 
-   private EncodingSupport encodingData;
+   private Persister persister;
+
+   private Object encodingData;
 
    private byte[] recordData;
 
@@ -51,7 +53,8 @@ public class ReplicationAddTXMessage extends PacketImpl {
                                   final long txId,
                                   final long id,
                                   final byte recordType,
-                                  final EncodingSupport encodingData) {
+                                  final Persister persister,
+                                  final Object encodingData) {
       this();
       this.journalID = journalID;
       this.operation = operation;
@@ -70,8 +73,8 @@ public class ReplicationAddTXMessage extends PacketImpl {
       buffer.writeLong(txId);
       buffer.writeLong(id);
       buffer.writeByte(recordType);
-      buffer.writeInt(encodingData.getEncodeSize());
-      encodingData.encode(buffer);
+      buffer.writeInt(persister.getEncodeSize(encodingData));
+      persister.encode(buffer, encodingData);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java
index 7307151..b88e0fe 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/ReplicationPageWriteMessage.java
@@ -48,7 +48,7 @@ public class ReplicationPageWriteMessage extends PacketImpl {
    @Override
    public void decodeRest(final ActiveMQBuffer buffer) {
       pageNumber = buffer.readInt();
-      pagedMessage = new PagedMessageImpl();
+      pagedMessage = new PagedMessageImpl(null);
       pagedMessage.decode(buffer);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
index ea3107c..c5318e7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
@@ -17,12 +17,14 @@
 package org.apache.activemq.artemis.core.remoting.server;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection;
 import org.apache.activemq.artemis.core.security.ActiveMQPrincipal;
+import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.utils.ReusableLatch;
@@ -65,6 +67,8 @@ public interface RemotingService {
 
    boolean isStarted();
 
+   Map<String, ProtocolManagerFactory> getProtocolFactoryMap();
+
    /**
     * Allow acceptors to use this as their default security Principal if applicable.
     * <p>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index 50bc90d..3e15f3e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -59,6 +59,7 @@ import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@@ -147,7 +148,9 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
       this.scheduledThreadPool = scheduledThreadPool;
 
       CoreProtocolManagerFactory coreProtocolManagerFactory = new CoreProtocolManagerFactory();
-      //i know there is only 1
+
+      MessagePersister.getInstance().registerProtocol(coreProtocolManagerFactory);
+
       this.flushExecutor = flushExecutor;
 
       ActiveMQServerLogger.LOGGER.addingProtocolSupport(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.getModuleName());
@@ -174,6 +177,11 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
    }
 
    @Override
+   public Map<String, ProtocolManagerFactory> getProtocolFactoryMap() {
+      return protocolMap;
+   }
+
+   @Override
    public synchronized void start() throws Exception {
       if (started) {
          return;
@@ -768,6 +776,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
     */
    private void loadProtocolManagerFactories(Iterable<ProtocolManagerFactory> protocolManagerFactoryCollection) {
       for (ProtocolManagerFactory next : protocolManagerFactoryCollection) {
+         MessagePersister.registerProtocol(next);
          String[] protocols = next.getProtocols();
          for (String protocol : protocols) {
             ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocol, next.getModuleName());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java
index d70316f..0731e8c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java
@@ -25,6 +25,7 @@ import org.apache.activemq.artemis.core.journal.IOCompletion;
 import org.apache.activemq.artemis.core.journal.Journal;
 import org.apache.activemq.artemis.core.journal.JournalLoadInformation;
 import org.apache.activemq.artemis.core.journal.LoaderCallback;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
@@ -88,13 +89,14 @@ public class ReplicatedJournal implements Journal {
    @Override
    public void appendAddRecord(final long id,
                                final byte recordType,
-                               final EncodingSupport record,
+                               Persister persister,
+                               final Object record,
                                final boolean sync) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("Append record id = " + id + " recordType = " + recordType);
       }
-      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, record);
-      localJournal.appendAddRecord(id, recordType, record, sync);
+      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, persister, record);
+      localJournal.appendAddRecord(id, recordType, persister, record, sync);
    }
 
    /**
@@ -108,14 +110,15 @@ public class ReplicatedJournal implements Journal {
    @Override
    public void appendAddRecord(final long id,
                                final byte recordType,
-                               final EncodingSupport record,
+                               Persister persister,
+                               final Object record,
                                final boolean sync,
                                final IOCompletion completionCallback) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("Append record id = " + id + " recordType = " + recordType);
       }
-      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, record);
-      localJournal.appendAddRecord(id, recordType, record, sync, completionCallback);
+      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, persister, record);
+      localJournal.appendAddRecord(id, recordType, persister, record, sync, completionCallback);
    }
 
    /**
@@ -146,12 +149,13 @@ public class ReplicatedJournal implements Journal {
    public void appendAddRecordTransactional(final long txID,
                                             final long id,
                                             final byte recordType,
-                                            final EncodingSupport record) throws Exception {
+                                            final Persister persister,
+                                            final Object record) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("Append record TXid = " + id + " recordType = " + recordType);
       }
-      replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.ADD, txID, id, recordType, record);
-      localJournal.appendAddRecordTransactional(txID, id, recordType, record);
+      replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.ADD, txID, id, recordType, persister, record);
+      localJournal.appendAddRecordTransactional(txID, id, recordType, persister, record);
    }
 
    /**
@@ -354,26 +358,28 @@ public class ReplicatedJournal implements Journal {
    @Override
    public void appendUpdateRecord(final long id,
                                   final byte recordType,
-                                  final EncodingSupport record,
+                                  final Persister persister,
+                                  final Object record,
                                   final boolean sync) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("AppendUpdateRecord id = " + id + " , recordType = " + recordType);
       }
-      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, recordType, record);
-      localJournal.appendUpdateRecord(id, recordType, record, sync);
+      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, recordType, persister, record);
+      localJournal.appendUpdateRecord(id, recordType, persister, record, sync);
    }
 
    @Override
    public void appendUpdateRecord(final long id,
                                   final byte journalRecordType,
-                                  final EncodingSupport record,
+                                  final Persister persister,
+                                  final Object record,
                                   final boolean sync,
                                   final IOCompletion completionCallback) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("AppendUpdateRecord id = " + id + " , recordType = " + journalRecordType);
       }
-      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, journalRecordType, record);
-      localJournal.appendUpdateRecord(id, journalRecordType, record, sync, completionCallback);
+      replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, journalRecordType, persister, record);
+      localJournal.appendUpdateRecord(id, journalRecordType, persister, record, sync, completionCallback);
    }
 
    /**
@@ -404,12 +410,13 @@ public class ReplicatedJournal implements Journal {
    public void appendUpdateRecordTransactional(final long txID,
                                                final long id,
                                                final byte recordType,
-                                               final EncodingSupport record) throws Exception {
+                                               final Persister persister,
+                                               final Object record) throws Exception {
       if (ReplicatedJournal.trace) {
          ReplicatedJournal.trace("AppendUpdateRecord txid=" + txID + " id = " + id + " , recordType = " + recordType);
       }
-      replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.UPDATE, txID, id, recordType, record);
-      localJournal.appendUpdateRecordTransactional(txID, id, recordType, record);
+      replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.UPDATE, txID, id, recordType, persister, record);
+      localJournal.appendUpdateRecordTransactional(txID, id, recordType, persister, record);
    }
 
    /**
@@ -437,15 +444,6 @@ public class ReplicatedJournal implements Journal {
    }
 
    /**
-    * @param pages
-    * @see org.apache.activemq.artemis.core.journal.Journal#perfBlast(int)
-    */
-   @Override
-   public void perfBlast(final int pages) {
-      localJournal.perfBlast(pages);
-   }
-
-   /**
     * @throws Exception
     * @see org.apache.activemq.artemis.core.server.ActiveMQComponent#start()
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
index 1a07adc..e82d38e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java
@@ -32,6 +32,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
@@ -76,7 +77,7 @@ import org.apache.activemq.artemis.core.replication.ReplicationManager.ADD_OPERA
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.qourum.SharedNothingBackupQuorum;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation;
@@ -651,8 +652,8 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon
    private void handlePageWrite(final ReplicationPageWriteMessage packet) throws Exception {
       PagedMessage pgdMessage = packet.getPagedMessage();
       pgdMessage.initMessage(storageManager);
-      ServerMessage msg = pgdMessage.getMessage();
-      Page page = getPage(msg.getAddress(), packet.getPageNumber());
+      Message msg = pgdMessage.getMessage();
+      Page page = getPage(msg.getAddressSimpleString(), packet.getPageNumber());
       page.write(pgdMessage);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
index d0468d1..dce5990 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
@@ -36,6 +36,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.SessionFailureListener;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.persistence.Persister;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
 import org.apache.activemq.artemis.core.paging.PagedMessage;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
@@ -147,9 +148,10 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene
                                   final ADD_OPERATION_TYPE operation,
                                   final long id,
                                   final byte recordType,
-                                  final EncodingSupport record) throws Exception {
+                                  final Persister persister,
+                                  final Object record) throws Exception {
       if (enabled) {
-         sendReplicatePacket(new ReplicationAddMessage(journalID, operation, id, recordType, record));
+         sendReplicatePacket(new ReplicationAddMessage(journalID, operation, id, recordType, persister, record));
       }
    }
 
@@ -164,9 +166,10 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene
                                             final long txID,
                                             final long id,
                                             final byte recordType,
-                                            final EncodingSupport record) throws Exception {
+                                            final Persister persister,
+                                            final Object record) throws Exception {
       if (enabled) {
-         sendReplicatePacket(new ReplicationAddTXMessage(journalID, operation, txID, id, recordType, record));
+         sendReplicatePacket(new ReplicationAddTXMessage(journalID, operation, txID, id, recordType, persister, record));
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 6ee844b..e72d5d9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -41,6 +41,7 @@ import java.util.concurrent.ExecutorService;
 
 import io.netty.channel.Channel;
 import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
+
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
@@ -577,12 +578,8 @@ public interface ActiveMQServerLogger extends BasicLogger {
    void ioErrorAddingReferences(Integer errorCode, String errorMessage);
 
    @LogMessage(level = Logger.Level.WARN)
-   @Message(id = 222058, value = "Duplicate message detected through the bridge - message will not be routed. Message information:\n{0}", format = Message.Format.MESSAGE_FORMAT)
-   void duplicateMessageDetectedThruBridge(ServerMessage message);
-
-   @LogMessage(level = Logger.Level.WARN)
    @Message(id = 222059, value = "Duplicate message detected - message will not be routed. Message information:\n{0}", format = Message.Format.MESSAGE_FORMAT)
-   void duplicateMessageDetected(ServerMessage message);
+   void duplicateMessageDetected(org.apache.activemq.artemis.api.core.Message message);
 
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 222060, value = "Error while confirming large message completion on rollback for recordID={0}", format = Message.Format.MESSAGE_FORMAT)
@@ -783,7 +780,7 @@ public interface ActiveMQServerLogger extends BasicLogger {
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 222110, value = "no queue IDs defined!,  originalMessage  = {0}, copiedMessage = {1}, props={2}",
       format = Message.Format.MESSAGE_FORMAT)
-   void noQueueIdDefined(ServerMessage message, ServerMessage messageCopy, SimpleString idsHeaderName);
+   void noQueueIdDefined(org.apache.activemq.artemis.api.core.Message message, org.apache.activemq.artemis.api.core.Message messageCopy, SimpleString idsHeaderName);
 
    @LogMessage(level = Logger.Level.TRACE)
    @Message(id = 222111, value = "exception while invoking {0} on {1}",

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Bindable.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Bindable.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Bindable.java
index 0e38634..1ede0ea 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Bindable.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Bindable.java
@@ -16,9 +16,11 @@
  */
 package org.apache.activemq.artemis.core.server;
 
+import org.apache.activemq.artemis.api.core.Message;
+
 public interface Bindable {
 
-   void route(ServerMessage message, RoutingContext context) throws Exception;
+   void route(Message message, RoutingContext context) throws Exception;
 
-   void routeWithAck(ServerMessage message, RoutingContext context) throws Exception;
+   void routeWithAck(Message message, RoutingContext context) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java
index 2a16ed2..aa58a7d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/LargeServerMessage.java
@@ -17,10 +17,11 @@
 package org.apache.activemq.artemis.core.server;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.io.SequentialFile;
 import org.apache.activemq.artemis.core.replication.ReplicatedLargeMessage;
 
-public interface LargeServerMessage extends ServerMessage, ReplicatedLargeMessage {
+public interface LargeServerMessage extends ReplicatedLargeMessage, Message {
 
    @Override
    void addBytes(byte[] bytes) throws Exception;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java
index a1e6a20..799b0b0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MessageReference.java
@@ -16,7 +16,10 @@
  */
 package org.apache.activemq.artemis.core.server;
 
+
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.impl.AckReason;
+import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 
 /**
@@ -26,9 +29,14 @@ import org.apache.activemq.artemis.core.transaction.Transaction;
  */
 public interface MessageReference {
 
+   final class Factory {
+      public static MessageReference createReference(Message encode, final Queue queue) {
+         return new MessageReferenceImpl(encode, queue);
+      }
+   }
    boolean isPaged();
 
-   ServerMessage getMessage();
+   Message getMessage();
 
    /**
     * We define this method aggregation here because on paging we need to hold the original estimate,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Queue.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Queue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Queue.java
index ae377bb..d7b70a3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Queue.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/Queue.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.concurrent.Executor;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
@@ -197,7 +198,7 @@ public interface Queue extends Bindable {
 
    void cancelRedistributor() throws Exception;
 
-   boolean hasMatchingConsumer(ServerMessage message);
+   boolean hasMatchingConsumer(Message message);
 
    Collection<Consumer> getConsumers();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerMessage.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerMessage.java
deleted file mode 100644
index 40dc50f..0000000
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerMessage.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.core.server;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.journal.EncodingSupport;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
-import org.apache.activemq.artemis.core.paging.PagingStore;
-
-/**
- * A ServerMessage
- */
-public interface ServerMessage extends MessageInternal, EncodingSupport {
-
-   ServerMessage setMessageID(long id);
-
-   MessageReference createReference(Queue queue);
-
-   /**
-    * This will force encoding of the address, and will re-check the buffer
-    * This is to avoid setMessageTransient which set the address without changing the buffer
-    *
-    * @param address
-    */
-   void forceAddress(SimpleString address);
-
-   int incrementRefCount() throws Exception;
-
-   int decrementRefCount() throws Exception;
-
-   int incrementDurableRefCount();
-
-   int decrementDurableRefCount();
-
-   ServerMessage copy(long newID);
-
-   ServerMessage copy();
-
-   int getMemoryEstimate();
-
-   int getRefCount();
-
-   ServerMessage makeCopyForExpiryOrDLA(long newID,
-                                        MessageReference originalReference,
-                                        boolean expiry,
-                                        boolean copyOriginalHeaders) throws Exception;
-
-   void setOriginalHeaders(ServerMessage other, MessageReference originalReference, boolean expiry);
-
-   void setPagingStore(PagingStore store);
-
-   PagingStore getPagingStore();
-
-   // Is there any _AMQ_ property being used
-   boolean hasInternalProperties();
-
-   boolean storeIsPaging();
-
-   void encodeMessageIDToBuffer();
-
-   byte[] getDuplicateIDBytes();
-
-   Object getDuplicateProperty();
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
index f4e2ec7..1899d65 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
@@ -21,10 +21,11 @@ import javax.transaction.xa.Xid;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.activemq.artemis.Closeable;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.message.impl.MessageInternal;
 import org.apache.activemq.artemis.core.persistence.OperationContext;
 import org.apache.activemq.artemis.core.postoffice.RoutingStatus;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
@@ -99,6 +100,8 @@ public interface ServerSession extends SecurityAuth {
 
    void stop();
 
+   void addCloseable(Closeable closeable);
+
    /**
     * To be used by protocol heads that needs to control the transaction outside the session context.
     */
@@ -178,18 +181,19 @@ public interface ServerSession extends SecurityAuth {
 
    void receiveConsumerCredits(long consumerID, int credits) throws Exception;
 
-   void sendContinuations(int packetSize, long totalBodySize, byte[] body, boolean continues) throws Exception;
-
    RoutingStatus send(Transaction tx,
-                      ServerMessage message,
+                      Message message,
                       boolean direct,
                       boolean noAutoCreateQueue) throws Exception;
 
-   RoutingStatus send(ServerMessage message, boolean direct, boolean noAutoCreateQueue) throws Exception;
+   RoutingStatus doSend(final Transaction tx,
+                        final Message msg,
+                        final boolean direct,
+                        final boolean noAutoCreateQueue) throws Exception;
 
-   RoutingStatus send(ServerMessage message, boolean direct) throws Exception;
+   RoutingStatus send(Message message, boolean direct, boolean noAutoCreateQueue) throws Exception;
 
-   void sendLarge(MessageInternal msg) throws Exception;
+   RoutingStatus send(Message message, boolean direct) throws Exception;
 
    void forceConsumerDelivery(long consumerID, long sequence) throws Exception;
 
@@ -249,7 +253,9 @@ public interface ServerSession extends SecurityAuth {
 
    SimpleString getMatchingQueue(SimpleString address, RoutingType routingType) throws Exception;
 
-   SimpleString getMatchingQueue(SimpleString address, SimpleString queueName, RoutingType routingType) throws Exception;
+   SimpleString getMatchingQueue(SimpleString address,
+                                 SimpleString queueName,
+                                 RoutingType routingType) throws Exception;
 
    AddressInfo getAddress(SimpleString address);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Transformer.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Transformer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Transformer.java
index 1583f2c..48f4aa9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Transformer.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/Transformer.java
@@ -16,9 +16,9 @@
  */
 package org.apache.activemq.artemis.core.server.cluster;
 
-import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.api.core.Message;
 
 public interface Transformer {
 
-   ServerMessage transform(ServerMessage message);
+   Message transform(Message message);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
index ee549c5..18a1f38 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java
@@ -46,14 +46,14 @@ import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal
 import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.HandleStatus;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
+
 import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
@@ -499,16 +499,16 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
    }
 
    /* Hook for processing message before forwarding */
-   protected ServerMessage beforeForward(final ServerMessage message) {
+   protected Message beforeForward(final Message message) {
       if (useDuplicateDetection) {
          // We keep our own DuplicateID for the Bridge, so bouncing back and forth will work fine
          byte[] bytes = getDuplicateBytes(nodeUUID, message.getMessageID());
 
-         message.putBytesProperty(MessageImpl.HDR_BRIDGE_DUPLICATE_ID, bytes);
+         message.putBytesProperty(Message.HDR_BRIDGE_DUPLICATE_ID, bytes);
       }
 
       if (transformer != null) {
-         final ServerMessage transformedMessage = transformer.transform(message);
+         final Message transformedMessage = transformer.transform(message);
          if (transformedMessage != message) {
             if (logger.isDebugEnabled()) {
                logger.debug("The transformer " + transformer +
@@ -556,7 +556,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
             refs.put(ref.getMessage().getMessageID(), ref);
          }
 
-         final ServerMessage message = beforeForward(ref.getMessage());
+         final Message message = beforeForward(ref.getMessage());
 
          final SimpleString dest;
 
@@ -564,7 +564,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
             dest = forwardingAddress;
          } else {
             // Preserve the original address
-            dest = message.getAddress();
+            dest = message.getAddressSimpleString();
          }
 
          pendingAcks.countUp();
@@ -686,7 +686,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
     * @param message
     * @return
     */
-   private HandleStatus deliverStandardMessage(SimpleString dest, final MessageReference ref, ServerMessage message) {
+   private HandleStatus deliverStandardMessage(SimpleString dest, final MessageReference ref, Message message) {
       // if we failover during send then there is a chance that the
       // that this will throw a disconnect, we need to remove the message
       // from the acks so it will get resent, duplicate detection will cope
@@ -697,6 +697,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled
       }
 
       try {
+         // TODO-now: replace this
          producer.send(dest, message);
       } catch (final ActiveMQException e) {
          ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
index f16d863..524bb08 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
@@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
@@ -36,12 +37,11 @@ import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
 import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.postoffice.BindingType;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
@@ -113,7 +113,7 @@ public class ClusterConnectionBridge extends BridgeImpl {
 
       this.discoveryLocator = discoveryLocator;
 
-      idsHeaderName = MessageImpl.HDR_ROUTE_TO_IDS.concat(name);
+      idsHeaderName = Message.HDR_ROUTE_TO_IDS.concat(name);
 
       this.clusterConnection = clusterConnection;
 
@@ -150,13 +150,13 @@ public class ClusterConnectionBridge extends BridgeImpl {
    }
 
    @Override
-   protected ServerMessage beforeForward(final ServerMessage message) {
+   protected Message beforeForward(final Message message) {
       // We make a copy of the message, then we strip out the unwanted routing id headers and leave
       // only
       // the one pertinent for the address node - this is important since different queues on different
       // nodes could have same queue ids
       // Note we must copy since same message may get routed to other nodes which require different headers
-      ServerMessage messageCopy = message.copy();
+      Message messageCopy = message.copy();
 
       if (logger.isTraceEnabled()) {
          logger.trace("Clustered bridge  copied message " + message + " as " + messageCopy + " before delivery");
@@ -175,12 +175,12 @@ public class ClusterConnectionBridge extends BridgeImpl {
       }
 
       for (SimpleString propName : propNames) {
-         if (propName.startsWith(MessageImpl.HDR_ROUTE_TO_IDS)) {
+         if (propName.startsWith(Message.HDR_ROUTE_TO_IDS)) {
             messageCopy.removeProperty(propName);
          }
       }
 
-      messageCopy.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, queueIds);
+      messageCopy.putBytesProperty(Message.HDR_ROUTE_TO_IDS, queueIds);
 
       messageCopy = super.beforeForward(messageCopy);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java
index c585405..e9477a8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/Redistributor.java
@@ -32,7 +32,6 @@ import org.apache.activemq.artemis.core.server.HandleStatus;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
 import org.apache.activemq.artemis.utils.ReusableLatch;
@@ -139,7 +138,7 @@ public class Redistributor implements Consumer {
 
       final Transaction tx = new TransactionImpl(storageManager);
 
-      final Pair<RoutingContext, ServerMessage> routingInfo = postOffice.redistribute(reference.getMessage(), queue, tx);
+      final Pair<RoutingContext, Message> routingInfo = postOffice.redistribute(reference.getMessage(), queue, tx);
 
       if (routingInfo == null) {
          return HandleStatus.BUSY;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java
index 8f54b2a..9803433 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java
@@ -23,15 +23,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.filter.impl.FilterImpl;
-import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+
 import org.apache.activemq.artemis.core.postoffice.BindingType;
 import org.apache.activemq.artemis.core.server.Bindable;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.RoutingContext;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
 import org.jboss.logging.Logger;
 
@@ -88,7 +88,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
 
       queueFilter = FilterImpl.createFilter(filterString);
 
-      idsHeaderName = MessageImpl.HDR_ROUTE_TO_IDS.concat(bridgeName);
+      idsHeaderName = Message.HDR_ROUTE_TO_IDS.concat(bridgeName);
 
       this.distance = distance;
    }
@@ -149,7 +149,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
    }
 
    @Override
-   public synchronized boolean isHighAcceptPriority(final ServerMessage message) {
+   public synchronized boolean isHighAcceptPriority(final Message message) {
       if (consumerCount == 0) {
          return false;
       }
@@ -172,7 +172,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) {
+   public void route(final Message message, final RoutingContext context) {
       addRouteContextToMessage(message);
 
       List<Queue> durableQueuesOnContext = context.getDurableQueues(storeAndForwardQueue.getAddress());
@@ -185,7 +185,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) {
+   public void routeWithAck(Message message, RoutingContext context) {
       addRouteContextToMessage(message);
 
       List<Queue> durableQueuesOnContext = context.getDurableQueues(storeAndForwardQueue.getAddress());
@@ -315,7 +315,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
     *
     * @param message
     */
-   private void addRouteContextToMessage(final ServerMessage message) {
+   private void addRouteContextToMessage(final Message message) {
       byte[] ids = message.getBytesProperty(idsHeaderName);
 
       if (ids == null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index aa1ebf3..38500b7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -2622,6 +2622,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
    @Override
    public void addProtocolManagerFactory(ProtocolManagerFactory factory) {
       protocolManagerFactories.add(factory);
+      new Exception("protocol....").printStackTrace();
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
index 619036d..bd3f303 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.core.server.impl;
 
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
@@ -25,7 +26,6 @@ import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.DivertConfigurationRoutingType;
 import org.apache.activemq.artemis.core.server.RoutingContext;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.cluster.Transformer;
 import org.jboss.logging.Logger;
 
@@ -83,7 +83,7 @@ public class DivertImpl implements Divert {
    }
 
    @Override
-   public void route(final ServerMessage message, final RoutingContext context) throws Exception {
+   public void route(final Message message, final RoutingContext context) throws Exception {
       // We must make a copy of the message, otherwise things like returning credits to the page won't work
       // properly on ack, since the original address will be overwritten
 
@@ -91,7 +91,7 @@ public class DivertImpl implements Divert {
          logger.trace("Diverting message " + message + " into " + this);
       }
 
-      ServerMessage copy = null;
+      Message copy = null;
 
       // Shouldn't copy if it's not routed anywhere else
       if (!forwardAddress.equals(context.getAddress())) {
@@ -99,7 +99,7 @@ public class DivertImpl implements Divert {
          copy = message.copy(id);
 
          // This will set the original MessageId, and the original address
-         copy.setOriginalHeaders(message, null, false);
+         copy.referenceOriginalMessage(message, null);
 
          copy.setAddress(forwardAddress);
 
@@ -130,7 +130,7 @@ public class DivertImpl implements Divert {
    }
 
    @Override
-   public void routeWithAck(ServerMessage message, RoutingContext context) throws Exception {
+   public void routeWithAck(Message message, RoutingContext context) throws Exception {
       route(message, context);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java
index 40cef50..4adb1b2 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/JournalLoader.java
@@ -20,6 +20,7 @@ import javax.transaction.xa.Xid;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.journal.Journal;
@@ -29,7 +30,6 @@ import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
 import org.apache.activemq.artemis.core.persistence.impl.PageCountPending;
 import org.apache.activemq.artemis.core.persistence.impl.journal.AddMessageRecord;
 import org.apache.activemq.artemis.core.server.MessageReference;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.ResourceManager;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 
@@ -43,7 +43,7 @@ public interface JournalLoader {
 
    void handleAddMessage(Map<Long, Map<Long, AddMessageRecord>> queueMap) throws Exception;
 
-   void handleNoMessageReferences(Map<Long, ServerMessage> messages);
+   void handleNoMessageReferences(Map<Long, Message> messages);
 
    void handleGroupingBindings(List<GroupingInfo> groupingInfos);
 
@@ -53,7 +53,7 @@ public interface JournalLoader {
                  ResourceManager resourceManager,
                  Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap) throws Exception;
 
-   void handlePreparedSendMessage(ServerMessage message, Transaction tx, long queueID) throws Exception;
+   void handlePreparedSendMessage(Message message, Transaction tx, long queueID) throws Exception;
 
    void handlePreparedAcknowledge(long messageID,
                                   List<MessageReference> referencesToAck,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java
index eb467ae..ab6ab62 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java
@@ -22,6 +22,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.api.core.Message;
+
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.filter.Filter;
 import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@@ -31,7 +32,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -74,7 +74,7 @@ public class LastValueQueue extends QueueImpl {
          return;
       }
 
-      SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME);
+      SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME.toString());
 
       if (prop != null) {
          HolderReference hr = map.get(prop);
@@ -98,7 +98,7 @@ public class LastValueQueue extends QueueImpl {
 
    @Override
    public synchronized void addHead(final MessageReference ref, boolean scheduling) {
-      SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME);
+      SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME.toString());
 
       if (prop != null) {
          HolderReference hr = map.get(prop);
@@ -148,7 +148,7 @@ public class LastValueQueue extends QueueImpl {
    @Override
    protected void refRemoved(MessageReference ref) {
       synchronized (this) {
-         SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME);
+         SimpleString prop = ref.getMessage().getSimpleStringProperty(Message.HDR_LAST_VALUE_NAME.toString());
 
          if (prop != null) {
             map.remove(prop);
@@ -223,7 +223,7 @@ public class LastValueQueue extends QueueImpl {
       }
 
       @Override
-      public ServerMessage getMessage() {
+      public Message getMessage() {
          return ref.getMessage();
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java
index 6d9030e..bffb1ad 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/MessageReferenceImpl.java
@@ -18,11 +18,10 @@ package org.apache.activemq.artemis.core.server.impl;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.Queue;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.Transaction;
-import org.apache.activemq.artemis.utils.MemorySize;
 
 /**
  * Implementation of a MessageReference
@@ -35,7 +34,7 @@ public class MessageReferenceImpl implements MessageReference {
 
    private volatile long scheduledDeliveryTime;
 
-   private final ServerMessage message;
+   private final Message message;
 
    private final Queue queue;
 
@@ -47,20 +46,7 @@ public class MessageReferenceImpl implements MessageReference {
 
    // Static --------------------------------------------------------
 
-   private static final int memoryOffset;
-
-   static {
-      // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
-      // Note, it is only an estimate, it's not possible to be entirely sure with Java
-      // This figure is calculated using the test utilities in org.apache.activemq.tests.unit.util.sizeof
-      // The value is somewhat higher on 64 bit architectures, probably due to different alignment
-
-      if (MemorySize.is64bitArch()) {
-         memoryOffset = 48;
-      } else {
-         memoryOffset = 32;
-      }
-   }
+   private static final int memoryOffset = 64;
 
    // Constructors --------------------------------------------------
 
@@ -80,7 +66,7 @@ public class MessageReferenceImpl implements MessageReference {
       this.queue = queue;
    }
 
-   protected MessageReferenceImpl(final ServerMessage message, final Queue queue) {
+   public MessageReferenceImpl(final Message message, final Queue queue) {
       this.message = message;
 
       this.queue = queue;
@@ -155,7 +141,7 @@ public class MessageReferenceImpl implements MessageReference {
    }
 
    @Override
-   public ServerMessage getMessage() {
+   public Message getMessage() {
       return message;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/46be6a2f/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
index 005a994..717e2e2 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java
@@ -57,7 +57,6 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueConfig;
 import org.apache.activemq.artemis.core.server.QueueFactory;
 import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.group.GroupingHandler;
 import org.apache.activemq.artemis.core.server.group.impl.GroupBinding;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
@@ -233,8 +232,8 @@ public class PostOfficeJournalLoader implements JournalLoader {
    }
 
    @Override
-   public void handleNoMessageReferences(Map<Long, ServerMessage> messages) {
-      for (ServerMessage msg : messages.values()) {
+   public void handleNoMessageReferences(Map<Long, Message> messages) {
+      for (Message msg : messages.values()) {
          if (msg.getRefCount() == 0) {
             ActiveMQServerLogger.LOGGER.journalUnreferencedMessage(msg.getMessageID());
             try {
@@ -284,7 +283,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
    }
 
    @Override
-   public void handlePreparedSendMessage(ServerMessage message, Transaction tx, long queueID) throws Exception {
+   public void handlePreparedSendMessage(Message message, Transaction tx, long queueID) throws Exception {
       Queue queue = queues.get(queueID);
 
       if (queue == null) {


[27/29] activemq-artemis git commit: Fixing tests (mqtt)

Posted by cl...@apache.org.
Fixing tests (mqtt)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5acb6f5a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5acb6f5a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5acb6f5a

Branch: refs/heads/artemis-1009
Commit: 5acb6f5a8e855f2e27e59461a996da37848479c1
Parents: c58a3d0
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Mar 1 15:28:33 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 2 10:05:21 2017 -0500

----------------------------------------------------------------------
 .../activemq/artemis/core/message/impl/CoreMessage.java   |  2 ++
 .../artemis/core/protocol/mqtt/MQTTPublishManager.java    | 10 +++++++---
 .../artemis/core/protocol/mqtt/MQTTSessionCallback.java   |  2 +-
 .../activemq/artemis/core/protocol/mqtt/MQTTUtil.java     |  4 +---
 4 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5acb6f5a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index 973c1de..b1bad5a 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -131,6 +131,7 @@ public class CoreMessage extends RefCountMessage {
 
    @Override
    public ActiveMQBuffer getReadOnlyBodyBuffer() {
+      checkEncode();
       internalWritableBuffer();
       return new ChannelBufferWrapper(buffer.slice(BODY_OFFSET, endOfBodyPosition - BUFFER_HEADER_SPACE).setIndex(0, endOfBodyPosition - BUFFER_HEADER_SPACE).asReadOnly());
    }
@@ -243,6 +244,7 @@ public class CoreMessage extends RefCountMessage {
 
    @Override
    public Message copy() {
+      checkEncode();
       return new CoreMessage(this);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5acb6f5a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
index e619eb9..67ef258 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java
@@ -32,12 +32,15 @@ import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
 import org.apache.activemq.artemis.core.transaction.Transaction;
+import org.jboss.logging.Logger;
 
 /**
  * Handles MQTT Exactly Once (QoS level 2) Protocol.
  */
 public class MQTTPublishManager {
 
+   private static final Logger logger = Logger.getLogger(MQTTPublishManager.class);
+
    private static final String MANAGEMENT_QUEUE_PREFIX = "$sys.mqtt.queue.qos2.";
 
    private SimpleString managementAddress;
@@ -173,6 +176,7 @@ public class MQTTPublishManager {
                }
                tx.commit();
             } catch (Throwable t) {
+               logger.warn(t.getMessage(), t);
                tx.rollback();
                throw t;
             }
@@ -253,17 +257,17 @@ public class MQTTPublishManager {
       switch (message.getType()) {
          case Message.TEXT_TYPE:
             try {
-               SimpleString text = message.getBodyBuffer().readNullableSimpleString();
+               SimpleString text = message.getReadOnlyBodyBuffer().readNullableSimpleString();
                byte[] stringPayload = text.toString().getBytes("UTF-8");
                payload = ByteBufAllocator.DEFAULT.buffer(stringPayload.length);
                payload.writeBytes(stringPayload);
                break;
             } catch (UnsupportedEncodingException e) {
-               log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
+               log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage(), e);
             }
          default:
             ActiveMQBuffer bufferDup = message.getReadOnlyBodyBuffer();
-            payload = bufferDup.readBytes(message.getEndOfBodyPosition() - bufferDup.readerIndex()).byteBuf();
+            payload = bufferDup.readBytes(bufferDup.writerIndex()).byteBuf();
             break;
       }
       session.getProtocolHandler().send(messageId, address, qos, payload, deliveryCount);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5acb6f5a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
index b997d80..a5b908f 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTSessionCallback.java
@@ -51,7 +51,7 @@ public class MQTTSessionCallback implements SessionCallback {
       try {
          session.getMqttPublishManager().sendMessage((CoreMessage)message, consumer, deliveryCount);
       } catch (Exception e) {
-         log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
+         log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage(), e);
       }
       return 1;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5acb6f5a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
index 6891497..e7b8c50 100644
--- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
+++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTUtil.java
@@ -26,7 +26,6 @@ import io.netty.handler.codec.mqtt.MqttSubscribeMessage;
 import io.netty.handler.codec.mqtt.MqttTopicSubscription;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.config.WildcardConfiguration;
 import org.apache.activemq.artemis.core.message.impl.CoreMessage;
 
@@ -114,8 +113,7 @@ public class MQTTUtil {
       String coreAddress = convertMQTTAddressFilterToCore(topic, session.getWildcardConfiguration());
       Message message = createServerMessage(session, new SimpleString(coreAddress), retain, qos);
 
-      // FIXME does this involve a copy?
-      message.getBodyBuffer().writeBytes(new ChannelBufferWrapper(payload), payload.readableBytes());
+      message.getBodyBuffer().writeBytes(payload, 0, payload.readableBytes());
       return message;
    }