Skip to content

Commit

Permalink
changed readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Peter authored and Mathias Peter committed Jan 20, 2015
1 parent c5d8fb4 commit 944a701
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ RSMQ helper to simply implement a worker around the message queue.
new RSMQWorker( queuename, options );
```


**Example:**

```js
var RSMQWorker = require( "rsmq-worker" );
var worker = new RSMQWorker( "myqueue" );

worker.on( "message", function( msg, next ){
// process your message
next()
});

worker.start();
```

**Config**

- **queuename**: *( `String` required )* The queuename to pull the messages
Expand All @@ -36,19 +51,6 @@ RSMQ helper to simply implement a worker around the message queue.
- **options.host**: *( `Number` optional; default = `6379` )* Port to connect to redis if no `rsmq` or `redis` instance has been defined
- **options.options**: *( `Object` optional; default = `{}` )* Options to connect to redis if no `rsmq` or `redis` instance has been defined

**Example:**

```js
var RSMQWorker = require( "rsmq-worker" );
var worker = new RSMQWorker( "myqueue" );

worker.on( "message", function( msg, next, id ){
// process your message
next()
});

worker.start();
```

## Raw message format

Expand Down Expand Up @@ -181,7 +183,9 @@ This is an advanced example showing some features in action.

//
worker.on( "message", function( message, next, id ){

console.log( "message", message )

if( message === "createmessages" ){
next( false )
worker.send( JSON.stringify( { type: "writefile", filename: "./test.txt", txt: "Foo Bar" } ) );
Expand Down

0 comments on commit 944a701

Please sign in to comment.