[ 
https://issues.apache.org/jira/browse/ARTEMIS-4648?focusedWorklogId=907468&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-907468
 ]

ASF GitHub Bot logged work on ARTEMIS-4648:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 29/Feb/24 05:26
            Start Date: 29/Feb/24 05:26
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #4824:
URL: https://github.com/apache/activemq-artemis/pull/4824#discussion_r1507026878


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java:
##########
@@ -190,6 +195,43 @@ protected Message createMessage(long i, String threadName) 
throws Exception {
 
       answer.setLongProperty("count", i);
       answer.setStringProperty("ThreadSent", threadName);
+
+      if (properties != null && properties.length() != 0) {
+         JsonArray propertyArray = JsonLoader.readArray(new 
StringReader(properties));
+         for (int j = 0; j < propertyArray.size(); j++) {
+            JsonObject propertyEntry = propertyArray.getJsonObject(j);
+            String type = propertyEntry.getString("type");
+            String key = propertyEntry.getString("key");
+            String value = propertyEntry.getString("value");
+            switch (type) {
+               case "boolean":
+                  answer.setBooleanProperty(key, Boolean.parseBoolean(value));
+                  break;
+               case "int":
+                  answer.setIntProperty(key, Integer.parseInt(value));
+                  break;
+               case "long":
+                  answer.setLongProperty(key, Long.parseLong(value));
+                  break;
+               case "byte":
+                  answer.setByteProperty(key, Byte.parseByte(value));
+                  break;
+               case "short":
+                  answer.setShortProperty(key, Short.parseShort(value));
+                  break;
+               case "float":
+                  answer.setFloatProperty(key, Float.parseFloat(value));
+                  break;
+               case "double":
+                  answer.setDoubleProperty(key, Double.parseDouble(value));
+                  break;
+               case "string":
+                  answer.setStringProperty(key, value);
+                  break;
+            }

Review Comment:
   Done. I also added a new test to make sure incorrect types are dealt with 
properly.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 907468)
    Time Spent: 1h 20m  (was: 1h 10m)

> Support typed properties on CLI producer
> ----------------------------------------
>
>                 Key: ARTEMIS-4648
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4648
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to