public NonCarbonPubSubTest(String name) {
super(name);
}
public void testBasicPubSub() throws Exception{
EventBrokerService brokerInstance = CarbonEventBroker.getInstance();
((CarbonEventBroker)brokerInstance).registerSubscriptionManager(new InMemorySubscriptionManager());
CarbonNotificationManager notifyManager = new CarbonNotificationManager();
notifyManager.init(new HashMap<String, String>());
((CarbonEventBroker)brokerInstance).registerNotificationManager(notifyManager);
Subscription subscription = new Subscription();
String topic = "testTopic";
subscription.setFilterDesc(new EventFilterDesc(null, topic));
EventDispatcher dispatcher = new EventDispatcher<Object>() {
public boolean onMatchingEvent(Event<Object> event,
Subscription subscription) throws EventException {
System.out.println("received "+event);
return false;
}
};
brokerInstance.subscribeNonPersistantly(subscription, dispatcher);
brokerInstance.publishEvent(new Event(new Object(), topic));
Thread.sleep(10000);
}