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


Java MessageProperties.setDeliveryMode方法代码示例

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


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

示例1: toMessageProperties

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
@Override
public MessageProperties toMessageProperties(AMQP.BasicProperties source, Envelope envelope,
		String charset) {
	MessageProperties properties = super.toMessageProperties(source, envelope, charset);
	properties.setDeliveryMode(null);
	return properties;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:8,代码来源:RabbitMessageChannelBinder.java

示例2: sendMessage

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
/**
 * Send a message to a queue with corrId, delay and potential replyQueue
 *
 * @param requestMessage
 * @param queueName
 * @param correlationId
 * @param replyQueue
 * @param delaySeconds
 * @throws JMSException
 */
public void sendMessage(String requestMessage, String queueName, String correlationId,
        final Queue replyQueue, int delaySeconds, int deliveryMode) throws JMSException {
    /**
     * If it's an internal message then always use jmsTemplate for ActiveMQ
     */

    if (rabbitTemplate != null) {
        MessageProperties messageProperties = new MessageProperties();
        String targetQueueName = queueName;
        if (delaySeconds > 0) {
            /**
             * For RabbitMQ, you can set a TTL (TimeToLive) on the message
             * properties
             */
            targetQueueName = "com.centurylink.mdw.process.delay.queue";
            messageProperties.setExpiration(String.valueOf(delaySeconds * 1000));
        }
        messageProperties.setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
        if (replyQueue != null) {
            rabbitTemplate.setReplyQueue(new org.springframework.amqp.core.Queue(replyQueue
                    .getQueueName()));
        }
        rabbitTemplate.send(getExchange(targetQueueName), targetQueueName, new Message(
                requestMessage.getBytes(), messageProperties), new CorrelationData(
                correlationId));

        /**
         * new MDWMessageCreator(requestMessage, correlationId, replyQueue,
         * delaySeconds). if (!StringUtils.isEmpty(queueName)) {
         * rabbitTemplate.send(queueName, routingKey, new
         * Message(requestMessage.getBytes(), messageProperties),
         * correlationData);
         *
         * } else { rabbitTemplate.send(new
         * MDWMessageCreator(requestMessage, correlationId, replyQueue)); }
         */
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:49,代码来源:RabbitMessageProducer.java

示例3: 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

示例4: sendMessage

import org.springframework.amqp.core.MessageProperties; //导入方法依赖的package包/类
/**
 * Send a message to a queue with corrId, delay and potential replyQueue
 *
 * @param requestMessage
 * @param queueName
 * @param correlationId
 * @param replyQueue
 * @param delaySeconds
 * @throws JMSException
 */
public void sendMessage(String requestMessage, String queueName, String correlationId,
        final Queue replyQueue, int delaySeconds, int deliveryMode) throws JMSException {
    /**
     * If it's an internal message then always use jmsTemplate for ActiveMQ
     */

    if (jmsTemplate != null) {
        jmsTemplate.setDeliveryMode(deliveryMode);
        if (!StringUtils.isEmpty(queueName)) {
            jmsTemplate.send(queueName, new MDWMessageCreator(requestMessage, correlationId,
                    replyQueue, delaySeconds));

        }
        else {
            jmsTemplate.send(new MDWMessageCreator(requestMessage, correlationId, replyQueue));
        }
    }
    else if (rabbitTemplate != null) {
        MessageProperties messageProperties = new MessageProperties();
        String targetQueueName = queueName;
        if (delaySeconds > 0) {
            /**
             * For RabbitMQ, you can set a TTL (TimeToLive)
             * on the message properties
             */
            targetQueueName="com.centurylink.mdw.process.delay.queue";
            messageProperties.setExpiration(String.valueOf(delaySeconds * 1000));
        }
        messageProperties.setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
        if (replyQueue != null) {
            rabbitTemplate.setReplyQueue(new org.springframework.amqp.core.Queue(replyQueue
                    .getQueueName()));
        }
        rabbitTemplate.send(getExchange(targetQueueName), targetQueueName,
                new Message(requestMessage.getBytes(), messageProperties), new CorrelationData(
                        correlationId));

        /**
         * new MDWMessageCreator(requestMessage, correlationId, replyQueue,
         * delaySeconds). if (!StringUtils.isEmpty(queueName)) {
         * rabbitTemplate.send(queueName, routingKey, new
         * Message(requestMessage.getBytes(), messageProperties),
         * correlationData);
         *
         * } else { rabbitTemplate.send(new
         * MDWMessageCreator(requestMessage, correlationId, replyQueue)); }
         */
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:60,代码来源:MDWMessageProducer.java


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