Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Content Type to Az Service Bus Sampler #8

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
);
}


}
}