|
PreCache NetInjector Documentation Center : PreCache NetInjector Application Development Basic Case, Subscription Java |
|
|
|
Basic Case, Subscription code Java the complete subscription code The previous code samples presented the basics of subscription. A subscription application retrieves content in much the same way as it was published, albeit after first defining a subscription class. Here is the basic sequence of the subscription process:
import com.precache.event.*; import java.io.*; //Define a subscriber class. class MySubscriber implements Subscriber { public MySubscriber() { } //Define the callback method. public void notify(Notification n, { String message; try { //Retrieve the value of the predefined attribute. message = n.getPredefinedAttrString( System.out.println( } catch(Exception e) { System.out.println(e); } } }; public class sub1 { static { System.loadLibrary("event-j"); } public static void main(String argv[]) { //Create a proxy for the channel and client. Proxy p; try { p = new Proxy(7,3002); //Submit the subscription. p.subscribe("Sample.Intro1", System.out.println( Thread.currentThread().sleep(30000); } catch (Exception e) { e.printStackTrace(); } } } In the next chapter, Common Cases, Publication Java, we will learn more about attributes. |
|