本文整理汇总了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)); }
*/
}
}
示例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);
}
}
示例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)); }
*/
}
}