Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Certiorem is a PubSubHubub (PSH) implementation for ROME. It isn't an application, but an API for building each of the three components (Publisher, Subscriber and Hub) into your web apps.

You can see an example webapp here: https://rometools.jira.com/source/browse/INCUBATOR/trunk/pubsubhubub/webapp

Creating a Hub

Hubs take notifications, or "Pings" that tell it the content of a feed has been updated, fetch the feed, then notify each of the subscribers of the change. As you will begin to see, Certiorem is very much about "Composition" of classes. The Hub class is a prime example of this.

...

Code Block
@Provides
@Singleton
public Hub buildHub() {
    FeedFetcher fetcher = new HttpURLFeedFetcher(new HashMapFeedInfoCacheDeltaFeedInfoCache());
    Hub hub = new Hub(new InMemoryHubDAO(), new UnthreadedVerifier(), new UnthreadedNotifier(), fetcher);

    return hub;
}

...

Code Block
@Singleton
public class SubServlet extends AbstractSubServlet {

    @Inject
    public SubServlet(final Subscriptions subscriptions){
        super(subscriptions);
    }
}

// In the ServerModule...
serve("/subscriptions/*").with(SubServlet.class)

Now if we want to subscribe to a feed, we get a reference to the Subscriptions object, and pass in either the SyndFeed (with appropriate rel="hub" and rel="self" links) or simply a couple of URLs:

Code Block
 subs.subscribe("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml", true, -1, null, new SubscriptionCallback(){

            public void onFailure(Exception e) {
                e.printStackTrace();
            }

            public void onSubscribe(Subscription subscribed) {
                System.out.println("Subscribed "+subscribed.getId() +" "+subscribed.getSourceUrl());
            }

        });

Here we pass in the URL of the Hub, the URL of the feed, a boolean indicating we want to make the subscription request synchronously, the lease seconds we want to keep the subscription for, a null cryptographic secret, and a Callback invoked when the subscribe request completes.