rjack-qpid-client 0.8.0-java
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/History.rdoc +2 -0
- data/Manifest.txt +13 -0
- data/NOTICE.txt +7 -0
- data/README.rdoc +42 -0
- data/Rakefile +51 -0
- data/assembly.xml +15 -0
- data/lib/rjack-qpid-client.rb +35 -0
- data/lib/rjack-qpid-client/base.rb +28 -0
- data/lib/rjack-qpid-client/qpid-client-0.8.jar +0 -0
- data/lib/rjack-qpid-client/qpid-common-0.8.jar +0 -0
- data/lib/rjack-qpid-client/qpid_jms_context.rb +241 -0
- data/pom.xml +47 -0
- data/test/test_qpid_client.rb +122 -0
- metadata +160 -0
data/History.rdoc
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
History.rdoc
|
2
|
+
Manifest.txt
|
3
|
+
NOTICE.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
assembly.xml
|
7
|
+
pom.xml
|
8
|
+
lib/rjack-qpid-client/base.rb
|
9
|
+
lib/rjack-qpid-client.rb
|
10
|
+
lib/rjack-qpid-client/qpid_jms_context.rb
|
11
|
+
test/test_qpid_client.rb
|
12
|
+
lib/rjack-qpid-client/qpid-client-0.8.jar
|
13
|
+
lib/rjack-qpid-client/qpid-common-0.8.jar
|
data/NOTICE.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= rjack-qpid-client
|
2
|
+
|
3
|
+
* http://rjack.rubyforge.org
|
4
|
+
* http://rubyforge.org/projects/rjack
|
5
|
+
|
6
|
+
== Description
|
7
|
+
|
8
|
+
A gem packaging of the {Qpid}[http://qpid.apache.org/] AMQP Java Client.
|
9
|
+
|
10
|
+
== License
|
11
|
+
|
12
|
+
=== rjack-qpid-client gem
|
13
|
+
|
14
|
+
Copyright (c) 2011 David Kellum
|
15
|
+
|
16
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you
|
17
|
+
may not use this file except in compliance with the License. You
|
18
|
+
may obtain a copy of the License at:
|
19
|
+
|
20
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
21
|
+
|
22
|
+
Unless required by applicable law or agreed to in writing, software
|
23
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
24
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
25
|
+
implied. See the License for the specific language governing
|
26
|
+
permissions and limitations under the License.
|
27
|
+
|
28
|
+
=== Qpid (java)
|
29
|
+
|
30
|
+
Copyright (c) 2006-2008 Apache Software Foundation
|
31
|
+
|
32
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you
|
33
|
+
may not use this file except in compliance with the License. You
|
34
|
+
may obtain a copy of the License at:
|
35
|
+
|
36
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
37
|
+
|
38
|
+
Unless required by applicable law or agreed to in writing, software
|
39
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
40
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
41
|
+
implied. See the License for the specific language governing
|
42
|
+
permissions and limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
$LOAD_PATH << './lib'
|
4
|
+
require 'rjack-qpid-client/base'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'rjack-tarpit', '~> 1.3.0'
|
8
|
+
require 'rjack-tarpit'
|
9
|
+
|
10
|
+
include RJack
|
11
|
+
|
12
|
+
t = TarPit.new( 'rjack-qpid-client', QpidClient::VERSION, :java_platform )
|
13
|
+
|
14
|
+
t.specify do |h|
|
15
|
+
h.developer( "David Kellum", "dek-oss@gravitext.com" )
|
16
|
+
|
17
|
+
h.extra_deps += [ [ 'rjack-jms', '~> 1.0.0' ],
|
18
|
+
[ 'rjack-mina', '~> 1.0.10' ],
|
19
|
+
[ 'rjack-slf4j', '>= 1.5.8', '< 1.7' ] ]
|
20
|
+
|
21
|
+
h.extra_dev_deps << [ 'rjack-logback', '>= 0.9.18', '< 2.0' ]
|
22
|
+
|
23
|
+
h.rubyforge_name = "rjack"
|
24
|
+
h.remote_rdoc_dir = "qpid-client"
|
25
|
+
end
|
26
|
+
|
27
|
+
t.jars = %w[ common client ].map do |mod|
|
28
|
+
"qpid-#{mod}-#{ QpidClient::QPID_VERSION }.jar"
|
29
|
+
end
|
30
|
+
|
31
|
+
t.assembly_version = 1.0
|
32
|
+
|
33
|
+
file 'Manifest.txt' => [ "lib/#{t.name}/base.rb" ]
|
34
|
+
|
35
|
+
task :check_pom_deps do
|
36
|
+
t.test_line_match( 'pom.xml',
|
37
|
+
%r[<version>#{ QpidClient::QPID_VERSION }</version>] )
|
38
|
+
end
|
39
|
+
|
40
|
+
task :check_history_version do
|
41
|
+
t.test_line_match( 'History.rdoc', /^==/, / #{t.version} / )
|
42
|
+
end
|
43
|
+
task :check_history_date do
|
44
|
+
t.test_line_match( 'History.rdoc', /^==/, /\([0-9\-]+\)$/ )
|
45
|
+
end
|
46
|
+
|
47
|
+
task :gem => [ :check_pom_deps, :check_history_version ]
|
48
|
+
task :tag => [ :check_pom_deps, :check_history_version, :check_history_date ]
|
49
|
+
task :push => [ :check_history_date ]
|
50
|
+
|
51
|
+
t.define_tasks
|
data/assembly.xml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<assembly>
|
2
|
+
<id>bin</id>
|
3
|
+
<formats>
|
4
|
+
<format>dir</format>
|
5
|
+
</formats>
|
6
|
+
<includeBaseDirectory>false</includeBaseDirectory>
|
7
|
+
<dependencySets>
|
8
|
+
<dependencySet>
|
9
|
+
<includes>
|
10
|
+
<include>org.apache.qpid:qpid-common</include>
|
11
|
+
<include>org.apache.qpid:qpid-client</include>
|
12
|
+
</includes>
|
13
|
+
</dependencySet>
|
14
|
+
</dependencySets>
|
15
|
+
</assembly>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You
|
6
|
+
# may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'rjack-qpid-client/base'
|
18
|
+
|
19
|
+
require 'rjack-jms'
|
20
|
+
require 'rjack-mina'
|
21
|
+
|
22
|
+
require 'rjack-slf4j'
|
23
|
+
require 'rjack-slf4j/jcl-over-slf4j'
|
24
|
+
|
25
|
+
require 'rjack-qpid-client/qpid_jms_context'
|
26
|
+
|
27
|
+
# QpidClient module
|
28
|
+
#
|
29
|
+
module RJack
|
30
|
+
module QpidClient
|
31
|
+
%w[ common client ].each do |mod|
|
32
|
+
require "#{LIB_DIR}/qpid-#{mod}-#{QPID_VERSION}.jar"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You
|
6
|
+
# may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module RJack
|
18
|
+
module QpidClient
|
19
|
+
|
20
|
+
# QpidClient (java) version
|
21
|
+
QPID_VERSION = '0.8'
|
22
|
+
|
23
|
+
# rjack gem version
|
24
|
+
VERSION = QPID_VERSION + '.0'
|
25
|
+
|
26
|
+
LIB_DIR = File.dirname( __FILE__ ) # :nodoc:
|
27
|
+
end
|
28
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,241 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'rjack-qpid-client'
|
18
|
+
require 'socket'
|
19
|
+
require 'rjack-slf4j'
|
20
|
+
require 'rjack-jms'
|
21
|
+
|
22
|
+
module RJack::QpidClient
|
23
|
+
|
24
|
+
# Implementation of RJack::JMS::JMSContext for Qpid, using the
|
25
|
+
# {Qpid JNDI Properties}[http://qpid.apache.org/books/0.8/Programming-In-Apache-Qpid/html/ch03s02.html]
|
26
|
+
# syntax. Provides scripted setup and a factory for JMS Connection,
|
27
|
+
# Session, and Destinations (including full AMQP queue and exchange
|
28
|
+
# creation) via Qpid
|
29
|
+
# {Addresses}[http://qpid.apache.org/books/0.8/Programming-In-Apache-Qpid/html/ch02s04.html]
|
30
|
+
# created from ruby.
|
31
|
+
class QpidJMSContext
|
32
|
+
include RJack::JMS::JMSContext
|
33
|
+
|
34
|
+
import 'javax.naming.Context'
|
35
|
+
import 'javax.naming.InitialContext'
|
36
|
+
import 'javax.jms.Session'
|
37
|
+
|
38
|
+
# User to connect with (required, often unused by broker,
|
39
|
+
# default: 'qpid')
|
40
|
+
attr_accessor :username
|
41
|
+
|
42
|
+
# Password to connect with (required, often unused by broker.)
|
43
|
+
attr_accessor :password
|
44
|
+
|
45
|
+
# Array of [ host[,port] ] arrays to brokers (default: [['localhost']] )
|
46
|
+
# Default port is 5672.
|
47
|
+
attr_accessor :brokers
|
48
|
+
|
49
|
+
# Connection 'virtualhost' (default: 'default-vhost')
|
50
|
+
# See JNDI Properties, 3.2.2 Connection URLs
|
51
|
+
attr_accessor :virtual_host
|
52
|
+
|
53
|
+
# Connection 'clientid' (default: 'default-client')
|
54
|
+
# See JNDI Properties, 3.2.2 Connection URLs
|
55
|
+
attr_accessor :client_id
|
56
|
+
|
57
|
+
# Connection factory, JNDI name (default: 'local')
|
58
|
+
attr_accessor :factory_jndi_name
|
59
|
+
|
60
|
+
# Acknowledge Mode specified on create_session
|
61
|
+
# (default: javax.jms.Session::AUTO_ACKNOWLEDGE).
|
62
|
+
attr_accessor :session_acknowledge_mode
|
63
|
+
|
64
|
+
# Hash of destination JNDI name to an 'address; options' Hash.
|
65
|
+
# The option hash may use ruby Symbol or String keys, and
|
66
|
+
# true, false, Symbol, String, Hash, or Array values. This will be
|
67
|
+
# serialized into the Qpid
|
68
|
+
# {Addresses}[http://qpid.apache.org/books/0.8/Programming-In-Apache-Qpid/html/ch02s04.html]
|
69
|
+
# Syntax. The special keys :address (default: same as JNDI name)
|
70
|
+
# and :subject (optional address/subject) are also supported when
|
71
|
+
# serializing. (Default: empty)
|
72
|
+
attr_accessor :destinations
|
73
|
+
|
74
|
+
def initialize
|
75
|
+
@username = 'qpid'
|
76
|
+
@password = 'pswd'
|
77
|
+
@brokers = [ [ 'localhost' ] ]
|
78
|
+
|
79
|
+
@virtual_host = 'default-vhost'
|
80
|
+
@client_id = 'default-client'
|
81
|
+
|
82
|
+
@factory_jndi_name = 'local'
|
83
|
+
|
84
|
+
@session_acknowledge_mode = Session::AUTO_ACKNOWLEDGE
|
85
|
+
@destinations = {}
|
86
|
+
@log = RJack::SLF4J[ self.class ]
|
87
|
+
end
|
88
|
+
|
89
|
+
# The JNDI InitialContext, created on first call, from properties.
|
90
|
+
def context
|
91
|
+
@context ||= InitialContext.new( properties )
|
92
|
+
end
|
93
|
+
|
94
|
+
# The javax.jms.ConnectionFactory, created on first call, by lookup
|
95
|
+
# of factory_jndi_name from context.
|
96
|
+
#
|
97
|
+
# Throws javax.naming.NamingException
|
98
|
+
def connection_factory
|
99
|
+
@con_factory ||= context.lookup( factory_jndi_name )
|
100
|
+
end
|
101
|
+
|
102
|
+
# Creates a new
|
103
|
+
# {javax.jms.Connection}[http://download.oracle.com/javaee/5/api/javax/jms/Connection.html]
|
104
|
+
# from the connection_factory. Caller should close this connection when done with it.
|
105
|
+
#
|
106
|
+
# Throws javax.jms.JMSException, javax.naming.NamingException
|
107
|
+
def create_connection
|
108
|
+
connection_factory.create_connection
|
109
|
+
end
|
110
|
+
|
111
|
+
# Create a
|
112
|
+
# {javax.jms.Session}[http://download.oracle.com/javaee/5/api/javax/jms/Session.html]
|
113
|
+
# from the connection previously obtained via create_connection.
|
114
|
+
#
|
115
|
+
# Throws javax.jms.JMSException
|
116
|
+
def create_session( connection )
|
117
|
+
connection.create_session( false, session_acknowledge_mode )
|
118
|
+
end
|
119
|
+
|
120
|
+
# Lookup (and thus create) a
|
121
|
+
# {javax.jms.Destination}[http://download.oracle.com/javaee/5/api/javax/jms/Destination.html]
|
122
|
+
# by JNDI name as key into destination. The name and full address
|
123
|
+
# specification is logged at this point.
|
124
|
+
#
|
125
|
+
# Throws javax.naming.NamingException
|
126
|
+
def lookup_destination( name )
|
127
|
+
@log.info( "Lookup of destinations[ '%s' ] =\n %s" %
|
128
|
+
[ name,
|
129
|
+
address_serialize( name, @destinations[ name ] ) ] )
|
130
|
+
context.lookup( name )
|
131
|
+
end
|
132
|
+
|
133
|
+
# Close the JNDI context (no more lookups may be made.)
|
134
|
+
def close
|
135
|
+
@con_factory = nil
|
136
|
+
|
137
|
+
@context.close if @context
|
138
|
+
@context = nil
|
139
|
+
end
|
140
|
+
|
141
|
+
# Qpid JNDI Properties including connection_url and destinations.
|
142
|
+
def properties
|
143
|
+
props = Java::java.util.Hashtable.new
|
144
|
+
|
145
|
+
props[ Context::INITIAL_CONTEXT_FACTORY ] =
|
146
|
+
"org.apache.qpid.jndi.PropertiesFileInitialContextFactory"
|
147
|
+
|
148
|
+
props[ [ "connectionfactory", factory_jndi_name ].join( '.' ) ] =
|
149
|
+
connection_url
|
150
|
+
|
151
|
+
destinations.each_pair do |name,opts|
|
152
|
+
props[ [ "destination", name ].join( '.' ) ] =
|
153
|
+
address_serialize( name, opts )
|
154
|
+
end
|
155
|
+
|
156
|
+
props
|
157
|
+
end
|
158
|
+
|
159
|
+
# Serialize destination
|
160
|
+
# {Addresses}[http://qpid.apache.org/books/0.8/Programming-In-Apache-Qpid/html/ch02s04.html]
|
161
|
+
# (new format). Reference: section 2.4.3.5
|
162
|
+
def address_serialize( name, opts = nil )
|
163
|
+
opts = opts.dup
|
164
|
+
out = ( opts.delete( :address ) || name ).to_s
|
165
|
+
subject = opts.delete( :subject )
|
166
|
+
out += '/' + subject.to_s if subject
|
167
|
+
out += '; ' + option_serialize( opts ) if opts
|
168
|
+
end
|
169
|
+
|
170
|
+
# Serialize addresses options Hash
|
171
|
+
def option_serialize( val )
|
172
|
+
case( val )
|
173
|
+
when TrueClass, FalseClass, Symbol, Integer
|
174
|
+
val.to_s
|
175
|
+
when String
|
176
|
+
val.to_s.inspect #quote/escape
|
177
|
+
when Hash
|
178
|
+
pairs = val.map do | key, value |
|
179
|
+
[ wrap_key( key ), option_serialize( value ) ].join( ": " )
|
180
|
+
end
|
181
|
+
'{ ' + pairs.join( ', ' ) + ' }'
|
182
|
+
when Array
|
183
|
+
values = val.map do | value |
|
184
|
+
option_serialize( value )
|
185
|
+
end
|
186
|
+
'[ ' + values.join( ', ' ) + ' ]'
|
187
|
+
else
|
188
|
+
raise "Unknown option value class: " + val.class.to_s
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Quote keys that require it based on Qpid address scheme (most
|
193
|
+
# commonly, those with '.' in them).
|
194
|
+
def wrap_key( key )
|
195
|
+
k = key.to_s
|
196
|
+
if ( k =~ /^[a-zA-Z_][a-zA-Z0-9_-]*[a-zA-Z0-9_]$/ )
|
197
|
+
k
|
198
|
+
else
|
199
|
+
"'" + k + "'"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# The AMQP specific Connection URL as defined in Qpid JNDI
|
204
|
+
# Properities.
|
205
|
+
def connection_url
|
206
|
+
url = "amqp://"
|
207
|
+
|
208
|
+
if username
|
209
|
+
url += username
|
210
|
+
url += ':' + password if password
|
211
|
+
url += '@'
|
212
|
+
end
|
213
|
+
|
214
|
+
url += [ client_id, virtual_host ].join( '/' )
|
215
|
+
|
216
|
+
url += '?'
|
217
|
+
|
218
|
+
url += "brokerlist='#{ broker_list }'"
|
219
|
+
|
220
|
+
url
|
221
|
+
end
|
222
|
+
|
223
|
+
# Broker list Connection URL parameter value from input brokers.
|
224
|
+
def broker_list
|
225
|
+
l = brokers.map do | host, port |
|
226
|
+
'tcp://%s:%s' % [ host, port || 5672 ]
|
227
|
+
end
|
228
|
+
|
229
|
+
l.join( ';' )
|
230
|
+
end
|
231
|
+
|
232
|
+
# Appends Socket.gethostname and the current Process.pid to the
|
233
|
+
# specified prefix to create a (transient) unique address name
|
234
|
+
def address_per_process( prefix )
|
235
|
+
[ prefix,
|
236
|
+
Socket.gethostname.to_s.split( '.' ).first,
|
237
|
+
Process.pid.to_s ].compact.join( '-' )
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
data/pom.xml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
2
|
+
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
4
|
+
<groupId>rjack</groupId>
|
5
|
+
<artifactId>rjack-qpid-client</artifactId>
|
6
|
+
<packaging>pom</packaging>
|
7
|
+
<version>1.0</version>
|
8
|
+
<name>QPid java client for Gem</name>
|
9
|
+
|
10
|
+
<dependencies>
|
11
|
+
<dependency>
|
12
|
+
<groupId>org.apache.qpid</groupId>
|
13
|
+
<artifactId>qpid-client</artifactId>
|
14
|
+
<version>0.8</version>
|
15
|
+
</dependency>
|
16
|
+
|
17
|
+
<dependency>
|
18
|
+
<groupId>org.apache.qpid</groupId>
|
19
|
+
<artifactId>qpid-common</artifactId>
|
20
|
+
<version>0.8</version>
|
21
|
+
</dependency>
|
22
|
+
</dependencies>
|
23
|
+
|
24
|
+
<build>
|
25
|
+
<plugins>
|
26
|
+
<plugin>
|
27
|
+
<artifactId>maven-assembly-plugin</artifactId>
|
28
|
+
<configuration>
|
29
|
+
<descriptors>
|
30
|
+
<descriptor>assembly.xml</descriptor>
|
31
|
+
</descriptors>
|
32
|
+
<tarLongFileMode>gnu</tarLongFileMode>
|
33
|
+
</configuration>
|
34
|
+
<executions>
|
35
|
+
<execution>
|
36
|
+
<id>assembly</id>
|
37
|
+
<phase>package</phase>
|
38
|
+
<goals>
|
39
|
+
<goal>attached</goal>
|
40
|
+
</goals>
|
41
|
+
</execution>
|
42
|
+
</executions>
|
43
|
+
</plugin>
|
44
|
+
</plugins>
|
45
|
+
</build>
|
46
|
+
|
47
|
+
</project>
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
#.hashdot.profile += jruby-shortlived
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2011 David Kellum
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
7
|
+
# may not use this file except in compliance with the License. You
|
8
|
+
# may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
15
|
+
# implied. See the License for the specific language governing
|
16
|
+
# permissions and limitations under the License.
|
17
|
+
#++
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift File.join( File.dirname(__FILE__), "..", "lib" )
|
20
|
+
|
21
|
+
require 'java'
|
22
|
+
require 'rubygems'
|
23
|
+
|
24
|
+
require 'rjack-qpid-client'
|
25
|
+
require 'rjack-logback'
|
26
|
+
|
27
|
+
RJack::Logback.config_console( :stderr => true )
|
28
|
+
|
29
|
+
require 'test/unit'
|
30
|
+
|
31
|
+
class TestQpidClient < Test::Unit::TestCase
|
32
|
+
include RJack::QpidClient
|
33
|
+
|
34
|
+
import 'org.apache.qpid.jms.Session'
|
35
|
+
|
36
|
+
def test_qpid_loaded
|
37
|
+
assert( Session )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_default_connection
|
41
|
+
with_context do |ctx|
|
42
|
+
assert( con = ctx.create_connection )
|
43
|
+
con.close
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_dest_queue
|
48
|
+
con = nil
|
49
|
+
with_context do |ctx|
|
50
|
+
ctx.destinations[ 'rjack-qpid-test-q' ] = {
|
51
|
+
:assert => :always,
|
52
|
+
:create => :always,
|
53
|
+
:node => {
|
54
|
+
:type => :queue,
|
55
|
+
'x-declare' => {
|
56
|
+
'auto-delete' => true,
|
57
|
+
:exclusive => true,
|
58
|
+
:arguments => {
|
59
|
+
'qpid.max_size' => 200,
|
60
|
+
'qpid.policy_type' => :ring,
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
assert( con = ctx.create_connection )
|
66
|
+
assert( session = ctx.create_session( con ) )
|
67
|
+
assert( ctx.lookup_destination( 'rjack-qpid-test-q' ) )
|
68
|
+
end
|
69
|
+
ensure
|
70
|
+
con.close if con
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_dest_exchange
|
74
|
+
con = nil
|
75
|
+
with_context do |ctx|
|
76
|
+
|
77
|
+
ctx.destinations[ 'rjack-qpid-test-x' ] = {
|
78
|
+
:assert => :always,
|
79
|
+
:create => :always,
|
80
|
+
:node => {
|
81
|
+
:type => :topic,
|
82
|
+
'x-declare' => {
|
83
|
+
:type => :fanout,
|
84
|
+
:exchange => 'rjack-qpid-test-x'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
ctx.destinations[ 'rjack-qpid-test-x-q' ] = {
|
90
|
+
:assert => :always,
|
91
|
+
:create => :always,
|
92
|
+
:delete => :always,
|
93
|
+
:node => {
|
94
|
+
:type => :queue,
|
95
|
+
'x-bindings' => [ { :exchange => 'rjack-qpid-test-x' } ],
|
96
|
+
'x-declare' => {
|
97
|
+
'auto-delete' => true,
|
98
|
+
:exclusive => true,
|
99
|
+
:arguments => {
|
100
|
+
'qpid.max_size' => 200_000,
|
101
|
+
'qpid.policy_type' => :ring,
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
assert( con = ctx.create_connection )
|
107
|
+
assert( session = ctx.create_session( con ) )
|
108
|
+
assert( ctx.lookup_destination( 'rjack-qpid-test-x' ) )
|
109
|
+
assert( ctx.lookup_destination( 'rjack-qpid-test-x-q' ) )
|
110
|
+
end
|
111
|
+
ensure
|
112
|
+
con.close if con
|
113
|
+
end
|
114
|
+
|
115
|
+
def with_context
|
116
|
+
ctx = QpidJMSContext.new
|
117
|
+
yield ctx
|
118
|
+
ensure
|
119
|
+
ctx.close if ctx
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rjack-qpid-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 8
|
8
|
+
- 0
|
9
|
+
version: 0.8.0
|
10
|
+
platform: java
|
11
|
+
authors:
|
12
|
+
- David Kellum
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-05 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rjack-jms
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 1.0.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rjack-mina
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
- 10
|
45
|
+
version: 1.0.10
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rjack-slf4j
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 5
|
58
|
+
- 8
|
59
|
+
version: 1.5.8
|
60
|
+
- - <
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 7
|
65
|
+
version: "1.7"
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rjack-logback
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
- 9
|
78
|
+
- 18
|
79
|
+
version: 0.9.18
|
80
|
+
- - <
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 2
|
84
|
+
- 0
|
85
|
+
version: "2.0"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id004
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: rjack-tarpit
|
90
|
+
prerelease: false
|
91
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 1
|
97
|
+
- 3
|
98
|
+
- 0
|
99
|
+
version: 1.3.0
|
100
|
+
type: :development
|
101
|
+
version_requirements: *id005
|
102
|
+
description: A gem packaging of the {Qpid}[http://qpid.apache.org/] AMQP Java Client.
|
103
|
+
email:
|
104
|
+
- dek-oss@gravitext.com
|
105
|
+
executables: []
|
106
|
+
|
107
|
+
extensions: []
|
108
|
+
|
109
|
+
extra_rdoc_files:
|
110
|
+
- Manifest.txt
|
111
|
+
- NOTICE.txt
|
112
|
+
- History.rdoc
|
113
|
+
- README.rdoc
|
114
|
+
files:
|
115
|
+
- History.rdoc
|
116
|
+
- Manifest.txt
|
117
|
+
- NOTICE.txt
|
118
|
+
- README.rdoc
|
119
|
+
- Rakefile
|
120
|
+
- assembly.xml
|
121
|
+
- pom.xml
|
122
|
+
- lib/rjack-qpid-client/base.rb
|
123
|
+
- lib/rjack-qpid-client.rb
|
124
|
+
- lib/rjack-qpid-client/qpid_jms_context.rb
|
125
|
+
- test/test_qpid_client.rb
|
126
|
+
- lib/rjack-qpid-client/qpid-client-0.8.jar
|
127
|
+
- lib/rjack-qpid-client/qpid-common-0.8.jar
|
128
|
+
has_rdoc: true
|
129
|
+
homepage: http://rjack.rubyforge.org
|
130
|
+
licenses: []
|
131
|
+
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options:
|
134
|
+
- --main
|
135
|
+
- README.rdoc
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
requirements: []
|
153
|
+
|
154
|
+
rubyforge_project: rjack
|
155
|
+
rubygems_version: 1.3.6
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: A gem packaging of the {Qpid}[http://qpid.apache.org/] AMQP Java Client.
|
159
|
+
test_files:
|
160
|
+
- test/test_qpid_client.rb
|