Chapter 5. Subscriptions
5.1. Subscription API
The
subscription
API allows you to cross-register services on different service registries and keep them up-to-date by sending out notifications as the registry information in the parent registry changes. This is helpful if you have a large or complex organisation and decide to run different service registries for different departments, with some services being shared between them.
5.2. Subscription Types
There are two type of subscriptions. Each has a different notification system:
- asynchronous
- With this, you can save a subscription, and receive updates on a set schedule. It requires a listener service to be installed on the node to which the notifications will be sent.
- synchronous
- With this, you can save a subscription and invoke
get_Subscription
to obtain a synchronous reply.
5.3. Tutorial: Subscriptions
Prerequisites
- In this example, you will configure nodes for
sales
andmarketing
. To do so, you will need to deploy the Service Registry to two different services first.
Procedure 5.1. Task
Configuring Node One: Sales
Createjuddi_custom_install_data
by running these commands:cd juddiv3/WEB-INF/classes
mv RENAME4SALES_juddi_custom_install_data juddi_custom_install_data
- Open the
SOA_ROOT/jboss-as/server/PROFILE/deploy/jbossesb-registry.sar/esb.juddi.xml
file in a text editor and set the following property values (where "sales" is the DNS name of your server):juddi.server.name=sales juddi.server.port=8080
- Save the file and exit.
- Start the server:
SOA_ROOT/jboss-as/bin/./run.sh
- Open a web browser and go to this address: http://sales:8080/juddiv3. You should see a message that provides you with information about the node.
Configuring Node Two: Marketing
Createjuddi_custom_install_data
by running these commands:cd juddiv3/WEB-INF/classes
mv RENAME4MARKETING_juddi_custom_install_data juddi_custom_install_data
- Open the
SOA_ROOT/jboss-as/server/PROFILE/deploy/jbossesb-registry.sar/esb.juddi.xml
file in a text editor and set the following property values (where "marketing" is the DNS name of your server)juddi.server.name=marketing juddi.server.port=8080
- Save the file and exit.
- Start the server:
SOA_ROOT/jboss-as/bin/./run.sh
- Open a web browser and go to this address: http://sales:8080/juddiv3. Again you should see a message that provides you with information about the node.
Note
Note that the root partition was kept the same, because both the sales and marketing departments are located in the same company, but the Node Id and Name changed to reflect that each node belongs to a different department. - Next, replace the sales server's
uddi-portlets.war/WEB-INF/classes/META-INF/uddi.xml
file withuddi-portlets.war/WEB-INF/classes/META-INF/uddi.xml.sales
. - Open the
uddi-portlets.war/WEB-INF/classes/META-INF/uddi.xml
file in a text editor and add the following properties:<name>default</name> <properties> <property name="serverName" value="sales"/> <property name="serverPort" value="8080"/> <property name="rmiPort" value="1099"/> </properties>
- Save the file and exit.
- Launch a web browser and go to this address: http://sales:8080/pluto.
- Log in with both a user name and password of
sales
and observe what is displayed onscreen. - Before logging into the marketing portal, replace marketing's
uddi-portlet.war/WEB-INF/classes/META-INF/uddi.xml
file withudd-portlet.war/WEB-INF/classes/META-INF/uddi.xml.marketing
. - Open the
uddi-portlet.war/WEB-INF/classes/META_INF/uddi.xml
file in a text editor and add the following properties:<name>default</name> <properties> <property name="serverName" value="marketing"/> <property name="serverPort" value="8080"/> <property name="rmiPort" value="1099"/> </properties>
- Save the file and exit.
- Launch a web browser and go to this address: http://marketing:8080/pluto.
- Log in with both a user name and password of
sales
and observe what is displayed onscreen.Note
The subscriptionlistener is owned by the Marketing Node business, not the Root Marketing Node. The Marketing Node Business is managed by the marketing publisher.
5.4. Tutorial: Deploy the HelloSales Service
Procedure 5.2. Task
- Open the
juddiv3-samples.war/WEB-INF/classes/META-INF/uddi.xml
file in a text editor and add the following property values to sales:<?xml version="1.0" encoding="ISO-8859-1" ?> <uddi> <reloadDelay>5000</reloadDelay> <manager name="example-manager"> <nodes> <node> <name>default</name> <description>Sales jUDDI node</description> <properties> <property name="serverName" value="sales"/> <property name="serverPort" value="8080"/> <property name="keyDomain" value="sales.apache.org"/> <property name="department" value="sales" /> </properties> <proxyTransport> org.apache.juddi.v3.client.transport.InVMTransport </proxyTransport> <custodyTransferUrl> org.apache.juddi.api.impl.UDDICustodyTransferImpl </custodyTransferUrl> <inquiryUrl>org.apache.juddi.api.impl.UDDIInquiryImpl</inquiryUrl> <publishUrl>org.apache.juddi.api.impl.UDDIPublicationImpl</publishUrl> <securityUrl>org.apache.juddi.api.impl.UDDISecurityImpl</securityUrl> <subscriptionUrl> org.apache.juddi.api.impl.UDDISubscriptionImpl </subscriptionUrl> <subscriptionListenerUrl> org.apache.juddi.api.impl.UDDISubscriptionListenerImpl </subscriptionListenerUrl> <juddiApiUrl>org.apache.juddi.api.impl.JUDDIApiImpl</juddiApiUrl> </node> </nodes> </manager> </uddi>
- Save the file and exit.
- Now deploy the
juddiv3-samples.war
to the sales registry.ant deploy
ant runtest
Note
The HelloSales service is provided in thejuddiv3-samples.war
archive file and it is annotated, so it will automatically register itself. - Subscribe to the Sales UDDI node's HelloWord service from within the Marketing UDDI node.
5.5. Allow Users to Create Their Own Subscriptions
Prerequisites
- For a user to create and save subscriptions, they must have valid "publisher" log-ins for both the sales and marketing nodes.
- If the marketing publisher is going to create registry objects in the marketing node, the marketing publisher needs to own the
sales keygenerator tModel
.It is important to understand that the marketing publisher in the marketing registry owns the followingtModels
:<save_tModel xmlns="urn:uddi-org:api_v3"> <tModel tModelKey="uddi:marketing.apache.org:keygenerator" xmlns="urn:uddi-org:api_v3"> <name>marketing-apache-org:keyGenerator</name> <description>Marketing domain key generator</description> <overviewDoc> <overviewURL useType="text"> http://uddi.org/pubs/uddi_v3.htm#keyGen </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="uddi:uddi.org:categorization:types" keyName="uddi-org:types:keyGenerator" keyValue="keyGenerator" /> </categoryBag> </tModel> <tModel tModelKey="uddi:marketing.apache.org:subscription:keygenerator" xmlns="urn:uddi-org:api_v3"> <name>marketing-apache-org:subscription:keyGenerator</name> <description>Marketing Subscriptions domain key generator</description> <overviewDoc> <overviewURL useType="text"> http://uddi.org/pubs/uddi_v3.htm#keyGen </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="uddi:uddi.org:categorization:types" keyName="uddi-org:types:keyGenerator" keyValue="keyGenerator" /> </categoryBag> </tModel> <tModel tModelKey="uddi:sales.apache.org:keygenerator" xmlns="urn:uddi-org:api_v3"> <name>sales-apache-org:keyGenerator</name> <description>Sales Root domain key generator</description> <overviewDoc> <overviewURL useType="text"> http://uddi.org/pubs/uddi_v3.htm#keyGen </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="uddi:uddi.org:categorization:types" keyName="uddi-org:types:keyGenerator" keyValue="keyGenerator" /> </categoryBag> </tModel> </save_tModel>
Procedure 5.3. Task
- If you are going to use the marketing publisher to subscribe to updates in the sales registry, then you must provide this publisher with two clerks. You do so by opening the
uddi-portlet.war/uddi.xml
file in a text editor and adding the following lines:<clerks registerOnStartup="false"> <clerk name="MarketingCratchit" node="default" publisher="marketing" password="marketing"/> <clerk name="SalesCratchit" node="sales-ws" publisher="marketing" password="marketing"/> <!-- optional <xregister> <servicebinding entityKey="uddi:marketing.apache.org:servicebindings-subscriptionlistener-ws" fromClerk="MarketingCratchit" toClerk="SalesCratchit"/> </xregister> --> </clerks>
In the code above, you created two clerks for this publisher, namely MarketingCratchit and SalesCratchit. These allow the publisher to check on the subscriptions it owns in each of the two systems. - Save the file and exit.
- Log in as the marketing publisher on the marketing portal and select the UDDISubscription Portlet.
- When both nodes turn green, click on the new subscription icon (found on the toolbar.) This will be a synchronous subscription, so only leave the Binding Key and Notification Interval
- Click the Save icon to store the subscription.
- Make sure that the subscription key uses the marketing publisher's
keyGenerator
's conventions. You should see the orange subscription icon appear under thesales-ws
UDDI node. - To invoke a synchronous subscription, click the Green Arrows icon. This will give you the opportunity to set the coverage period.
- Click the Green Arrows icon again to invoke the synchronous subscription request.The example finder request will search the sales node looking for updates to the
HelloWorld
service. The raw XML response is then posted to theUDDISubscriptionNotification
portlet: - The response is processed by the marketing node. This node then imports the
HelloWorld
subscription information, as well as thesales business
. If they synchronise successfully, three businesses will be visible in the marketing node's browser portlet.