
Originally Posted by
Ajith
Hi Leigh,
Thanks for posting this example. Symexec looks like an useful tool.
Can you describe the pro's and con's of this solution vs. sending data through messages?
Pro: Simple Command Line interface, no need for user to create client and service program
Con: Message cannot be pased back to the sender, only a return code is issued.
Alternative Solution
The implimentation below demonstrates a similar solution, by using Symphony Client and Service, instead of Symexec.
Client Side
Modify out-of-box sample AsyncClient.java. Issue the search commands via Task Input Message. All other code unchanged. This particular command queries for all "Error" tasks in Task History.
Code:
// Create a message
String command = "/bin/grep Error /data//history/SampleAppJavaGF_task.soamdb";
MyInput myInput = new MyInput(taskCount, command);
Service Side
Modify out-of-box sample MyService.java. Execute command (received from Task Input Message) on compute host, process command output, and then return results via Task Output Message. All other code unchanged. This particular service will fetch and return 3 Task Property fields for each Error Task found in Task History.
Code:
try {
// Execute command
Process p = Runtime.getRuntime().exec(myInput.getString());
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
// Process command output
String line = null;
while ((line = in.readLine()) != null) {
String[] results = line.split(",");
sb.append("\nTask: ");
sb.append(results[0]);
sb.append("\tSession: ");
sb.append(results[1]);
sb.append("\t\tStatus: ");
sb.append(results[3]);
}
} catch (IOException e) {
e.printStackTrace();
}
// Return results
myOutput.setString(sb.toString());
How to run
1) Build Java SampleApp
2) Deploy SampleServiceJavaPackage
3) Register SampleAppJava.xml (make sure Java PATH is defined in Service section)
4) Execute RunAsyncClient.sh

Packages