Skip to content

Play Platform Client

chamerling edited this page Nov 16, 2012 · 3 revisions

Using the platform client

Maven dependencies

Available from repository at http://maven.petalslink.com/private-play-snapshot/ :

<dependency>
  <groupId>org.ow2.play</groupId>
  <artifactId>play-platform-client-ws</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

Sample

package org.ow2.play;

import junit.framework.TestCase;

import org.ow2.play.platform.api.bean.Subscription;
import org.ow2.play.platform.api.bean.SubscriptionResult;
import org.ow2.play.platform.api.bean.Topic;
import org.ow2.play.platform.client.ws.PlatformClient;

public class AppTest extends TestCase {

	public void testMe() throws Exception {
		PlatformClient client = new PlatformClient();
		client.connect("http://localhost:8080/play/api/v1/", null);

		Subscription subscription = new Subscription();
		subscription.subscriber = "http://localhost:3001/";
		Topic topic = new Topic();
		topic.name = "Friend_Geo_Event";
		topic.ns = "http://streams.event-processing.org/ids/";
		topic.prefix = "s";

		subscription.topic = topic;
		SubscriptionResult result = client.getSubscriptionManager().subscribe(
				subscription);
		System.out.println("Subscription ID : " + result.subscriptionID);
	}

	public void testUnsubscribe() throws Exception {
		PlatformClient client = new PlatformClient();
		client.connect("http://localhost:8080/play/api/v1/", null);
		String subscriptionID = "4d7ddc57-f426-454c-a738-625a7621a852";
		boolean result = client.getSubscriptionManager().unsubscribe(
				subscriptionID);
		;
		System.out.println(result);
	}
}
Clone this wiki locally