Reuse QosSettings in JmsTemplate

See SPR-15408
This commit is contained in:
Stephane Nicoll
2017-04-18 13:32:53 +02:00
parent a2acbee004
commit 4ffdb50681
2 changed files with 25 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import org.springframework.jms.JmsException;
import org.springframework.jms.connection.ConnectionFactoryUtils;
import org.springframework.jms.connection.JmsResourceHolder;
import org.springframework.jms.support.JmsUtils;
import org.springframework.jms.support.QosSettings;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.SimpleMessageConverter;
import org.springframework.jms.support.destination.JmsDestinationAccessor;
@@ -364,6 +365,23 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
return this.explicitQosEnabled;
}
/**
* Set the {@link QosSettings} to use when sending a message.
* @param settings the deliveryMode, priority, and timeToLive settings to use
* @see #setExplicitQosEnabled(boolean)
* @see #setDeliveryMode(int)
* @see #setPriority(int)
* @see #setTimeToLive(long)
* @since 5.0
*/
public void setQosSettings(QosSettings settings) {
Assert.notNull(settings, "Settings must not be null");
setExplicitQosEnabled(true);
setDeliveryMode(settings.getDeliveryMode());
setPriority(settings.getPriority());
setTimeToLive(settings.getTimeToLive());
}
/**
* Set whether message delivery should be persistent or non-persistent,
* specified as boolean value ("true" or "false"). This will set the delivery