Red Hat Training

A Red Hat training course is available for JBoss Enterprise SOA Platform

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 and marketing. To do so, you will need to deploy the Service Registry to two different services first.

Procedure 5.1. Task

  1. Configuring Node One: Sales

    Create juddi_custom_install_data by running these commands:
    cd juddiv3/WEB-INF/classes
    mv RENAME4SALES_juddi_custom_install_data juddi_custom_install_data
  2. 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
    
  3. Save the file and exit.
  4. Start the server: SOA_ROOT/jboss-as/bin/./run.sh
  5. 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.
  6. Configuring Node Two: Marketing

    Create juddi_custom_install_data by running these commands:
    cd juddiv3/WEB-INF/classes
    mv RENAME4MARKETING_juddi_custom_install_data juddi_custom_install_data
  7. 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
    
  8. Save the file and exit.
  9. Start the server: SOA_ROOT/jboss-as/bin/./run.sh
  10. 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.
  11. Next, replace the sales server's uddi-portlets.war/WEB-INF/classes/META-INF/uddi.xml file with uddi-portlets.war/WEB-INF/classes/META-INF/uddi.xml.sales.
  12. 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>
    
  13. Save the file and exit.
  14. Launch a web browser and go to this address: http://sales:8080/pluto.
  15. Log in with both a user name and password of sales and observe what is displayed onscreen.
  16. Before logging into the marketing portal, replace marketing's uddi-portlet.war/WEB-INF/classes/META-INF/uddi.xml file with udd-portlet.war/WEB-INF/classes/META-INF/uddi.xml.marketing.
  17. 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>
    
  18. Save the file and exit.
  19. Launch a web browser and go to this address: http://marketing:8080/pluto.
  20. 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

  1. 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>
    
  2. Save the file and exit.
  3. Now deploy the juddiv3-samples.war to the sales registry.
    ant deploy
    ant runtest

    Note

    The HelloSales service is provided in the juddiv3-samples.war archive file and it is annotated, so it will automatically register itself.
  4. 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 following tModels:
    <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

  1. 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.
  2. Save the file and exit.
  3. Log in as the marketing publisher on the marketing portal and select the UDDISubscription Portlet.
  4. 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
  5. Click the Save icon to store the subscription.
  6. Make sure that the subscription key uses the marketing publisher's keyGenerator's conventions. You should see the orange subscription icon appear under the sales-ws UDDI node.
  7. To invoke a synchronous subscription, click the Green Arrows icon. This will give you the opportunity to set the coverage period.
  8. 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 the UDDISubscriptionNotification portlet:
  9. The response is processed by the marketing node. This node then imports the HelloWorld subscription information, as well as the sales business. If they synchronise successfully, three businesses will be visible in the marketing node's browser portlet.