You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ag...@apache.org on 2009/02/27 14:32:20 UTC

svn commit: r748512 - in /qpid/trunk/qpid/java/management/client/src/example: PauseAndResumeSubscription.out.ok org/apache/qpid/management/example/ConsumerAndProducerExample.java org/apache/qpid/management/example/PausableSubscriptionExample.java

Author: agazzarini
Date: Fri Feb 27 13:32:19 2009
New Revision: 748512

URL: http://svn.apache.org/viewvc?rev=748512&view=rev
Log:
QPID-1606 : Pausable Subscription Manager capability example.

Added:
    qpid/trunk/qpid/java/management/client/src/example/PauseAndResumeSubscription.out.ok
    qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java
Modified:
    qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java

Added: qpid/trunk/qpid/java/management/client/src/example/PauseAndResumeSubscription.out.ok
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/example/PauseAndResumeSubscription.out.ok?rev=748512&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/example/PauseAndResumeSubscription.out.ok (added)
+++ qpid/trunk/qpid/java/management/client/src/example/PauseAndResumeSubscription.out.ok Fri Feb 27 13:32:19 2009
@@ -0,0 +1,133 @@
+This example is demonstrating a WS-Notification scenario 
+when (for simplicity) QMan is at the same time consumer 
+and producer.
+
+Specifically the example shows how a requestor can create,
+pause and resume a subscription.
+Type enter to proceed...
+
+[CLIENT TRACE] SOAP envelope contents (outgoing):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://romagazzarini:8080/qman/services/adapter</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:485cc87c-660e-de43-e8fa-4ad5fffa95a6</wsa:MessageID>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://www.w3.org/2005/08/addressing/role/anonymous</wsa:Address>
+        </wsa:From>
+    </soap:Header>
+    <soap:Body>
+        <wsnt:Subscribe xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
+            <wsnt:ConsumerReference>
+                <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://romagazzarini:8080/qman/services/consumer</wsa:Address>
+            </wsnt:ConsumerReference>
+        </wsnt:Subscribe>
+    </soap:Body>
+</soap:Envelope>
+
+[CLIENT TRACE] SOAP envelope contents (incoming):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/role/anonymous</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:0ee610d1-e211-95c6-a498-e1084a610c44</wsa:MessageID>
+        <wsa:RelatesTo RelationshipType="wsa:Reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:485cc87c-660e-de43-e8fa-4ad5fffa95a6</wsa:RelatesTo>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://romagazzarini:8080/qman/services/adapter</wsa:Address>
+        </wsa:From>
+    </soap:Header>
+    <soap:Body>
+        <wsnt:SubscribeResponse xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
+            <wsnt:SubscriptionReference>
+                <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://romagazzarini:8080/qman/services/SubscriptionManager</wsa:Address>
+                <wsa:ReferenceParameters xmlns:wsa="http://www.w3.org/2005/08/addressing">
+                    <qman-wsa:ResourceId xmlns:qman-wsa="http://amqp.apache.org/qpid/management/qman/addressing">282f28e6-4396-4000-a19d-87a03978e8a0</qman-wsa:ResourceId>
+                </wsa:ReferenceParameters>
+            </wsnt:SubscriptionReference>
+            <wsnt:CurrentTime>2009-02-27T13:51:56+01:00</wsnt:CurrentTime>
+        </wsnt:SubscribeResponse>
+    </soap:Body>
+</soap:Envelope>
+
+[CLIENT TRACE] SOAP envelope contents (outgoing):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://romagazzarini:8080/qman/services/SubscriptionManager</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/PauseSubscriptionRequest</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:35cc80af-84ac-2456-3e1f-edc2a7f60970</wsa:MessageID>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://www.w3.org/2005/08/addressing/role/anonymous</wsa:Address>
+        </wsa:From>
+        <qman-wsa:ResourceId
+            xmlns:wsa="http://www.w3.org/2005/08/addressing"
+            wsa:IsReferenceParameter="true" xmlns:qman-wsa="http://amqp.apache.org/qpid/management/qman/addressing">282f28e6-4396-4000-a19d-87a03978e8a0</qman-wsa:ResourceId>
+    </soap:Header>
+    <soap:Body>
+        <wsnt:PauseSubscription xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"/>
+    </soap:Body>
+</soap:Envelope>
+
+[CLIENT TRACE] SOAP envelope contents (incoming):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/role/anonymous</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/PauseSubscriptionResponse</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:bb53d38a-428c-3d90-cc45-29d5cb27a8df</wsa:MessageID>
+        <wsa:RelatesTo RelationshipType="wsa:Reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:35cc80af-84ac-2456-3e1f-edc2a7f60970</wsa:RelatesTo>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://romagazzarini:8080/qman/services/SubscriptionManager</wsa:Address>
+            <wsa:ReferenceParameters>
+                <qman-wsa:ResourceId wsa:IsReferenceParameter="true"
+                    xmlns:qman-wsa="http://amqp.apache.org/qpid/management/qman/addressing" xmlns:wsa="http://www.w3.org/2005/08/addressing">282f28e6-4396-4000-a19d-87a03978e8a0</qman-wsa:ResourceId>
+            </wsa:ReferenceParameters>
+        </wsa:From>
+    </soap:Header>
+    <soap:Body>
+        <muse-op:PauseSubscriptionResponse xmlns:muse-op="http://docs.oasis-open.org/wsn/b-2"/>
+    </soap:Body>
+</soap:Envelope>
+
+[CLIENT TRACE] SOAP envelope contents (outgoing):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://romagazzarini:8080/qman/services/SubscriptionManager</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/ResumeSubscriptionRequest</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:bfb48615-905a-e472-a9ca-5483fa592f60</wsa:MessageID>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://www.w3.org/2005/08/addressing/role/anonymous</wsa:Address>
+        </wsa:From>
+        <qman-wsa:ResourceId
+            xmlns:wsa="http://www.w3.org/2005/08/addressing"
+            wsa:IsReferenceParameter="true" xmlns:qman-wsa="http://amqp.apache.org/qpid/management/qman/addressing">282f28e6-4396-4000-a19d-87a03978e8a0</qman-wsa:ResourceId>
+    </soap:Header>
+    <soap:Body>
+        <wsnt:ResumeSubscription xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"/>
+    </soap:Body>
+</soap:Envelope>
+
+[CLIENT TRACE] SOAP envelope contents (incoming):
+
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
+    <soap:Header>
+        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/role/anonymous</wsa:To>
+        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/ResumeSubscriptionResponse</wsa:Action>
+        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:aab4cf18-3cc0-30c4-7036-009e26bb3213</wsa:MessageID>
+        <wsa:RelatesTo RelationshipType="wsa:Reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:bfb48615-905a-e472-a9ca-5483fa592f60</wsa:RelatesTo>
+        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
+            <wsa:Address>http://romagazzarini:8080/qman/services/SubscriptionManager</wsa:Address>
+            <wsa:ReferenceParameters>
+                <qman-wsa:ResourceId wsa:IsReferenceParameter="true"
+                    xmlns:qman-wsa="http://amqp.apache.org/qpid/management/qman/addressing" xmlns:wsa="http://www.w3.org/2005/08/addressing">282f28e6-4396-4000-a19d-87a03978e8a0</qman-wsa:ResourceId>
+            </wsa:ReferenceParameters>
+        </wsa:From>
+    </soap:Header>
+    <soap:Body>
+        <muse-op:ResumeSubscriptionResponse xmlns:muse-op="http://docs.oasis-open.org/wsn/b-2"/>
+    </soap:Body>
+</soap:Envelope>
+

