AMQ-6183 Add isDispatchSync to the subscription view and deprecate the

meaningless one in the producer view
This commit is contained in:
Timothy Bish 2016-02-24 17:25:01 -05:00
parent bc960f3a7e
commit c2ad0c3251
5 changed files with 67 additions and 4 deletions

View File

@ -124,16 +124,15 @@ public class ProducerView implements ProducerViewMBean {
}
@Override
@Deprecated
public boolean isDispatchAsync() {
if (info != null) {
return info.isDispatchAsync();
}
return false;
}
/**
* @return pretty print
*/
@Override
public String toString() {
return "ProducerView: " + getClientId() + ":" + getConnectionId();
}

View File

@ -73,8 +73,10 @@ public interface ProducerViewMBean {
int getProducerWindowSize();
/**
* @deprecated This value is no longer used for producers.
* @return if the Producer is configured for Async dispatch
*/
@Deprecated
@MBeanInfo("Is the producer configured for Async Dispatch")
boolean isDispatchAsync();

View File

@ -266,6 +266,15 @@ public class SubscriptionView implements SubscriptionViewMBean {
return info != null ? info.isNoLocal() : false;
}
/**
* @return whether or not the subscriber is configured for async dispatch
*/
@Override
public boolean isDispatchAsync() {
ConsumerInfo info = getConsumerInfo();
return info != null ? info.isDispatchAsync() : false;
}
/**
* @return the maximum number of pending messages allowed in addition to the
* prefetch size. If enabled to a non-zero value then this will

View File

@ -160,6 +160,12 @@ public interface SubscriptionViewMBean {
@MBeanInfo("The subscription ignores local messages.")
boolean isNoLocal();
/**
* @return if the Consumer is configured for Async dispatch
*/
@MBeanInfo("Is the consumer configured for Async Dispatch")
boolean isDispatchAsync();
/**
* @return the maximum number of pending messages allowed in addition to the
* prefetch size. If enabled to a non-zero value then this will

View File

@ -1790,4 +1790,51 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
assertEquals(1, subscriberView.getDequeueCounter());
}
}
}
public void testSubscriptionViewProperties() throws Exception {
connection = createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic1 = session.createTopic("test.topic1?consumer.dispatchAsync=false&consumer.retroactive=true");
Topic topic2 = session.createTopic("test.topic2?consumer.dispatchAsync=true&consumer.retroactive=false&consumer.exclusive=true");
MessageConsumer consumer1 = session.createConsumer(topic1);
MessageConsumer consumer2 = session.createConsumer(topic2);
assertNotNull(consumer1);
assertNotNull(consumer2);
ObjectName topicObjName = assertRegisteredObjectName(
domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + topic1.getTopicName());
final TopicViewMBean topic1View = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName, TopicViewMBean.class, true);
ArrayList<SubscriptionViewMBean> subscriberViews = new ArrayList<SubscriptionViewMBean>();
for (ObjectName name : topic1View.getSubscriptions()) {
subscriberViews.add(MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true));
}
assertEquals(1, subscriberViews.size());
SubscriptionViewMBean subscription = subscriberViews.get(0);
assertFalse(subscription.isDispatchAsync());
assertTrue(subscription.isRetroactive());
assertFalse(subscription.isExclusive());
topicObjName = assertRegisteredObjectName(
domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + topic2.getTopicName());
final TopicViewMBean topic2View = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName, TopicViewMBean.class, true);
subscriberViews = new ArrayList<SubscriptionViewMBean>();
for (ObjectName name : topic2View.getSubscriptions()) {
subscriberViews.add(MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true));
}
assertEquals(1, subscriberViews.size());
subscription = subscriberViews.get(0);
assertTrue(subscription.isDispatchAsync());
assertFalse(subscription.isRetroactive());
assertTrue(subscription.isExclusive());
}
}