[
https://issues.apache.org/jira/browse/ARTEMIS-3113?focusedWorklogId=551268&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-551268
]
ASF GitHub Bot logged work on ARTEMIS-3113:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Feb/21 12:07
Start Date: 11/Feb/21 12:07
Worklog Time Spent: 10m
Work Description: clebertsuconic commented on a change in pull request
#3450:
URL: https://github.com/apache/activemq-artemis/pull/3450#discussion_r574449982
##########
File path:
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/coreWrapper/CoreMapMessageWrapper.java
##########
@@ -0,0 +1,231 @@
+/*
+ * 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.coreWrapper;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+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.SimpleString;
+import org.apache.activemq.artemis.protocol.amqp.converter.AMQPMessageSupport;
+import org.apache.activemq.artemis.utils.collections.TypedProperties;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.UnsignedShort;
+import org.apache.qpid.proton.amqp.messaging.AmqpValue;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+import org.apache.qpid.proton.amqp.messaging.Section;
+
+import static org.apache.activemq.artemis.reader.MapMessageUtil.readBodyMap;
+import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap;
+
+public final class CoreMapMessageWrapper extends CoreMessageWrapper {
+ // Constants -----------------------------------------------------
+
+ public static final byte TYPE = Message.MAP_TYPE;
+
+ // Attributes ----------------------------------------------------
+
+ private final TypedProperties map = new TypedProperties();
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /*
+ * This constructor is used to construct messages prior to sending
+ */
+ public CoreMapMessageWrapper(ICoreMessage message) {
+ super(message);
+
+ }
+
+ private static Map<String, Object>
getMapFromMessageBody(CoreMapMessageWrapper message) {
+ final HashMap<String, Object> map = new LinkedHashMap<>();
+
+ @SuppressWarnings("unchecked")
+ final Enumeration<String> names = message.getMapNames();
+ while (names.hasMoreElements()) {
+ String key = names.nextElement();
+ Object value = message.getObject(key);
+ if (value instanceof byte[]) {
+ value = new Binary((byte[]) value);
+ }
+ map.put(key, value);
+ }
+
+ return map;
+ }
+
+ @Override
+ public Section createAMQPSection(Map<Symbol, Object> maMap, Properties
properties) {
+ maMap.put(AMQPMessageSupport.JMS_MSG_TYPE,
AMQPMessageSupport.JMS_MAP_MESSAGE);
+ return new AmqpValue(getMapFromMessageBody(this));
+ }
+
+ public void setBoolean(final String name, final boolean value) {
+ map.putBooleanProperty(new SimpleString(name), value);
+ }
+
+ public void setByte(final String name, final byte value) {
+ map.putByteProperty(new SimpleString(name), value);
+ }
+
+ public void setShort(final String name, final short value) {
+ map.putShortProperty(new SimpleString(name), value);
+ }
+
+ public void setChar(final String name, final char value) {
+ map.putCharProperty(new SimpleString(name), value);
+ }
+
+ public void setInt(final String name, final int value) {
+ map.putIntProperty(new SimpleString(name), value);
+ }
+
+ public void setLong(final String name, final long value) {
+ map.putLongProperty(new SimpleString(name), value);
+ }
+
+ public void setFloat(final String name, final float value) {
+ map.putFloatProperty(new SimpleString(name), value);
+ }
+
+ public void setDouble(final String name, final double value) {
+ map.putDoubleProperty(new SimpleString(name), value);
+ }
+
+ public void setString(final String name, final String value) {
+ map.putSimpleStringProperty(new SimpleString(name), value == null ? null
: new SimpleString(value));
Review comment:
not part of my change but ok
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 551268)
Time Spent: 13h (was: 12h 50m)
> Artemis AMQP shouldn't depend on JMS
> ------------------------------------
>
> Key: ARTEMIS-3113
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3113
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: AMQP
> Affects Versions: 2.16.0
> Reporter: Emmanuel Hugonnet
> Priority: Major
> Time Spent: 13h
> Remaining Estimate: 0h
>
> The converters between core messages and amqp messages depend on JMS. Since
> this is just for convenience we should remove this dependecy on an API that
> is being replaced.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)