[
https://issues.apache.org/jira/browse/ARTEMIS-4648?focusedWorklogId=907127&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-907127
]
ASF GitHub Bot logged work on ARTEMIS-4648:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 27/Feb/24 10:07
Start Date: 27/Feb/24 10:07
Worklog Time Spent: 10m
Work Description: gemmellr commented on code in PR #4824:
URL: https://github.com/apache/activemq-artemis/pull/4824#discussion_r1503959087
##########
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:
This is missing a default case, which would be useful for when someone
inevitably typos the type name, or just uses e.g the proper class name such as
String (could also just handle that one by lower-casing the type before).
Issue Time Tracking
-------------------
Worklog Id: (was: 907127)
Time Spent: 40m (was: 0.5h)
> 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: 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)