Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1793#discussion_r168166559
  
    --- Diff: 
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessage.java
 ---
    @@ -0,0 +1,673 @@
    +/**
    + * 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
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * 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.protocol.openwire;
    +
    +import javax.jms.JMSException;
    +import java.io.IOException;
    +import java.util.Enumeration;
    +import java.util.HashSet;
    +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.ActiveMQException;
    +import 
org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException;
    +import org.apache.activemq.artemis.api.core.ICoreMessage;
    +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.core.buffers.impl.ChannelBufferWrapper;
    +import 
org.apache.activemq.artemis.core.message.impl.CoreMessageObjectPools;
    +import org.apache.activemq.artemis.core.persistence.Persister;
    +import org.apache.activemq.artemis.utils.DataConstants;
    +import org.apache.activemq.command.ActiveMQDestination;
    +import org.apache.activemq.command.ActiveMQMessage;
    +import org.apache.activemq.openwire.OpenWireFormat;
    +import org.apache.activemq.util.ByteSequence;
    +import org.apache.activemq.wireformat.WireFormat;
    +
    +public class OpenWireMessage extends RefCountMessage {
    +
    +   private org.apache.activemq.command.ActiveMQMessage message;
    +   private WireFormat wireFormat;
    +   ByteBuf data;
    +   boolean bufferValid;
    +
    +
    +   public OpenWireMessage(org.apache.activemq.command.ActiveMQMessage 
message, WireFormat wireFormat) {
    +      this.message = message;
    +      this.wireFormat = wireFormat;
    +      try {
    +         ByteSequence byteSequence = this.wireFormat.marshal(message);
    +         setBuffer(Unpooled.copiedBuffer(byteSequence.getData(), 
byteSequence.getOffset(), byteSequence.getLength()));
    +      } catch (IOException e) {
    +         throw new ActiveMQPropertyConversionException(e.getMessage());
    +      }
    +   }
    +
    +   public OpenWireMessage() {
    +   }
    +
    +   public void setMarsheller(WireFormat wireFormat) {
    +      this.wireFormat = wireFormat;
    +   }
    +
    +   public ActiveMQMessage getAMQMessage() {
    +      if (message == null) {
    +         if (data != null) {
    +            try {
    +               message = (ActiveMQMessage) wireFormat.unmarshal(new 
ChannelBufferWrapper(data));
    +            } catch (IOException e) {
    +               throw new 
ActiveMQPropertyConversionException(e.getMessage());
    +            }
    +            return message;
    +         } else {
    +            return new ActiveMQMessage();
    +         }
    +      }
    +      return message;
    +   }
    +
    +   @Override
    +   public void messageChanged() {
    +   }
    +
    +   @Override
    +   public Long getScheduledDeliveryTime() {
    +      return message.getArrival();
    +   }
    +
    +   @Override
    +   public SimpleString getReplyTo() {
    +      return 
SimpleString.toSimpleString(message.getReplyTo().getPhysicalName());
    --- End diff --
    
    Could use pool


---

Reply via email to