Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
article updates for better connection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesward committed Jun 26, 2012
1 parent 480568d commit c5e7459
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
9 changes: 7 additions & 2 deletions ARTICLE.md
Expand Up @@ -129,6 +129,7 @@ The `SchedulerMain` class needs to be updated to add a new message onto a queue
byte[] body = msg.getBytes("UTF-8");
channel.basicPublish(exchangeName, routingKey, null, body);
logger.info("Message Sent: " + msg);
connection.close();
}
catch (Exception e) {
logger.error(e.getMessage(), e);
Expand All @@ -138,7 +139,7 @@ The `SchedulerMain` class needs to be updated to add a new message onto a queue
}

In this example every time the `HelloJob` is executed it adds a message onto a RabbitMQ message queue simply containing a String with the time the String was created. Running the updated `SchedulerMain` should add a new message to the queue every 2 seconds.
In this example every time the `HelloJob` is executed it adds a message onto a RabbitMQ message queue simply containing a String with the time the String was created. Running the updated `SchedulerMain` should add a new message to the queue every 5 seconds.


Processing Jobs From a Queue
Expand Down Expand Up @@ -243,8 +244,12 @@ You can verify that this is happening by watching the Heroku logs for your appli

You should see something like:

*** NEED OUTPUT ***
2012-06-26T22:26:47+00:00 app[scheduler.1]: 100223 [DefaultQuartzScheduler_Worker-1] INFO com.heroku.devcenter.SchedulerMain - Message Sent: Sent at:1340749607126
2012-06-26T22:26:47+00:00 app[worker.2]: 104798 [main] INFO com.heroku.devcenter.WorkerMain - Message Received: Sent at:1340749607126
2012-06-26T22:26:52+00:00 app[scheduler.1]: 105252 [DefaultQuartzScheduler_Worker-2] INFO com.heroku.devcenter.SchedulerMain - Message Sent: Sent at:1340749612155
2012-06-26T22:26:52+00:00 app[worker.1]: 109738 [main] INFO com.heroku.devcenter.WorkerMain - Message Received: Sent at:1340749612155

In this example execution the scheduler creates 2 messages which are handled by the two different worker Dynos. This shows that the work is being scheduled and distributed correctly.

Further Leaning
---------------
Expand Down
22 changes: 8 additions & 14 deletions README.md
@@ -1,14 +1,8 @@
# Embedded Jetty template application

This is a template for a web application that uses embedded Jetty. The sample code consists of a JSP (this page) and a simple servlet.

## Running the application locally

First build with:

$mvn clean install

Then run it with:

$java -cp target/classes:target/dependency/* com.example.Main

# Run on Heroku

heroku create
heroku addons:add cloudamqp
git push heroku master
heroku scale scheduler=1
heroku scale worker=2
heroku logs -t

0 comments on commit c5e7459

Please sign in to comment.