qpid_proton 0.26.0 → 0.32.0
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.
- checksums.yaml +5 -5
- data/ext/cproton/cproton.c +1812 -4106
- data/lib/handler/messaging_adapter.rb +4 -2
- data/tests/{old-examples/lib/debugging.rb → collect_coverage.rb} +12 -5
- metadata +4 -18
- data/tests/old-examples/broker.rb +0 -200
- data/tests/old-examples/client.rb +0 -81
- data/tests/old-examples/direct_recv.rb +0 -64
- data/tests/old-examples/direct_send.rb +0 -63
- data/tests/old-examples/helloworld.rb +0 -72
- data/tests/old-examples/helloworld_direct.rb +0 -73
- data/tests/old-examples/lib/driver.rb +0 -68
- data/tests/old-examples/lib/qpid_examples.rb +0 -26
- data/tests/old-examples/lib/selectable.rb +0 -119
- data/tests/old-examples/lib/send_and_receive.rb +0 -89
- data/tests/old-examples/old_example_test.rb +0 -99
- data/tests/old-examples/server.rb +0 -75
- data/tests/old-examples/simple_recv.rb +0 -57
- data/tests/old-examples/simple_send.rb +0 -54
@@ -1,72 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
require 'qpid_proton'
|
20
|
-
require 'optparse'
|
21
|
-
|
22
|
-
class HelloWorld < Qpid::Proton::Handler::MessagingHandler
|
23
|
-
|
24
|
-
def initialize(server, address)
|
25
|
-
super()
|
26
|
-
@server = server
|
27
|
-
@address = address
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_start(event)
|
31
|
-
conn = event.container.connect(:address => @server)
|
32
|
-
event.container.create_sender(conn, :target => @address)
|
33
|
-
event.container.create_receiver(conn, :source => @address)
|
34
|
-
end
|
35
|
-
|
36
|
-
def on_sendable(event)
|
37
|
-
msg = Qpid::Proton::Message.new
|
38
|
-
msg.body = "Hello world!"
|
39
|
-
event.sender.send(msg)
|
40
|
-
event.sender.close
|
41
|
-
end
|
42
|
-
|
43
|
-
def on_message(event)
|
44
|
-
puts event.message.body
|
45
|
-
event.connection.close
|
46
|
-
end
|
47
|
-
|
48
|
-
def on_transport_error(event)
|
49
|
-
raise "Connection error: #{event.transport.condition}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
options = {
|
54
|
-
:address => "localhost:5672",
|
55
|
-
:queue => "examples"
|
56
|
-
}
|
57
|
-
|
58
|
-
OptionParser.new do |opts|
|
59
|
-
opts.banner = "Usage: helloworld_direct.rb [options]"
|
60
|
-
|
61
|
-
opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
|
62
|
-
options[:address] = address
|
63
|
-
end
|
64
|
-
|
65
|
-
opts.on("-q", "--queue=QUEUE", "Send messages to QUEUE (def. #{options[:queue]})") do |queue|
|
66
|
-
options[:queue] = queue
|
67
|
-
end
|
68
|
-
|
69
|
-
end.parse!
|
70
|
-
|
71
|
-
hw = HelloWorld.new(options[:address], "examples")
|
72
|
-
Qpid::Proton::Reactor::Container.new(hw).run
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
require 'qpid_proton'
|
20
|
-
require 'optparse'
|
21
|
-
|
22
|
-
options = {
|
23
|
-
:address => "localhost:5672/examples",
|
24
|
-
}
|
25
|
-
|
26
|
-
class HelloWorldDirect < Qpid::Proton::Handler::MessagingHandler
|
27
|
-
|
28
|
-
include Qpid::Proton::Util::Wrapper
|
29
|
-
|
30
|
-
def initialize(url)
|
31
|
-
super()
|
32
|
-
@url = url
|
33
|
-
end
|
34
|
-
|
35
|
-
def on_start(event)
|
36
|
-
@acceptor = event.container.listen(@url)
|
37
|
-
event.container.create_sender(@url)
|
38
|
-
end
|
39
|
-
|
40
|
-
def on_sendable(event)
|
41
|
-
msg = Qpid::Proton::Message.new
|
42
|
-
msg.body = "Hello world!"
|
43
|
-
event.sender.send(msg)
|
44
|
-
event.sender.close
|
45
|
-
end
|
46
|
-
|
47
|
-
def on_message(event)
|
48
|
-
puts "#{event.message.body}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def on_accepted(event)
|
52
|
-
event.connection.close
|
53
|
-
end
|
54
|
-
|
55
|
-
def on_connection_closed(event)
|
56
|
-
@acceptor.close
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
OptionParser.new do |opts|
|
62
|
-
opts.banner = "Usage: helloworld_direct.rb [options]"
|
63
|
-
|
64
|
-
opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
|
65
|
-
options[:address] = address
|
66
|
-
end
|
67
|
-
|
68
|
-
end.parse!
|
69
|
-
|
70
|
-
begin
|
71
|
-
Qpid::Proton::Reactor::Container.new(HelloWorldDirect.new(options[:address])).run
|
72
|
-
rescue Interrupt => error
|
73
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
class Driver
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@selectables = {}
|
23
|
-
end
|
24
|
-
|
25
|
-
def add(selectable)
|
26
|
-
@selectables[selectable.fileno] = selectable
|
27
|
-
end
|
28
|
-
|
29
|
-
def process
|
30
|
-
reading = []
|
31
|
-
writing = []
|
32
|
-
|
33
|
-
@selectables.each_value do |sel|
|
34
|
-
if sel.closed? || sel.fileno.nil?
|
35
|
-
@selectables.delete(sel.fileno)
|
36
|
-
else
|
37
|
-
begin
|
38
|
-
reading << sel.to_io if sel.reading?
|
39
|
-
writing << sel.to_io if sel.writing?
|
40
|
-
rescue Exception => error
|
41
|
-
puts "Error: #{error}"
|
42
|
-
puts error.backtrace.join("\n");
|
43
|
-
# @selectables.delete(sel.fileno)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
read_from, write_to = IO.select(reading, writing, [], 0)
|
49
|
-
|
50
|
-
unless read_from.nil?
|
51
|
-
read_from.each do |r|
|
52
|
-
sel = @selectables[r.fileno]
|
53
|
-
sel.readable unless sel.nil? || sel.closed?
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
begin
|
58
|
-
unless write_to.nil?
|
59
|
-
write_to.each do |w|
|
60
|
-
sel = @selectables[w.fileno]
|
61
|
-
sel.writable unless sel.nil? || sel.closed?
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
require "qpid_proton"
|
20
|
-
|
21
|
-
require "selectable"
|
22
|
-
require "driver"
|
23
|
-
require "socket"
|
24
|
-
require "monitor"
|
25
|
-
|
26
|
-
include Socket::Constants
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
class Selectable
|
20
|
-
|
21
|
-
attr_reader :transport
|
22
|
-
|
23
|
-
def initialize(transport, socket)
|
24
|
-
@transport = transport
|
25
|
-
@socket = socket
|
26
|
-
@socket.autoclose = true
|
27
|
-
@write_done = false
|
28
|
-
@read_done = false
|
29
|
-
end
|
30
|
-
|
31
|
-
def closed?
|
32
|
-
return true if @socket.closed?
|
33
|
-
return false if !@read_done && !@write_done
|
34
|
-
@socket.close
|
35
|
-
true
|
36
|
-
end
|
37
|
-
|
38
|
-
def fileno
|
39
|
-
@socket.fileno unless @socket.closed?
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_io
|
43
|
-
@socket
|
44
|
-
end
|
45
|
-
|
46
|
-
def reading?
|
47
|
-
return false if @read_done
|
48
|
-
c = @transport.capacity
|
49
|
-
if c > 0
|
50
|
-
return true
|
51
|
-
elsif c < 0
|
52
|
-
@read_done = true
|
53
|
-
return false
|
54
|
-
else
|
55
|
-
return false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def writing?
|
60
|
-
return false if @write_done
|
61
|
-
begin
|
62
|
-
p = @transport.pending
|
63
|
-
if p > 0
|
64
|
-
return true
|
65
|
-
elsif p < 0
|
66
|
-
@write_done = true
|
67
|
-
return false
|
68
|
-
else
|
69
|
-
return false
|
70
|
-
end
|
71
|
-
rescue Qpid::Proton::TransportError => error
|
72
|
-
@write_done = true
|
73
|
-
return false
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def readable
|
78
|
-
c = @transport.capacity
|
79
|
-
if c > 0
|
80
|
-
begin
|
81
|
-
data = @socket.recv(c)
|
82
|
-
if data
|
83
|
-
@transport.push(data)
|
84
|
-
else
|
85
|
-
@transport.close_tail
|
86
|
-
end
|
87
|
-
rescue Exception => error
|
88
|
-
puts "read error; #{error}"
|
89
|
-
@transport.close_tail
|
90
|
-
@read_done = true
|
91
|
-
end
|
92
|
-
elsif c < 0
|
93
|
-
@read_done = true
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def writable
|
98
|
-
begin
|
99
|
-
p = @transport.pending
|
100
|
-
if p > 0
|
101
|
-
data = @transport.peek(p)
|
102
|
-
n = @socket.send(data, 0)
|
103
|
-
@transport.pop(n)
|
104
|
-
elsif p < 0
|
105
|
-
@write_done = true
|
106
|
-
end
|
107
|
-
rescue Exception => error
|
108
|
-
puts "write error: #{error}"
|
109
|
-
puts error.backtrace.join("\n")
|
110
|
-
@transport.close_head
|
111
|
-
@write_done = true
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def tick(now)
|
116
|
-
@transport.tick(now)
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
3
|
-
# distributed with this work for additional information
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
6
|
-
# "License"); you may not use this file except in compliance
|
7
|
-
# with the License. You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
|
18
|
-
|
19
|
-
class ExampleSend < Qpid::Proton::Handler::MessagingHandler
|
20
|
-
|
21
|
-
attr_reader :url
|
22
|
-
|
23
|
-
def initialize(url, expected)
|
24
|
-
super()
|
25
|
-
@url = url
|
26
|
-
@sent = 0
|
27
|
-
@confirmed = 0
|
28
|
-
@expected = expected
|
29
|
-
end
|
30
|
-
|
31
|
-
def on_sendable(event)
|
32
|
-
while event.sender.credit > 0 && @sent < @expected
|
33
|
-
msg = Qpid::Proton::Message.new
|
34
|
-
msg.body = "sequence #{@sent}"
|
35
|
-
msg.id = @sent
|
36
|
-
event.sender.send(msg)
|
37
|
-
@sent = @sent + 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_accepted(event)
|
42
|
-
@confirmed = @confirmed + 1
|
43
|
-
if self.finished?
|
44
|
-
puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!"
|
45
|
-
event.connection.close
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def on_disconnected(event)
|
50
|
-
@sent = @confirmed
|
51
|
-
end
|
52
|
-
|
53
|
-
def finished?
|
54
|
-
@confirmed == @expected
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
class ExampleReceive < Qpid::Proton::Handler::MessagingHandler
|
60
|
-
|
61
|
-
attr_reader :url
|
62
|
-
|
63
|
-
def initialize(url, expected)
|
64
|
-
super()
|
65
|
-
@url = url
|
66
|
-
@expected = expected
|
67
|
-
@received = 0
|
68
|
-
end
|
69
|
-
|
70
|
-
def on_message(event)
|
71
|
-
if event.message.id.nil? || event.message.id < @received
|
72
|
-
puts "Missing or old message id: id=#{event.message.id}"
|
73
|
-
return
|
74
|
-
end
|
75
|
-
if @expected.zero? || (@received < @expected)
|
76
|
-
puts "Received: #{event.message.body}"
|
77
|
-
@received = @received + 1
|
78
|
-
if finished?
|
79
|
-
event.receiver.close
|
80
|
-
event.connection.close
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def finished?
|
86
|
-
@received == @expected
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|