action_subscriber 3.0.0.pre2-java → 3.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -23
- data/lib/action_subscriber/rabbit_connection.rb +3 -0
- data/lib/action_subscriber/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1399aac04de823cbbdd75e1dba0f8ae3c45232ed
|
4
|
+
data.tar.gz: 404f24d6a475c20942452178d77c6bfca7aad2a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ae9eedc5301772ed162f6db18e461c8e4a982a4ceb1bd2e59a8558f92de203a61445eeea2c78ef5601131351a2dd3a9efba5cb42fee4ad087d1620e1979393
|
7
|
+
data.tar.gz: ed762a8e65760130503ce53a5914f4e97e3a2613bcf59be3b09f0b65dae3cdfd64a14aaf39dbc2038f23396d329d13d73926ffac721206e6b516ead2e7be33b3
|
data/README.md
CHANGED
@@ -24,8 +24,6 @@ A subscriber is set up by creating a class that inherits from ActionSubscriber::
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
class UserSubscriber < ::ActionSubscriber::Base
|
27
|
-
publisher :user_hq
|
28
|
-
|
29
27
|
def created
|
30
28
|
# do something when a user is created
|
31
29
|
end
|
@@ -36,35 +34,29 @@ checkout the examples dir for more detailed examples.
|
|
36
34
|
|
37
35
|
Usage
|
38
36
|
-----------------
|
39
|
-
ActionSubscriber is inspired by rails observers, and if you are familiar with rails
|
40
|
-
observers the ActionSubscriber DSL should make you feel right at home!
|
41
|
-
|
42
|
-
First, create a subscriber the inherits from ActionSubscriber::Base
|
43
37
|
|
44
|
-
|
38
|
+
In your application setup you will draw your subscription routes. In a rails app this is usually done in `config/initializers/action_subscriber.rb`.
|
45
39
|
|
46
40
|
```ruby
|
47
|
-
ActionSubscriber.
|
48
|
-
|
49
|
-
|
41
|
+
::ActionSubscriber.draw_routes do
|
42
|
+
# you can define routes one-by-one for fine-grained controled
|
43
|
+
route UserSubscriber, :created
|
44
|
+
|
45
|
+
# or you can setup default routes for all the public methods in a subscriber
|
46
|
+
default_routes_for UserSubscriber
|
50
47
|
end
|
51
48
|
```
|
52
49
|
|
53
|
-
|
50
|
+
Now you can start your subscriber process with:
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
::ActionSubscriber.auto_pop!
|
59
|
-
sleep 1.0
|
60
|
-
end
|
52
|
+
|
53
|
+
```
|
54
|
+
$ bundle exec action_subscriber start --mode=subscribe
|
61
55
|
```
|
62
56
|
|
63
|
-
|
64
|
-
routing keys named intelligently.
|
57
|
+
This will start your subscribers in a mode where they connect to rabbitmq and let the broker push messages down to them.
|
65
58
|
|
66
|
-
|
67
|
-
parameter you recieve will be a decoded message.
|
59
|
+
You can also start in `--mode=pop` where your process will poll the broker for messages.
|
68
60
|
|
69
61
|
Configuration
|
70
62
|
-----------------
|
@@ -80,11 +72,11 @@ In an initializer, you can set the host and the port like this :
|
|
80
72
|
Other configuration options include :
|
81
73
|
|
82
74
|
* config.add_decoder - add a custom decoder for a custom content type
|
83
|
-
* config.allow_low_priority_methods - subscribe to queues for methods suffixed with "_low"
|
84
75
|
* config.default_exchange - set the default exchange that your queues will use, using the default RabbitMQ exchange is not recommended
|
85
76
|
* config.error_handler - handle error like you want to handle them!
|
86
77
|
* config.heartbeat - number of seconds between hearbeats (default 5) [see bunny documentation for more details](http://rubybunny.info/articles/connecting.html)
|
87
|
-
* config.hosts - an array of hostnames in your cluster
|
78
|
+
* config.hosts - an array of hostnames in your cluster (ie `["rabbit1.myapp.com", "rabbit2.myapp.com"]`)
|
79
|
+
* config.pop_interval - how long to wait between polling for messages in `--mode=pop`. It should be a number of milliseconds
|
88
80
|
* config.threadpool_size - set the number of threads availiable to action_subscriber
|
89
81
|
* config.timeout - how many seconds to allow rabbit to respond before timing out
|
90
82
|
* config.times_to_pop - when using RabbitMQ's pull API, the number of messages we will grab each time we pool the broker
|
@@ -36,6 +36,9 @@ module ActionSubscriber
|
|
36
36
|
def self.create_connection(settings)
|
37
37
|
options = connection_options.merge(settings)
|
38
38
|
if ::RUBY_PLATFORM == "java"
|
39
|
+
options[:executor_factory] = ::Proc.new do
|
40
|
+
::MarchHare::ThreadPools.fixed_of_size(options[:threadpool_size])
|
41
|
+
end
|
39
42
|
connection = ::MarchHare.connect(options)
|
40
43
|
else
|
41
44
|
connection = ::Bunny.new(options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-09-
|
15
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -279,9 +279,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
279
279
|
version: '0'
|
280
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
281
|
requirements:
|
282
|
-
- - "
|
282
|
+
- - ">="
|
283
283
|
- !ruby/object:Gem::Version
|
284
|
-
version:
|
284
|
+
version: '0'
|
285
285
|
requirements: []
|
286
286
|
rubyforge_project:
|
287
287
|
rubygems_version: 2.6.6
|