org.apache.qpid.proton.message.Message.setContentType()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.qpid.proton.message.Message.setContentType()方法的一些代码示例,展示了Message.setContentType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setContentType()方法的具体详情如下:
包路径:org.apache.qpid.proton.message.Message
类名称:Message
方法名:setContentType

Message.setContentType介绍

暂无

代码示例

代码示例来源:origin: eclipse/hono

if (Strings.isNullOrEmpty(message.getContentType()) && String.class.isInstance(prop.getValue())) {
  message.setContentType((String) prop.getValue());

代码示例来源:origin: org.eclipse.hono/hono-service-base

if (Strings.isNullOrEmpty(message.getContentType()) && String.class.isInstance(prop.getValue())) {
  message.setContentType((String) prop.getValue());

代码示例来源:origin: eclipse/hono

/**
 * Set the payload of the message using a {@link Data} section.
 * <p>
 * If the payload is {@code null}, then neither the payload, nor content type will be set.
 * </p>
 * 
 * @param message The message to update.
 * @param contentType An optional content type.
 * @param payload The optional message payload.
 * 
 * @throws NullPointerException If the parameter {@code message} was {@code null}.
 */
public static void setPayload(final Message message, final String contentType, final byte[] payload) {
  Objects.requireNonNull(message);
  if (contentType != null) {
    message.setContentType(contentType);
  }
  if (payload != null) {
    message.setBody(new Data(new Binary(payload)));
  }
}

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Set the payload of the message using a {@link Data} section.
 * <p>
 * If the payload is {@code null}, then neither the payload, nor content type will be set.
 * </p>
 * 
 * @param message The message to update.
 * @param contentType An optional content type.
 * @param payload The optional message payload.
 * 
 * @throws NullPointerException If the parameter {@code message} was {@code null}.
 */
public static void setPayload(final Message message, final String contentType, final byte[] payload) {
  Objects.requireNonNull(message);
  if (contentType != null) {
    message.setContentType(contentType);
  }
  if (payload != null) {
    message.setBody(new Data(new Binary(payload)));
  }
}

代码示例来源:origin: com.ibm.mqlight/mqlight-api

@Override
public <T> boolean sendJson(String topic, String json,
    Map<String, Object> properties, SendOptions sendOptions,
    CompletionListener<T> listener, T context)
throws StoppedException {
  final String methodName = "sendJson";
  logger.entry(this, methodName, topic, json, properties, sendOptions, listener, context);
  org.apache.qpid.proton.message.Message protonMsg = Proton.message();
  protonMsg.setBody(new AmqpValue(json));
  protonMsg.setContentType("application/json");
  final boolean result = send(topic, protonMsg, properties, sendOptions == null ? defaultSendOptions : sendOptions, listener, context);
  logger.exit(this, methodName, result);
  return result;
}

代码示例来源:origin: Azure/azure-event-hubs-java

break;
case AmqpConstants.AMQP_PROPERTY_CONTENT_TYPE:
  amqpMessage.setContentType((String) systemProperty.getValue());
  break;
case AmqpConstants.AMQP_PROPERTY_CONTENT_ENCODING:

代码示例来源: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"));
}

代码示例来源:origin: org.eclipse.hono/hono-service-base

msg.setContentType(contentType);
if (timeUntilDisconnect != null) {
  MessageHelper.addTimeUntilDisconnect(msg, timeUntilDisconnect);

代码示例来源:origin: eclipse/hono

msg.setContentType(contentType);
if (timeUntilDisconnect != null) {
  MessageHelper.addTimeUntilDisconnect(msg, timeUntilDisconnect);

代码示例来源:origin: org.eclipse.hono/hono-service-base

message.setContentType(CONTENT_TYPE_OCTET_STREAM);

代码示例来源:origin: eclipse/hono

message.setContentType(CONTENT_TYPE_OCTET_STREAM);

代码示例来源:origin: eclipse/hono

/**
 * Verifies that a message containing a subject that does not represent
 * a Credentials API operation does not pass the filter.
 */
@Test
public void testVerifyFailsForUnknownAction() {
  // GIVEN a message with an unsupported subject
  final Message msg = givenAValidMessageWithoutBody(CredentialsConstants.CredentialsAction.unknown);
  msg.setBody(new AmqpValue(BILLIE_HASHED_PASSWORD));
  msg.setContentType("application/json");
  // WHEN receiving the message via a link with any tenant
  final boolean filterResult = CredentialsMessageFilter.verify(target, msg);
  // THEN message validation fails
  assertFalse(filterResult);
}

代码示例来源:origin: eclipse/hono

/**
 * Verifies that a message containing a non Data section body
 * does not pass the filter.
 */
@Test
public void testVerifyFailsForNonDataSectionBody() {
  // GIVEN a message with an unsupported subject
  final Message msg = givenAValidMessageWithoutBody(CredentialsConstants.CredentialsAction.get);
  msg.setBody(new AmqpValue(BILLIE_HASHED_PASSWORD.encode()));
  msg.setContentType("application/json");
  // WHEN receiving the message via a link with any tenant
  final boolean filterResult = CredentialsMessageFilter.verify(target, msg);
  // THEN message validation fails
  assertFalse(filterResult);
}

代码示例来源:origin: eclipse/hono

/**
 * Verifies that a message that does not contain a message-id nor correlation-id
 * does not pass the filter.
 */
@Test
public void testVerifyFailsForMissingCorrelationId() {
  // GIVEN a message with an unsupported subject
  final Message msg = ProtonHelper.message();
  msg.setReplyTo("reply");
  msg.setBody(new AmqpValue(BILLIE_HASHED_PASSWORD));
  msg.setContentType("application/json");
  // WHEN receiving the message via a link with any tenant
  final boolean filterResult = CredentialsMessageFilter.verify(target, msg);
  // THEN message validation fails
  assertFalse(filterResult);
}

代码示例来源:origin: eclipse/hono

/**
 * Verifies that a valid message passes the filter.
 */
@Test
public void testVerifySucceedsForValidGetAction() {
  // GIVEN a credentials message for user billie
  final Message msg = givenAValidMessageWithoutBody(CredentialsConstants.CredentialsAction.get);
  msg.setBody(new Data(new Binary(BILLIE_HASHED_PASSWORD.toBuffer().getBytes())));
  msg.setContentType("application/json");
  // WHEN receiving the message via a link with any tenant
  final boolean filterResult = CredentialsMessageFilter.verify(target, msg);
  // THEN message validation succeeds
  assertTrue(filterResult);
}

代码示例来源:origin: Azure/azure-service-bus-java

amqpMessage.setContentType(brokeredMessage.getContentType());
amqpMessage.setCorrelationId(brokeredMessage.getCorrelationId());
amqpMessage.setSubject(brokeredMessage.getLabel());

代码示例来源:origin: apache/activemq-artemis

message.getWrappedMessage().setContentType("text/plain");
message.getWrappedMessage().setBody(new Data(new Binary(messageText.getBytes(StandardCharsets.UTF_8))));

代码示例来源:origin: io.vertx/vertx-amqp-bridge

protonMsg.setGroupSequence(testGroupSeq);
protonMsg.setReplyToGroupId(testReplyToGroupId);
protonMsg.setContentType(testContentType);
protonMsg.setContentEncoding(testContentEncoding);
protonMsg.setCreationTime(testCreationTime);

相关文章