Skip to content

Commit

Permalink
Merge pull request #8 from MalachiMcintosh/master
Browse files Browse the repository at this point in the history
Add Content Type to Az Service Bus Sampler
  • Loading branch information
kuniteru committed Jun 6, 2022
2 parents 1e012d1 + c1133e0 commit e202482
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class AzAmqpMessage extends AbstractTestElement {
private static final String GROUP_ID = "Message.groupId"; //$NON-NLS$
private static final String PARTITION_KEY = "Message.partitionKey"; //$NON-NLS$
private static final String CUSTOM_PROPERTIES = "Message.customProperties"; //$NON-NLS$
private static final String CONTENT_TYPE = "Message.contentType"; //$NON-NLS$

public AzAmqpMessage() {
}
Expand All @@ -52,6 +53,7 @@ public AzAmqpMessage(String messageType) {
setProperty(new StringProperty(MESSAGE_ID, ""));
setProperty(new StringProperty(GROUP_ID, ""));
setProperty(new StringProperty(CUSTOM_PROPERTIES, ""));
setProperty(new StringProperty(CONTENT_TYPE, ""));
}

/**
Expand Down Expand Up @@ -168,4 +170,23 @@ public String getCustomProperties() {
return getPropertyAsString(CUSTOM_PROPERTIES);
}

/**
* Set the content type of the Message.
*
* @param contentType
* the new content type
*/
public void setContentType(String contentType) {
setProperty(new StringProperty(CONTENT_TYPE, contentType));
}

/**
* Get the content type.
*
* @return the content type
*/
public String getContentType() {
return getPropertyAsString(CONTENT_TYPE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class AzAmqpMessagesPanel extends AbstractSamplerGui implements ActionLis
COLUMN_NAMES.put("MESSAGE_ID", "message Id"); //$NON-NLS-1$
COLUMN_NAMES.put("GROUP_ID", "group Id"); //$NON-NLS-1$
COLUMN_NAMES.put("CUSTOM_PROPERTIES", "custom properties"); //$NON-NLS-1$
COLUMN_NAMES.put("CONTENT_TYPE", "content type"); //$NON-NLS-1$
}

public AzAmqpMessagesPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ public SampleResult sample(Entry e) {
Map<String, Object> properties = mapper.readValue(customProperties, new TypeReference<Map<String, Object>>(){});
serviceBusMessage.getApplicationProperties().putAll(properties);
}

String contentType = msg.getContentType();
if (!contentType.isEmpty()) {
serviceBusMessage.setContentType(contentType);
requestBody = requestBody.concat("\n").concat("Content Type: ").concat(contentType);
}

batch.tryAddMessage(serviceBusMessage);
bodyBytes += serviceBusMessage.getBody().toBytes().length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ public AzServiceBusMessagesPanel() {
@Override
protected void initializeTableModel() {
tableModel = new ObjectTableModel(
new String[] { COLUMN_NAMES.get("MESSAGE_TYPE"), COLUMN_NAMES.get("MESSAGE"), COLUMN_NAMES.get("MESSAGE_ID"), "session Id", "partition key", COLUMN_NAMES.get("CUSTOM_PROPERTIES") },
new String[] { COLUMN_NAMES.get("MESSAGE_TYPE"), COLUMN_NAMES.get("MESSAGE"), COLUMN_NAMES.get("MESSAGE_ID"), "session Id", "partition key", COLUMN_NAMES.get("CUSTOM_PROPERTIES"), COLUMN_NAMES.get("CONTENT_TYPE") },
AzAmqpMessage.class,
new Functor[] { new Functor("getMessageType"), new Functor("getMessage"), new Functor("getMessageId"), new Functor("getGroupId"), new Functor("getPartitionKey"), new Functor("getCustomProperties") },
new Functor[] { new Functor("setMessageType"), new Functor("setMessage"), new Functor("setMessageId"), new Functor("setGroupId"), new Functor("setPartitionKey"), new Functor("setCustomProperties") },
new Class[] { String.class, String.class, String.class, String.class, String.class, String.class }
new Functor[] { new Functor("getMessageType"), new Functor("getMessage"), new Functor("getMessageId"), new Functor("getGroupId"), new Functor("getPartitionKey"), new Functor("getCustomProperties"), new Functor("getContentType") },
new Functor[] { new Functor("setMessageType"), new Functor("setMessage"), new Functor("setMessageId"), new Functor("setGroupId"), new Functor("setPartitionKey"), new Functor("setCustomProperties"), new Functor("setContentType") },
new Class[] { String.class, String.class, String.class, String.class, String.class, String.class, String.class }
);
}


}
}

0 comments on commit e202482

Please sign in to comment.