apache > ws.apache
Pubscribe
 

Using the Subscription Manager

Introduction

The WS-BaseNotification specification includes a portType called SubscriptionManager. The portType includes two operations (PauseSubscription and ResumeSubscription) and a set of resource properties: ConsumerReference, TopicExpression, UseNotify, Precondition, Selector, SubscriptionPolicy, and CreationTime. Pubscribe implements this portType and its required resource properties by default. Therefore, it is not necessary for you to ever define define or implement this portType.

Note
In Pubscribe, a notification producer uses the subscription manager to create a subscription whenever a Subscribe message is received for a topic.

Subscription Manager Messages

Messages to pause or resume a subscription are sent to the SubscriptionManager service. This service is deployed by default when you deploy the Pubscribe Web application. The SubscriptionManager service can also be used to send Destroy, SetTerminationTime, and GetResourceProperty messages. These operations are defined in the WSRF WS-ResourceLifetime and WS-ResourceProperties specifications respectively. When you send messages to the subscription manager, the SOAP header must include the ResourceIdentifier obtained from the EPR of the subscription this value is returned in the response message when you subscribe to a topic.

The below requests demonstrate the messages to pause, resume, and destroy a subscription and are taken from the filesystem example. In the header, notice the EPR that is entered in the wsa:To element and the subscription identifier that is entered in the sub:ResourceIdentifier element.

PauseSubscription

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" 
	  xmlns:wsnt="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd"
          xmlns:sub="http://ws.apache.org/notification/base/service/SubscriptionManager">

   <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
      <wsa:To mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager</wsa:To>
      <wsa:Action mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager/yourWsdlRequestName</wsa:Action>
      <sub:ResourceIdentifier mustUnderstand="1">4623a820-7483-11d9-9a53-fe396408008d</sub:ResourceIdentifier>
   </Header>

   <Body>
      <wsnt:PauseSubscription />
   </Body>

</Envelope>

ResumeSubscription

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" 
	  xmlns:wsnt="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd"
          xmlns:sub="http://ws.apache.org/notification/base/service/SubscriptionManager">

   <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
      <wsa:To mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager</wsa:To>
      <wsa:Action mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager/yourWsdlRequestName</wsa:Action>
      <sub:ResourceIdentifier mustUnderstand="1">4623a820-7483-11d9-9a53-fe396408008d</sub:ResourceIdentifier>
   </Header>

   <Body>
      <wsnt:ResumeSubscription />
   </Body>

</Envelope>

Destroy

The SubscriptionManager also includes the Destroy operation. This operation is defined in the WS-ResourceLifetime specifcation. The Destroy operation can be used to destroy a subscription (i.e. unsubscribe). Like pause and resume, you must provide the EPR and the subscription's ResourceIdentifier.

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" 
	  xmlns:wsnt="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd"
	  xmlns:wsrlw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"
         xmlns:sub="http://ws.apache.org/notification/base/service/SubscriptionManager">

   <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
      <wsa:To mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager</wsa:To>
      <wsa:Action mustUnderstand="1">http://localhost:8080/pubscribe/services/SubscriptionManager/yourWsdlRequestName</wsa:Action>
      <sub:ResourceIdentifier mustUnderstand="1">6d8e2160-f89f-11d9-9c4c-9e6bfb2aa2bf</sub:ResourceIdentifier>
   </Header>

   <Body>
      <wsrlw:Destroy />
   </Body>

</Envelope>

Getting the Subscription Manager's WSDL

The subscription manager publishes its WSDL as metadata using Pubscribe's builtin support for the WS-MetadataExchange specification. The following examples demonstrate SOAP requests that can be used to retrieve the WSDL. For instructions on providing metadata about your service, see the Adding Service Metadata section of the Apache WSRF documentation.

Note
The following request contains a ResourceIdentifier which must be updated to the identifier of the resource you plan to talk to.
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" 
          xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
          xmlns:sub="http://ws.apache.org/notification/base/service/SubscriptionManager">

   <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
      <wsa:To mustUnderstand="1">http://localhost:8080/foobar</wsa:To>
      <wsa:Action mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request</wsa:Action> 
      <sub:ResourceIdentifier mustUnderstand="1">52082a10-ff9f-11d9-b386-b35a385b29cd</sub:ResourceIdentifier>
   </Header>

   <Body>
      <wsx:GetMetadata />
   </Body>

</Envelope>