Modified: qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java?rev=748512&r1=748511&r2=748512&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java (original)
+++ qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java Fri Feb 27 13:32:19 2009
@@ -67,11 +67,11 @@
 	void executeExample(String host, int port) throws Exception
 	{ 
 		// This is QMan... 
-		URI producerURI = URI.create("http://"+host+":"+port+"/qman/services/consumer");
+		URI producerURI = URI.create("http://"+host+":"+port+"/qman/services/adapter");
 		
 		// ...and this is QMan too! Note that it has an hidden consumer capability that is used in 
 		// order to run successfully this example...
-		URI consumerURI = producerURI;
+		URI consumerURI = URI.create("http://"+host+":"+port+"/qman/services/consumer");
 		
 		EndpointReference producerEPR = new EndpointReference(producerURI);		
 		EndpointReference consumerEPR = new EndpointReference(consumerURI);

Added: qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java?rev=748512&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java (added)
+++ qpid/trunk/qpid/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java Fri Feb 27 13:32:19 2009
@@ -0,0 +1,88 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.management.example;
+
+import java.net.URI;
+
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.notification.remote.NotificationProducerClient;
+import org.apache.muse.ws.notification.remote.SubscriptionClient;
+
+/**
+ * This example is demonstrating a WS-Notification scenario 
+ * when (for simplicity) QMan is at the same time consumer 
+ * and producer.
+ * 
+ * Specifically the example shows how a requestor can create, pause and resume 
+ * a subscription.
+ * 
+ * @author Andrea Gazzarini
+ *
+ */
+public class PausableSubscriptionExample extends AbstractQManExample
+{
+	@Override
+	void executeExample(String host, int port) throws Exception
+	{ 
+		// This is QMan... 
+		URI producerURI = URI.create("http://"+host+":"+port+"/qman/services/adapter");
+		
+		// ...and this is QMan too! Note that it has an hidden consumer capability that is used in 
+		// order to run successfully this example...
+		URI consumerURI = URI.create("http://"+host+":"+port+"/qman/services/consumer");
+		
+		EndpointReference producerEPR = new EndpointReference(producerURI);		
+		EndpointReference consumerEPR = new EndpointReference(consumerURI);
+	
+		NotificationProducerClient producerClient = new NotificationProducerClient(producerEPR);
+        producerClient.setTrace(true);
+
+        // 1) Creates a subscription and gets the corresponding reference.
+        SubscriptionClient subscriptionClient = producerClient.subscribe(
+        		consumerEPR,	// Consumer Endpoint reference
+        		null,			// Filter, if null that means "all messages"
+        		null);			// Termination Time : if null the subscription will never expire.
+        subscriptionClient.setTrace(true);
+        
+        
+        // 2) Pauses the subscription.
+        subscriptionClient.pauseSubscription();
+
+        // 3) Resumes the subscription.
+        subscriptionClient.resumeSubscription();
+	}	
+	
+	@Override
+	void printOutExampleDescription()
+	{
+		System.out.println("This example is demonstrating a WS-Notification scenario ");
+		System.out.println("when (for simplicity) QMan is at the same time consumer ");
+		System.out.println("and producer.");
+		System.out.println();
+		System.out.println("Specifically the example shows how a requestor can create,");
+		System.out.println("pause and resume a subscription.");
+	}
+	
+	public static void main(String[] args)
+	{
+		new PausableSubscriptionExample().execute(new String[]{"romagazzarini","8080"});
+	}
+}



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org