https://github.com/cobbzilla/rooty-tooty
an MQ-based event bus for delegating priviledged tasks to various daemons
https://github.com/cobbzilla/rooty-tooty
Last synced: 4 months ago
JSON representation
an MQ-based event bus for delegating priviledged tasks to various daemons
- Host: GitHub
- URL: https://github.com/cobbzilla/rooty-tooty
- Owner: cobbzilla
- Created: 2014-05-29T22:27:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-08-19T11:32:13.000Z (almost 11 years ago)
- Last Synced: 2024-12-31T09:47:06.407Z (over 1 year ago)
- Language: Java
- Size: 297 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rooty-tooty
An MQ-based message bus for informing various daemons when things need to get done.
## Usage
### Send an event to the bus
RootyConfiguration config = new RootyConfiguration()
.withSecret(secretKey)
.withQueueName(qName);
RootySender sender = config.getSender();
RootyMessage message = new NewAccountEvent(accountName);
sender.write(message);
### Receive events from the bus
#### Define a class that extends RootyHandlerBase
public class MyHandler extends RootyHandlerBase {
// handlers can have attributes, set in their config (see below)
private boolean debug;
public void setDebug (boolean debug) { this.debug = debug; }
// declare which message types this class can handle
@Override public boolean accepts(RootyMessage message) { return message instanceof NewAccountEvent; }
// called when an acceptable message is ready to be processed
@Override public void process(RootyMessage message) {
NewAccountEvent event = (NewAccountEvent) message;
// ... handle the event ...
}
}
#### Start the rooty daemon from the command line
Create a YAML config file:
queueName: someQueueName+dns
secret: yourSecretKey
handlers:
MyHandler: # fully-qualified Java class name here
params: # params will be copied to JavaBean-style attributes on the handler class
debug: true
# multiple handlers can be listed
Start RootyMain like this:
java rooty.RootyMain /path/to/config.yml
Ensure your CLASSPATH includes both:
* the appropriate rooty-tooty.jar file
* the jar file that contains the MyHandler class
#### Or, start the rooty daemon from code
RootyHandlerConfiguration handlerConfig = new RootyHandlerConfiguration()
.withHandler(MyHandler.class.getName())
.withParam("debug", true);
RootyConfiguration config = new RootyConfiguration()
.withSecret(secretKey)
.withQueueName(qName)
.addHandler(handlerConfig);
RootyMain daemon = new RootyMain();
daemon.run(config); // async: will start a listener thread and return
##### License
For personal or non-commercial use, this code is available under the [GNU Affero General Public License, version 3](https://www.gnu.org/licenses/agpl-3.0.html).
For commercial use, please contact cloudstead.io