本文整理了Java中org.apache.qpid.proton.message.Message.getContentType()
方法的一些代码示例,展示了Message.getContentType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getContentType()
方法的具体详情如下:
包路径:org.apache.qpid.proton.message.Message
类名称:Message
方法名:getContentType
暂无
代码示例来源:origin: eclipse/hono
/**
* Gets the content type of the AMQP 1.0 message.
*
* @return The content type of the AMQP 1.0 message.
*/
String getMessageContentType() {
return message.getContentType();
}
代码示例来源:origin: apache/activemq-artemis
/**
* Check whether the content-type field of the properties section (if present) in the given
* message matches the provided string (where null matches if there is no content type
* present.
*
* @param contentType
* content type string to compare against, or null if none
* @param message
* the AMQP message object that is being examined.
*
* @return true if content type matches
*/
public static boolean isContentType(String contentType, Message message) {
if (contentType == null) {
return message.getContentType() == null;
} else {
return contentType.equals(message.getContentType());
}
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
/**
* Check whether the content-type field of the properties section (if present) in
* the given message matches the provided string (where null matches if there is
* no content type present.
*
* @param contentType
* content type string to compare against, or null if none
* @param message
* the AMQP message object that is being examined.
*
* @return true if content type matches
*/
public static boolean isContentType(String contentType, Message message) {
if (contentType == null) {
return message.getContentType() == null;
} else {
return contentType.equals(message.getContentType());
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
/**
* Check whether the content-type field of the properties section (if present) in
* the given message matches the provided string (where null matches if there is
* no content type present.
*
* @param contentType
* content type string to compare against, or null if none
* @param message
* the AMQP message object that is being examined.
*
* @return true if content type matches
*/
public static boolean isContentType(String contentType, Message message) {
if (contentType == null) {
return message.getContentType() == null;
} else {
return contentType.equals(message.getContentType());
}
}
代码示例来源:origin: org.apache.activemq/artemis-amqp-protocol
/**
* Check whether the content-type field of the properties section (if present) in the given
* message matches the provided string (where null matches if there is no content type
* present.
*
* @param contentType
* content type string to compare against, or null if none
* @param message
* the AMQP message object that is being examined.
*
* @return true if content type matches
*/
public static boolean isContentType(String contentType, Message message) {
if (contentType == null) {
return message.getContentType() == null;
} else {
return contentType.equals(message.getContentType());
}
}
代码示例来源:origin: org.eclipse.hono/hono-client
/**
* Gets the type of this command's payload.
*
* @return The content type or {@code null} if not set.
* @throws IllegalStateException if this command is invalid.
*/
public String getContentType() {
if (isValid()) {
return message.getContentType();
} else {
throw new IllegalStateException("command is invalid");
}
}
代码示例来源:origin: eclipse/hono
private void printMessage(final String tenantId, final Message msg, final String messageType) {
if (LOG.isDebugEnabled()) {
final String content = MessageHelper.getPayloadAsString(msg);
final String deviceId = MessageHelper.getDeviceId(msg);
final StringBuilder sb = new StringBuilder("received ").
append(messageType).
append(" [tenant: ").append(tenantId).
append(", device: ").append(deviceId).
append(", content-type: ").append(msg.getContentType()).
append(" ]: [").append(content).append("].");
LOG.debug(sb.toString());
}
}
代码示例来源:origin: eclipse/hono
private void handleMessage(final String endpoint, final Message msg) {
final String deviceId = MessageHelper.getDeviceId(msg);
final Buffer payload = MessageHelper.getPayload(msg);
LOG.info("received {} message [device: {}, content-type: {}]: {}", endpoint, deviceId, msg.getContentType(),
payload);
if (msg.getApplicationProperties() != null) {
LOG.info("... with application properties: {}", msg.getApplicationProperties().getValue());
}
}
代码示例来源:origin: org.eclipse.hono/hono-service-base
if (Strings.isNullOrEmpty(message.getContentType()) && String.class.isInstance(prop.getValue())) {
代码示例来源:origin: eclipse/hono
if (Strings.isNullOrEmpty(message.getContentType()) && String.class.isInstance(prop.getValue())) {
代码示例来源:origin: org.eclipse.hono/hono-server
@Override
public void processMessage(final UpstreamReceiver client, final ProtonDelivery delivery, final Message data) {
LinkStatus status = statusMap.get(client.getLinkId());
if (status == null) {
LOG.debug("creating new link status object [{}]", client.getLinkId());
status = new LinkStatus(client);
statusMap.put(client.getLinkId(), status);
}
LOG.debug("processing telemetry data [id: {}, to: {}, content-type: {}]", data.getMessageId(), data.getAddress(),
data.getContentType());
if (messageConsumer != null) {
messageConsumer.accept(data);
}
ProtonHelper.accepted(delivery, true);
status.onMsgReceived();
}
代码示例来源:origin: eclipse/hono
/**
* Adds JMS vendor properties defined by
* <a href="https://www.oasis-open.org/committees/download.php/60574/amqp-bindmap-jms-v1.0-wd09.pdf"> AMQP JMS
* Mapping 1.0</a> as AMQP 1.0 application properties to a given message.
* <p>
* The following vendor properties are added (if the message has a corresponding non-null value set):
* <ul>
* <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_TYPE}</li>
* <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_ENCODING}</li>
* </ul>
*
* @param msg the message to add the vendor properties to.
*/
public static void addJmsVendorProperties(final Message msg) {
if (!Strings.isNullOrEmpty(msg.getContentType())) {
MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_TYPE, msg.getContentType());
}
if (!Strings.isNullOrEmpty(msg.getContentEncoding())) {
MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_ENCODING, msg.getContentEncoding());
}
}
代码示例来源:origin: org.eclipse.hono/hono-core
/**
* Adds JMS vendor properties defined by
* <a href="https://www.oasis-open.org/committees/download.php/60574/amqp-bindmap-jms-v1.0-wd09.pdf"> AMQP JMS
* Mapping 1.0</a> as AMQP 1.0 application properties to a given message.
* <p>
* The following vendor properties are added (if the message has a corresponding non-null value set):
* <ul>
* <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_TYPE}</li>
* <li>{@link #JMS_VENDOR_PROPERTY_CONTENT_ENCODING}</li>
* </ul>
*
* @param msg the message to add the vendor properties to.
*/
public static void addJmsVendorProperties(final Message msg) {
if (!Strings.isNullOrEmpty(msg.getContentType())) {
MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_TYPE, msg.getContentType());
}
if (!Strings.isNullOrEmpty(msg.getContentEncoding())) {
MessageHelper.addProperty(msg, JMS_VENDOR_PROPERTY_CONTENT_ENCODING, msg.getContentEncoding());
}
}
代码示例来源:origin: org.eclipse.hono/hono-server
return false;
} else if (msg.getBody() != null) {
if (msg.getContentType() == null || !msg.getContentType().startsWith("application/json")) {
LOG.trace("message [{}] content type is not JSON", msg.getMessageId());
return false;
代码示例来源:origin: org.eclipse.hono/hono-server
/**
* Checks whether a given telemetry message contains all required properties.
* <p>
* For successful verification, the message must meet the following conditions
* <ul>
* <li>All conditions defined by {@link #verifyStandardProperties(ResourceIdentifier, Message)}</li>
* <li>The message must have its {@code content-type} property set.</li>
* <li>The message must have an AMQP {@code Data} typed body.</li>
* </ul>
*
* @param linkTarget the link target address to match the telemetry message's properties against.
* @param msg the message to verify.
* @return {@code true} if the given message complies with the <em>Telemetry</em> API specification, {@code false}
* otherwise.
*/
public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) {
if (!verifyStandardProperties(linkTarget, msg)) {
return false;
} else if (msg.getContentType() == null) {
LOG.trace("message [{}] has no content type", msg.getMessageId());
return false;
} else if (msg.getBody() == null || !(msg.getBody() instanceof Data)) {
LOG.trace("message [{}] has no body of type AMQP Data", msg.getMessageId());
return false;
} else {
return true;
}
}
}
代码示例来源:origin: org.eclipse.hono/hono-client
private R getRequestResponseResult(final Message message) {
final Integer status = MessageHelper.getApplicationProperty(
message.getApplicationProperties(),
MessageHelper.APP_PROPERTY_STATUS,
Integer.class);
if (status == null) {
return null;
} else {
final CacheDirective cacheDirective = CacheDirective.from(MessageHelper.getCacheDirective(message));
return getResult(status, message.getContentType(), MessageHelper.getPayload(message), cacheDirective);
}
}
代码示例来源:origin: org.eclipse.hono/hono-server
msg.getMessageId(), msg.getAddress(), msg.getContentType(), getDownstreamContainer(), sender.getCredit(), sender.getQueued());
forwardMessage(sender, msg, delivery);
代码示例来源:origin: eclipse/hono
/**
* Verifies that the registered default content type is set on a downstream message.
*/
@Test
public void testAddPropertiesAddsDefaultContentType() {
final Message message = ProtonHelper.message();
adapter.addProperties(message, newRegistrationAssertionResult("token", "application/hono"));
assertThat(MessageHelper.getRegistrationAssertion(message), is("token"));
assertThat(message.getContentType(), is("application/hono"));
}
代码示例来源:origin: eclipse/hono
/**
* Verifies that the fall back content type is set on a downstream message
* if no default has been configured for the device.
*/
@Test
public void testAddPropertiesAddsFallbackContentType() {
final Message message = ProtonHelper.message();
adapter.addProperties(message, newRegistrationAssertionResult("token"));
assertThat(MessageHelper.getRegistrationAssertion(message), is("token"));
assertThat(message.getContentType(), is(AbstractProtocolAdapterBase.CONTENT_TYPE_OCTET_STREAM));
}
代码示例来源:origin: eclipse/hono
/**
* Verifies that the registered default content type is not set on a downstream message
* that already contains a content type.
*/
@Test
public void testAddPropertiesDoesNotAddDefaultContentType() {
final Message message = ProtonHelper.message();
message.setContentType("application/existing");
adapter.addProperties(message, newRegistrationAssertionResult("token", "application/hono"));
assertThat(MessageHelper.getRegistrationAssertion(message), is("token"));
assertThat(message.getContentType(), is("application/existing"));
}
内容来源于网络,如有侵权,请联系作者删除!