package org.wso2.carbon.event.broker.sample;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.AxisFault;
import org.wso2.carbon.event.client.broker.BrokerClient;
import org.wso2.carbon.event.client.broker.SimpleMessageReceiver;
public class SubscribeWithMessageBox {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String topic = "/foo";
String repoLocation = "/home/hemapani/playground/events/wso2carbon-3.2.0-SNAPSHOT/repository";
String confFile = repoLocation + "/conf/axis2_client.xml";
SimpleMessageReceiver messageReceiver = new SimpleMessageReceiver(repoLocation, confFile,null);
messageReceiver.start();
BrokerClient brokerClient = new BrokerClient("http://127.0.0.1:9763/services/EventBrokerService");
//brokerClient.subscribe(topic, messageReceiver.getListenerUrl());
brokerClient.subscribe(topic, "http://parakum:6666/axis2/services/MessageCollector/receive/");
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement ele = fac.createOMElement(new QName("http://wso2.org","foo"));
ele.setText("hello");
brokerClient.publish(topic, ele);
Thread.sleep(3000);
}
}