return result;
}
public static void executeClient() throws Exception {
Options options = new Options();
ServiceClient serviceClient;
ConfigurationContext configContext = null;
String addUrl = getProperty("addurl", "http://localhost:8280/services/EventingProxy");
String repo = getProperty("repository", "client_repo");
String symbol = getProperty("symbol", "GOOG");
String price = getProperty("price", "10.10");
String qty = getProperty("qty", "1000");
String topic = getProperty("topic", "synapse/event/test");
String action = getProperty("action", "urn:event");
String topicns = getProperty("topicns", "http://apache.org/aip");
if (repo != null && !"null".equals(repo)) {
configContext =
ConfigurationContextFactory.
createConfigurationContextFromFileSystem(repo,
repo + File.separator + "conf" + File.separator + "axis2.xml");
serviceClient = new ServiceClient(configContext, null);
} else {
serviceClient = new ServiceClient();
}
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace nsaip = factory.createOMNamespace(topicns, "aip");
// set the target topic
OMElement topicOm = factory.createOMElement("Topic", nsaip);
factory.createOMText(topicOm, topic);
// set addressing, transport and proxy url
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
options.setAction(action);
options.setProperty(MessageContext.CLIENT_API_NON_BLOCKING,
Boolean.FALSE); // set for fire and foget
serviceClient.setOptions(options);
serviceClient.addHeader(topicOm);
OMElement payload =
AXIOMUtil.stringToOM("<m:placeOrder xmlns:m=\"http://services.samples\">\n" +
" <m:order>\n" +
" <m:price>" + price + "</m:price>\n" +
" <m:quantity>" + qty + "</m:quantity>\n" +
" <m:symbol>" + symbol + "</m:symbol>\n" +
" </m:order>\n" +
"</m:placeOrder>");
System.out.println("Sending Event : \n" + payload.toString());
serviceClient.fireAndForget(payload);
System.out.println("Event sent to topic " + topic);
Thread.sleep(1000);
if (configContext != null) {
configContext.terminate();
}