daemon_objects 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # DaemonObjects
2
2
  [![Build Status](https://travis-ci.org/craigisrael/daemon_objects.png)](https://travis-ci.org/craigisrael/daemon_objects)
3
3
  [![Code Climate](https://codeclimate.com/github/craigisrael/daemon_objects.png)](https://codeclimate.com/github/craigisrael/daemon_objects)
4
+ [![Gem Version](https://badge.fury.io/rb/daemon_objects.png)](http://badge.fury.io/rb/daemon_objects)
4
5
 
5
6
  Daemon Objects is designed to simplify using daemons in your ruby applications. Under the hood, it uses the
6
7
  [daemons](http://daemons.rubyforge.org) gem, which is a mature and tested solution. But, it adds support for managing via rake tasks,
@@ -80,8 +81,7 @@ with your daemon, add `supports_amqp` to your daemon class.
80
81
 
81
82
  class MyQueueProcessingDaemon < Daemon::Base
82
83
  supports_amqp :endpoint => "http://localhost:5672",
83
- :queue_name => "my_awesome_queue",
84
- :worker_class => MyAmqpWorker
84
+ :queue_name => "my_awesome_queue"
85
85
  end
86
86
 
87
87
  This will add the code to monitor the queue, so all you need now is code to handle the messages.
@@ -31,7 +31,7 @@ class DaemonObjects::Amqp::Worker
31
31
  queue.bind(exchange, :routing_key => routing_key) if exchange
32
32
 
33
33
  queue.subscribe(:ack => true) do |metadata, payload|
34
- handle_message(metadata, payload)
34
+ exception = handle_message(metadata, payload)
35
35
 
36
36
  response_payload = consumer.get_response(payload, exception) if consumer.respond_to?(:get_response)
37
37
  if response_payload
@@ -47,10 +47,12 @@ class DaemonObjects::Amqp::Worker
47
47
  end
48
48
 
49
49
  def handle_message(metadata, payload)
50
- consumer.handle_message (payload)
50
+ response = consumer.handle_message (payload)
51
51
  metadata.ack
52
+ response
52
53
  rescue Exception => e
53
54
  metadata.reject
54
55
  logger.error "Error occurred handling message, the payload was: #{payload}, the error was: '#{e}'."
56
+ e
55
57
  end
56
58
  end
@@ -18,12 +18,14 @@ class DaemonObjects::ConsumerBase
18
18
 
19
19
  def handle_message(payload)
20
20
  logger.info("Handling message #{payload}")
21
- handle_message_impl(payload)
21
+ response = handle_message_impl(payload)
22
22
  logger.info("Completed handling message")
23
+ response
23
24
  rescue StandardError => e
24
25
  logger.error("#{e.class}: #{e.message}")
25
26
  logger.error(e.backtrace.join("\n"))
26
27
  Airbrake.notify(e) if defined?(Airbrake)
28
+ e
27
29
  end
28
30
 
29
31
  def self.handle_messages_with(&block)
@@ -1,3 +1,3 @@
1
1
  module DaemonObjects
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-19 00:00:00.000000000 Z
12
+ date: 2013-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: daemons