jack_rabbit 0.0.5-java → 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/dev/consumer.rb +19 -0
- data/dev/producer.rb +13 -0
- data/lib/jack_rabbit/consumer.rb +13 -11
- data/lib/jack_rabbit/producer.rb +17 -8
- data/lib/jack_rabbit/version.rb +1 -1
- metadata +23 -19
data/.gitignore
CHANGED
data/dev/consumer.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.push(File.expand_path('../../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'jack_rabbit'
|
5
|
+
|
6
|
+
subscriptions = [
|
7
|
+
# exchange key queue
|
8
|
+
[ 'jackrabbitdev', 'consumer.test', 'consumer.test', {} ]
|
9
|
+
]
|
10
|
+
|
11
|
+
consumer = JackRabbit::Consumer.new
|
12
|
+
|
13
|
+
consumer.connect([ URI.parse('amqp://guest:guest@localhost:5672/') ])
|
14
|
+
|
15
|
+
subscriptions.each do |exchange, key, queue, options|
|
16
|
+
consumer.subscribe(exchange, key, queue, options) do |header, message|
|
17
|
+
puts [ header, message ].inspect
|
18
|
+
end
|
19
|
+
end
|
data/dev/producer.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.push(File.expand_path('../../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'jack_rabbit'
|
5
|
+
|
6
|
+
producer = JackRabbit::Producer.new
|
7
|
+
|
8
|
+
producer.connect(URI.parse('amqp://guest:guest@localhost:5672/'))
|
9
|
+
|
10
|
+
loop do
|
11
|
+
puts producer.publish('jackrabbitdev', :direct, 'consumer.test', 'foo')
|
12
|
+
sleep(1)
|
13
|
+
end
|
data/lib/jack_rabbit/consumer.rb
CHANGED
@@ -34,21 +34,23 @@ module JackRabbit
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def open_connection(uri, options)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
connection =
|
38
|
+
HotBunnies.connect(options.merge(
|
39
|
+
host: uri.host,
|
40
|
+
pass: uri.password,
|
41
|
+
port: uri.port,
|
42
|
+
user: uri.user,
|
43
|
+
vhost: uri.path
|
44
|
+
))
|
45
|
+
connection.add_shutdown_listener { |_reason| exit! }
|
46
|
+
connection
|
44
47
|
end
|
45
48
|
|
46
49
|
def open_channels(prefetch)
|
47
50
|
@connections.inject(@channels) do |memo, connection|
|
48
|
-
channel =
|
49
|
-
|
50
|
-
|
51
|
-
end
|
51
|
+
channel = connection.create_channel
|
52
|
+
channel.add_shutdown_listener { |_reason| exit! }
|
53
|
+
channel.prefetch = prefetch if prefetch
|
52
54
|
memo.push(channel)
|
53
55
|
end
|
54
56
|
end
|
data/lib/jack_rabbit/producer.rb
CHANGED
@@ -20,14 +20,23 @@ module JackRabbit
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def open_connection(uri, options
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
def open_connection(uri, options)
|
24
|
+
connection =
|
25
|
+
HotBunnies.connect(options.merge(
|
26
|
+
host: uri.host,
|
27
|
+
pass: uri.password,
|
28
|
+
port: uri.port,
|
29
|
+
user: uri.user,
|
30
|
+
vhost: uri.path
|
31
|
+
))
|
32
|
+
connection.add_shutdown_listener { |_reason| exit! }
|
33
|
+
connection
|
34
|
+
end
|
35
|
+
|
36
|
+
def open_channel(connection)
|
37
|
+
channel = connection.open_channel
|
38
|
+
channel.add_shutdown_listener { |_reason| exit! }
|
39
|
+
channel
|
31
40
|
end
|
32
41
|
|
33
42
|
def with_exchange(channel, exchange_name, exchange_type, &block)
|
data/lib/jack_rabbit/version.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jack_rabbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Sebastian Ohm
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hot_bunnies
|
16
|
-
|
17
|
-
none: false
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
17
|
requirements:
|
19
18
|
- - ~>
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: 1.4.0
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
21
|
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.4.0
|
30
|
-
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
|
+
description:
|
31
31
|
email:
|
32
32
|
- ohm.sebastian@gmail.com
|
33
33
|
executables: []
|
@@ -39,34 +39,38 @@ files:
|
|
39
39
|
- LICENSE
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
|
+
- dev/consumer.rb
|
43
|
+
- dev/producer.rb
|
42
44
|
- jack_rabbit.gemspec
|
43
45
|
- lib/jack_rabbit.rb
|
44
46
|
- lib/jack_rabbit/consumer.rb
|
45
47
|
- lib/jack_rabbit/message_header.rb
|
46
48
|
- lib/jack_rabbit/producer.rb
|
47
49
|
- lib/jack_rabbit/version.rb
|
48
|
-
homepage:
|
50
|
+
homepage:
|
49
51
|
licenses: []
|
50
|
-
post_install_message:
|
52
|
+
post_install_message:
|
51
53
|
rdoc_options: []
|
52
54
|
require_paths:
|
53
55
|
- lib
|
54
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
57
|
requirements:
|
57
58
|
- - ! '>='
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
|
60
|
+
version: !binary |-
|
61
|
+
MA==
|
61
62
|
none: false
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
64
|
requirements:
|
63
65
|
- - ! '>='
|
64
66
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
67
|
+
version: !binary |-
|
68
|
+
MA==
|
69
|
+
none: false
|
66
70
|
requirements: []
|
67
|
-
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
69
|
-
signing_key:
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.24
|
73
|
+
signing_key:
|
70
74
|
specification_version: 3
|
71
75
|
summary: Convenience wrapper around AMQP client libraries
|
72
76
|
test_files: []
|