mirror of https://github.com/apache/activemq.git
Applied John Sission's patch: https://issues.apache.org/activemq/browse/AMQ-705 Thanks John!
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@399701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b36e9f804a
commit
3fc0546936
|
@ -381,6 +381,13 @@ public class ActiveMQActivationSpec implements ActivationSpec, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidSubscriptionDurability(List errorMessages) {
|
private boolean isValidSubscriptionDurability(List errorMessages) {
|
||||||
|
// subscriptionDurability only applies to Topics
|
||||||
|
if ( DURABLE_SUBSCRIPTION.equals(subscriptionDurability) &&
|
||||||
|
getDestinationType() != null && !Topic.class.getName().equals(getDestinationType())) {
|
||||||
|
errorMessages.add("subscriptionDurability cannot be set to: "+DURABLE_SUBSCRIPTION+" when destinationType is set to "+
|
||||||
|
Queue.class.getName()+" as it is only valid when destinationType is set to "+Topic.class.getName()+".");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (NON_DURABLE_SUBSCRIPTION.equals(subscriptionDurability) || DURABLE_SUBSCRIPTION.equals(subscriptionDurability))
|
if (NON_DURABLE_SUBSCRIPTION.equals(subscriptionDurability) || DURABLE_SUBSCRIPTION.equals(subscriptionDurability))
|
||||||
return true;
|
return true;
|
||||||
errorMessages.add("subscriptionDurability must be set to: "+NON_DURABLE_SUBSCRIPTION+" or "+DURABLE_SUBSCRIPTION+".");
|
errorMessages.add("subscriptionDurability must be set to: "+NON_DURABLE_SUBSCRIPTION+" or "+DURABLE_SUBSCRIPTION+".");
|
||||||
|
|
|
@ -197,6 +197,7 @@ public class ActiveMQActivationSpecTest extends TestCase {
|
||||||
|
|
||||||
//----------- durable subscriber tests
|
//----------- durable subscriber tests
|
||||||
public void testValidDurableSubscriber() {
|
public void testValidDurableSubscriber() {
|
||||||
|
activationSpec.setDestinationType(Topic.class.getName());
|
||||||
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
||||||
activationSpec.setClientId("foobar");
|
activationSpec.setClientId("foobar");
|
||||||
activationSpec.setSubscriptionName("foobar");
|
activationSpec.setSubscriptionName("foobar");
|
||||||
|
@ -204,7 +205,17 @@ public class ActiveMQActivationSpecTest extends TestCase {
|
||||||
assertTrue(activationSpec.isDurableSubscription());
|
assertTrue(activationSpec.isDurableSubscription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDurableSubscriberWithQueueDestinationTypeFailure() {
|
||||||
|
activationSpec.setDestinationType(Queue.class.getName());
|
||||||
|
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
||||||
|
activationSpec.setClientId("foobar");
|
||||||
|
activationSpec.setSubscriptionName("foobar");
|
||||||
|
PropertyDescriptor[] expected = {subscriptionDurabilityProperty};
|
||||||
|
assertActivationSpecInvalid(expected);
|
||||||
|
}
|
||||||
|
|
||||||
public void testDurableSubscriberNoClientIdNoSubscriptionNameFailure() {
|
public void testDurableSubscriberNoClientIdNoSubscriptionNameFailure() {
|
||||||
|
activationSpec.setDestinationType(Topic.class.getName());
|
||||||
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
||||||
activationSpec.setClientId(null);
|
activationSpec.setClientId(null);
|
||||||
assertNull(activationSpec.getClientId());
|
assertNull(activationSpec.getClientId());
|
||||||
|
@ -215,6 +226,7 @@ public class ActiveMQActivationSpecTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDurableSubscriberEmptyClientIdEmptySubscriptionNameFailure() {
|
public void testDurableSubscriberEmptyClientIdEmptySubscriptionNameFailure() {
|
||||||
|
activationSpec.setDestinationType(Topic.class.getName());
|
||||||
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
activationSpec.setSubscriptionDurability(ActiveMQActivationSpec.DURABLE_SUBSCRIPTION);
|
||||||
activationSpec.setClientId(EMPTY_STRING);
|
activationSpec.setClientId(EMPTY_STRING);
|
||||||
assertNull(activationSpec.getClientId());
|
assertNull(activationSpec.getClientId());
|
||||||
|
|
Loading…
Reference in New Issue