本文整理汇总了Java中org.springframework.amqp.core.MessageProperties.setContentEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java MessageProperties.setContentEncoding方法的具体用法?Java MessageProperties.setContentEncoding怎么用?Java MessageProperties.setContentEncoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.amqp.core.MessageProperties
的用法示例。
在下文中一共展示了MessageProperties.setContentEncoding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMessage
import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
protected <T> Message toMessage(T object, String correlationId, boolean isOnlySend) {
if (object == null) {
return null;
}
if (object instanceof Message) {
return (Message) object;
}
MessageProperties messageProperties = new MessageProperties();
messageProperties.setMessageId(UUID.randomUUID().toString());
messageProperties.setContentEncoding(DEFAULT_CHARSET);
try {
if (!isOnlySend) {
if (correlationId == null) {
messageProperties.setCorrelationId(UUID.randomUUID().toString().getBytes(DEFAULT_CHARSET));
} else {
messageProperties.setCorrelationId(correlationId.getBytes(DEFAULT_CHARSET));
}
}
byte[] bytes = getBytesAndSetMessageProperties(object, messageProperties);
return new Message(bytes, messageProperties);
} catch (Exception warnException) {
throw new RuntimeException("#####��Ϣת��ʧ��", warnException);
}
}
示例2: processMessageProperties
import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private void processMessageProperties(MessageProperties messageProperties) {
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
messageProperties.setContentEncoding("UTF-8");
messageProperties.setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
messageProperties.setHeader(MessageHeaders.HOST, OSUtils.getHostName());
messageProperties.setAppId(AppInfo.getApplicationName());
if(this.messagePropertiesCallback != null) {
this.messagePropertiesCallback.call(messageProperties);
}
}