Skip to content

Commit c5e7459

Browse files
committed
article updates for better connection handling
1 parent 480568d commit c5e7459

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

ARTICLE.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ The `SchedulerMain` class needs to be updated to add a new message onto a queue
129129
byte[] body = msg.getBytes("UTF-8");
130130
channel.basicPublish(exchangeName, routingKey, null, body);
131131
logger.info("Message Sent: " + msg);
132+
connection.close();
132133
}
133134
catch (Exception e) {
134135
logger.error(e.getMessage(), e);
@@ -138,7 +139,7 @@ The `SchedulerMain` class needs to be updated to add a new message onto a queue
138139
139140
}
140141

141-
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.
142+
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.
142143

143144

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

244245
You should see something like:
245246

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

252+
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.
248253

249254
Further Leaning
250255
---------------

README.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
# Embedded Jetty template application
2-
3-
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.
4-
5-
## Running the application locally
6-
7-
First build with:
8-
9-
$mvn clean install
10-
11-
Then run it with:
12-
13-
$java -cp target/classes:target/dependency/* com.example.Main
14-
1+
# Run on Heroku
2+
3+
heroku create
4+
heroku addons:add cloudamqp
5+
git push heroku master
6+
heroku scale scheduler=1
7+
heroku scale worker=2
8+
heroku logs -t

0 commit comments

Comments
 (0)