From dev-return-64209-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Wed Feb 14 14:04:52 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CB974180656 for ; Wed, 14 Feb 2018 14:04:51 +0100 (CET) Received: (qmail 1926 invoked by uid 500); 14 Feb 2018 13:04:50 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 1439 invoked by uid 99); 14 Feb 2018 13:04:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Feb 2018 13:04:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 08494E96E4; Wed, 14 Feb 2018 13:04:50 +0000 (UTC) From: michaelandrepearce To: dev@activemq.apache.org Reply-To: dev@activemq.apache.org References: In-Reply-To: Subject: [GitHub] activemq-artemis pull request #1793: ARTEMIS-1498: Openwire internal headers... Content-Type: text/plain Message-Id: <20180214130450.08494E96E4@git1-us-west.apache.org> Date: Wed, 14 Feb 2018 13:04:50 +0000 (UTC) Github user michaelandrepearce commented on a diff in the pull request: https://github.com/apache/activemq-artemis/pull/1793#discussion_r168166093 --- 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 + *

+ * 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.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()); + } + + @Override + public Message setReplyTo(SimpleString address) { + message.setReplyTo(ActiveMQDestination.createDestination(address.toString(), ActiveMQDestination.QUEUE_TYPE)); + return this; + } + + @Override + public Message setBuffer(ByteBuf buffer) { + this.data = buffer; + return this; + } + + @Override + public ByteBuf getBuffer() { + if (data == null) { + return null; + } else { + return Unpooled.wrappedBuffer(data); + } + } + + @Override + public OpenWireMessage copy() { + return new OpenWireMessage((ActiveMQMessage)message.copy(), wireFormat); + } + + @Override + public Message copy(long newID) { + OpenWireMessage copy = new OpenWireMessage((ActiveMQMessage)message.copy(), wireFormat); + copy.setMessageID(newID); + return copy; + } + + @Override + public long getMessageID() { + return message.getMessageId().getBrokerSequenceId(); + } + + @Override + public Message setMessageID(long id) { + message.getMessageId().setBrokerSequenceId(id); + return this; + } + + @Override + public long getExpiration() { + return message.getExpiration(); + } + + @Override + public Message setExpiration(long expiration) { + message.setExpiration(expiration); + return this; + } + + @Override + public Object getUserID() { + return message.getUserID(); + } + + @Override + public Message setUserID(Object userID) { + message.setUserID(userID.toString()); + return this; + } + + @Override + public boolean isDurable() { + return message.isPersistent(); + } + + @Override + public Message setDurable(boolean durable) { + message.setPersistent(durable); + return this; + } + + @Override + public Persister getPersister() { + return OpenWireMessagePersister.INSTANCE; + } + + @Override + public String getAddress() { + return message.getDestination().getPhysicalName(); + } + + @Override + public Message setAddress(String address) { + message.setDestination(ActiveMQDestination.createDestination(address, ActiveMQDestination.QUEUE_TYPE)); + return this; + } + + @Override + public SimpleString getAddressSimpleString() { + return SimpleString.toSimpleString(message.getDestination().getPhysicalName()); + } + + @Override + public Message setAddress(SimpleString address) { + message.setDestination(ActiveMQDestination.createDestination(address.toString(), ActiveMQDestination.QUEUE_TYPE)); + return this; + } + + @Override + public long getTimestamp() { + return message.getTimestamp(); + } + + @Override + public Message setTimestamp(long timestamp) { + message.setTimestamp(timestamp); + return this; + } + + @Override + public byte getPriority() { + return message.getPriority(); + } + + @Override + public Message setPriority(byte priority) { + message.setPriority(priority); + return this; + } + + @Override + public void receiveBuffer(ByteBuf buffer) { + + } + + @Override + public void sendBuffer(ByteBuf buffer, int deliveryCount) { --- End diff -- Needs implementing? ---