Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created March 5, 2012 17:18
Show Gist options
  • Save iocanel/1979570 to your computer and use it in GitHub Desktop.
Save iocanel/1979570 to your computer and use it in GitHub Desktop.
A karaf command which echos messages to cluster nodes via Hazelcast
@Command(scope = "hazelcast", name = "echo", description = "Echos a message to all cluster nodes")
public class EchoCommand extends HazelcastCommandSupport {
@Argument(index=0,name="message", description = "The message to echo", required = true, multiValued = false)
private String message;
private ITopic topic;
@Override
protected Object doExecute() throws Exception {
if(topic != null) {
topic.publish(message);
} else System.err.println("Echo topic not available");
return null;
}
public ITopic getTopic() {
return topic;
}
public void setTopic(ITopic topic) {
this.topic = topic;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment