diff options
| author | Andrea Gazzarini <agazzarini@apache.org> | 2009-02-26 13:52:33 +0000 |
|---|---|---|
| committer | Andrea Gazzarini <agazzarini@apache.org> | 2009-02-26 13:52:33 +0000 |
| commit | 244c8e31c6073d7db5b79cccf1decba830a0c85e (patch) | |
| tree | 20955d4197dd87483adb092a9e6d0ba1d57e9fc6 /java/management/client/src/example/org | |
| parent | 09ce45e0164e0be383b427c6f42c93908f274024 (diff) | |
| download | qpid-python-244c8e31c6073d7db5b79cccf1decba830a0c85e.tar.gz | |
QPID-1579 : Instead of having one huge WSDM test case now WS-DM Adapter test is a suite that contains different test cases ( one for each interface)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@748154 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/client/src/example/org')
| -rw-r--r-- | java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java b/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java index 93e78707e9..9b4a24e2ae 100644 --- a/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java +++ b/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java @@ -26,7 +26,9 @@ import java.util.Date; import org.apache.muse.util.xml.XPathUtils;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.notification.impl.FilterCollection;
import org.apache.muse.ws.notification.impl.MessagePatternFilter;
+import org.apache.muse.ws.notification.impl.ProducerPropertiesFilter;
import org.apache.muse.ws.notification.impl.TopicFilter;
import org.apache.muse.ws.notification.remote.NotificationProducerClient;
import org.apache.qpid.management.Names;
@@ -93,8 +95,11 @@ public class ConsumerAndProducerExample extends AbstractQManExample // Example 6: a MessageFilter is installed in order to listen only for connection events
// (connections created or removed). The subscription will expire in 10 seconds.
allMessagesWithMessageFilterAndTerminationTime(producerEPR,consumerEPR);
+
+ // Example 7 : a subscription with more than one filter.
+ complexSubscription(producerEPR, consumerEPR);
}
-
+
/**
* Makes a subscription on all topics / all messages without an expiry date.
*
@@ -223,6 +228,41 @@ public class ConsumerAndProducerExample extends AbstractQManExample new Date(System.currentTimeMillis() + 10000)); // Termination Time
}
+ /**
+ * Makes a subscription on a specifc topic with an expiry date.
+ * Only messages published on the given topic will be delivered to the given consumer.
+ * The subscription will end after 10 seconds
+ *
+ * @param producer the producer endpoint reference.
+ * @param consumer the consumer endpoint reference .
+ * @throws SoapFault when the subscription cannot be made.
+ */
+ private void complexSubscription(EndpointReference producer, EndpointReference consumer) throws SoapFault
+ {
+ NotificationProducerClient producerClient = new NotificationProducerClient(producer);
+ producerClient.setTrace(true);
+
+ FilterCollection filter = new FilterCollection();
+
+ TopicFilter topicFilter = new TopicFilter(Names.EVENTS_LIFECYLE_TOPIC_NAME);
+ MessagePatternFilter messageFilter= new MessagePatternFilter(
+ "/wsnt:NotificationMessage/wsnt:Message/qman:LifeCycleEvent/qman:Resource/qman:Name/text()='connection'", // expression (XPath)
+ XPathUtils.NAMESPACE_URI); // Dialect : the only supported dialect is XPath 1.0
+
+ ProducerPropertiesFilter producerFilter = new ProducerPropertiesFilter(
+ "boolean(/*/MgtPubInterval > 100 and /*/MsgTotalEnqueues > 56272)",
+ XPathUtils.NAMESPACE_URI);
+
+ filter.addFilter(topicFilter);
+ filter.addFilter(messageFilter);
+ filter.addFilter(producerFilter);
+
+ producerClient.subscribe(
+ consumer, // Consumer Endpoint reference
+ filter, // Topic Filter
+ new Date(System.currentTimeMillis() + 10000)); // Termination Time
+ }
+
@Override
void printOutExampleDescription()
{
@@ -245,4 +285,9 @@ public class ConsumerAndProducerExample extends AbstractQManExample System.out.println("A subscription with a termination time will have a predefined expiry");
System.out.println("date while if there's no termination the subscription will never expire.");
}
+
+ public static void main(String[] args)
+ {
+ new ConsumerAndProducerExample().execute(new String[]{"localhost","8080"});
+ }
}
|
