当前位置: 首页>>代码示例>>Java>>正文


Java MessageProperties.setContentType方法代码示例

本文整理汇总了Java中org.springframework.amqp.core.MessageProperties.setContentType方法的典型用法代码示例。如果您正苦于以下问题:Java MessageProperties.setContentType方法的具体用法?Java MessageProperties.setContentType怎么用?Java MessageProperties.setContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.amqp.core.MessageProperties的用法示例。


在下文中一共展示了MessageProperties.setContentType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkContentTypeJson

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
/**
 * Method to validate if content type is set in the message properties.
 *
 * @param message
 *            the message to get validated
 */
private void checkContentTypeJson(final Message message) {
    if (message.getBody().length == 0) {
        return;
    }
    final MessageProperties messageProperties = message.getMessageProperties();
    final String headerContentType = (String) messageProperties.getHeaders().get("content-type");
    if (null != headerContentType) {
        messageProperties.setContentType(headerContentType);
    }
    final String contentType = messageProperties.getContentType();
    if (contentType != null && contentType.contains("json")) {
        return;
    }
    throw new AmqpRejectAndDontRequeueException("Content-Type is not JSON compatible");
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:22,代码来源:DmfReceiverService.java

示例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);
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:11,代码来源:AmqpReporter.java

示例3: send

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
public void send(Document document){
	MessageProperties messageProperties = new MessageProperties();
	messageProperties.setContentType("text/xml");
	byte[] body = XmlUtils.toXML(document).getBytes();
	Message message = new Message(body, messageProperties);
	rabbitTemplate.send(message);
}
 
开发者ID:Apress,项目名称:introducing-spring-framework,代码行数:8,代码来源:RabbitMQProducer.java

示例4: ping

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
public void ping(final String tenant, final String correlationId) {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.getHeaders().put(MessageHeaderKey.TENANT, tenant);
    messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.PING.toString());
    messageProperties.setCorrelationId(correlationId.getBytes());
    messageProperties.setReplyTo(amqpProperties.getSenderForSpExchange());
    messageProperties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN);

    sendMessage(spExchange, new Message(null, messageProperties));
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:11,代码来源:DmfSenderService.java

示例5: thingCreatedMessage

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private Message thingCreatedMessage(final String tenant, final String targetId) {
    final MessageProperties messagePropertiesForSP = new MessageProperties();
    messagePropertiesForSP.setHeader(MessageHeaderKey.TYPE, MessageType.THING_CREATED.name());
    messagePropertiesForSP.setHeader(MessageHeaderKey.TENANT, tenant);
    messagePropertiesForSP.setHeader(MessageHeaderKey.THING_ID, targetId);
    messagePropertiesForSP.setHeader(MessageHeaderKey.SENDER, "simulator");
    messagePropertiesForSP.setContentType(MessageProperties.CONTENT_TYPE_JSON);
    messagePropertiesForSP.setReplyTo(amqpProperties.getSenderForSpExchange());
    return new Message(null, messagePropertiesForSP);
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:11,代码来源:DmfSenderService.java

示例6: attributeUpdateMessage

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private Message attributeUpdateMessage(final String tenant, final String targetId) {
    final MessageProperties messagePropertiesForSP = new MessageProperties();
    messagePropertiesForSP.setHeader(MessageHeaderKey.TYPE, MessageType.EVENT.name());
    messagePropertiesForSP.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ATTRIBUTES);
    messagePropertiesForSP.setHeader(MessageHeaderKey.TENANT, tenant);
    messagePropertiesForSP.setHeader(MessageHeaderKey.THING_ID, targetId);
    messagePropertiesForSP.setContentType(MessageProperties.CONTENT_TYPE_JSON);
    messagePropertiesForSP.setReplyTo(amqpProperties.getSenderForSpExchange());
    final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate();

    attributeUpdate.getAttributes().putAll(simulationProperties.getAttributes().stream().collect(
            Collectors.toMap(SimulationProperties.Attribute::getKey, SimulationProperties.Attribute::getValue)));

    return convertMessage(attributeUpdate, messagePropertiesForSP);
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:16,代码来源:DmfSenderService.java

示例7: createConnectorMessageProperties

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private static MessageProperties createConnectorMessageProperties(final String tenant, final String controllerId) {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
    messageProperties.setHeader(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON);
    messageProperties.setHeader(MessageHeaderKey.THING_ID, controllerId);
    messageProperties.setHeader(MessageHeaderKey.TENANT, tenant);
    return messageProperties;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:9,代码来源:AmqpMessageDispatcherService.java

示例8: wrongContentType

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
@Test
@Description("Tests not allowed content-type in message")
public void wrongContentType() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType("xml");
    final Message message = new Message(new byte[0], messageProperties);
    try {
        amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
        fail("AmqpRejectAndDontRequeueException was excepeted due to worng content type");
    } catch (final AmqpRejectAndDontRequeueException e) {
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:13,代码来源:AmqpMessageHandlerServiceTest.java

示例9: createMessageProperties

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private MessageProperties createMessageProperties(final MessageType type, final String replyTo) {
    final MessageProperties messageProperties = new MessageProperties();
    if (type != null) {
        messageProperties.setHeader(MessageHeaderKey.TYPE, type.name());
    }
    messageProperties.setHeader(MessageHeaderKey.TENANT, TENANT);
    messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
    messageProperties.setReplyTo(replyTo);
    return messageProperties;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:11,代码来源:AmqpMessageHandlerServiceTest.java

示例10: createMessage

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
protected Message createMessage(final Object payload, final MessageProperties messageProperties) {
    if (payload == null) {
        messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
        return new Message(null, messageProperties);
    }
    return getDmfClient().getMessageConverter().toMessage(payload, messageProperties);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:8,代码来源:AbstractAmqpIntegrationTest.java

示例11: handle

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
@Override
public void handle(ConsentSignedEvent event) {
	MessageProperties messageProperties = new MessageProperties();
	messageProperties.setHeader("messageType", event.getClass().getName());
	messageProperties.setContentType("text/plain");
	messageSender.send(event.getConsentId().toString(), messageProperties);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:8,代码来源:ConsentSignedEventHandler.java

示例12: createJsonProperties

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
private MessageProperties createJsonProperties() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
    return messageProperties;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:6,代码来源:BaseAmqpServiceTest.java


注:本文中的org.springframework.amqp.core.MessageProperties.setContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。