try {
long value = System.currentTimeMillis();
String msg = String.format("<msg> current time is : %d </msg>", value);
WsntMsgBrokerClient wsntMsgBrokerClient = new WsntMsgBrokerClient();
int consumerPort = 6767;
String brokerEPR = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/NotificationService";
wsntMsgBrokerClient.init(brokerEPR);
String[] consumerEPRs = wsntMsgBrokerClient.startConsumerService(consumerPort, this);
assertTrue(consumerEPRs.length > 0);
String topic = "/WsntRoundTripTestTopic";
String topicSubscriptionID = wsntMsgBrokerClient.subscribe(consumerEPRs[0], topic, null);
System.out.println("topic subscription id: " + topicSubscriptionID);
try {
wsntMsgBrokerClient.publish(topic, msg);
wsntMsgBrokerClient.publish(topic, AXIOMUtil.stringToOM("<foo><bar>Test</bar></foo>"));
} catch (Exception e) {
fail(e.getMessage());
}
Thread.sleep(2000);
try {
wsntMsgBrokerClient.unSubscribe(topicSubscriptionID);
} catch (AxisFault e) {
e.printStackTrace();
fail(e.getMessage());
}
wsntMsgBrokerClient.shutdownConsumerService();
} catch (AxisFault e) {
e.printStackTrace();
try {
System.in.read();