jruby-jms 1.1.0-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +24 -7
  3. data/README.md +49 -49
  4. data/Rakefile +17 -12
  5. data/lib/jms.rb +8 -17
  6. data/lib/jms/bytes_message.rb +3 -19
  7. data/lib/jms/connection.rb +63 -83
  8. data/lib/jms/map_message.rb +9 -25
  9. data/lib/jms/message.rb +22 -173
  10. data/lib/jms/message_consumer.rb +23 -35
  11. data/lib/jms/message_listener_impl.rb +22 -38
  12. data/lib/jms/message_producer.rb +9 -25
  13. data/lib/jms/mq_workaround.rb +11 -26
  14. data/lib/jms/object_message.rb +1 -17
  15. data/lib/jms/oracle_a_q_connection_factory.rb +4 -21
  16. data/lib/jms/queue_browser.rb +2 -18
  17. data/lib/jms/session.rb +92 -106
  18. data/lib/jms/session_pool.rb +34 -41
  19. data/lib/jms/text_message.rb +0 -16
  20. data/lib/jms/version.rb +1 -1
  21. data/test/connection_test.rb +35 -81
  22. data/test/jms.yml +18 -8
  23. data/test/message_test.rb +27 -43
  24. data/test/session_pool_test.rb +30 -46
  25. data/test/session_test.rb +30 -45
  26. data/test/test_helper.rb +33 -0
  27. metadata +20 -26
  28. data/Gemfile +0 -8
  29. data/Gemfile.lock +0 -36
  30. data/examples/advanced/session_pool.rb +0 -37
  31. data/examples/client-server/replier.rb +0 -29
  32. data/examples/client-server/requestor.rb +0 -40
  33. data/examples/file-to-q/files_to_q.rb +0 -51
  34. data/examples/file-to-q/q_to_files.rb +0 -44
  35. data/examples/invm/invm.rb +0 -44
  36. data/examples/invm/log4j.properties +0 -58
  37. data/examples/jms.yml +0 -149
  38. data/examples/performance/consumer.rb +0 -25
  39. data/examples/performance/producer.rb +0 -31
  40. data/examples/producer-consumer/browser.rb +0 -24
  41. data/examples/producer-consumer/consumer.rb +0 -24
  42. data/examples/producer-consumer/consumer_async.rb +0 -41
  43. data/examples/producer-consumer/producer.rb +0 -25
  44. data/examples/publish-subscribe/publish.rb +0 -24
  45. data/examples/publish-subscribe/subscribe.rb +0 -31
  46. data/lib/jms/logging.rb +0 -50
  47. data/nbproject/private/private.properties +0 -3
  48. data/nbproject/private/rake-d.txt +0 -5
  49. data/parallel_minion.gemspec +0 -21
@@ -1,25 +0,0 @@
1
- #
2
- # Sample Consumer:
3
- # Retrieve all messages from a queue
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'yaml'
11
- require 'jms'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- JMS::Connection.session(config) do |session|
20
- stats = session.consume(:queue_name => 'ExampleQueue', :statistics => true) do |message|
21
- # Do nothing in this example with each message
22
- end
23
-
24
- JMS::logger.info "Consumed #{stats[:messages]} messages. Average #{stats[:ms_per_msg]}ms per message"
25
- end
@@ -1,31 +0,0 @@
1
- #
2
- # Sample Producer:
3
- # Write multiple messages to the queue
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'yaml'
11
- require 'jms'
12
- require 'benchmark'
13
-
14
- jms_provider = ARGV[0] || 'activemq'
15
- count = (ARGV[1] || 10).to_i
16
-
17
- # Load Connection parameters from configuration file
18
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
19
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
20
-
21
- JMS::Connection.session(config) do |session|
22
- duration = Benchmark.realtime do
23
- session.producer(:queue_name => 'ExampleQueue') do |producer|
24
- count.times do |i|
25
- producer.send(session.message("Hello Producer #{i}"))
26
- end
27
- end
28
- end
29
-
30
- JMS::logger.info "Produced #{count} messages. Average #{duration*1000/count}ms per message"
31
- end
@@ -1,24 +0,0 @@
1
- #
2
- # Sample Browsing Consumer:
3
- # Browse all messages on a queue without removing them
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'jms'
11
- require 'yaml'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- # Consume all available messages on the queue
20
- JMS::Connection.session(config) do |session|
21
- session.browse(:queue_name => 'ExampleQueue', :timeout=>1000) do |message|
22
- JMS::logger.info message.inspect
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- #
2
- # Sample Consumer:
3
- # Retrieve all messages from a queue
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'jms'
11
- require 'yaml'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- # Consume all available messages on the queue
20
- JMS::Connection.session(config) do |session|
21
- session.consume(:queue_name => 'ExampleQueue', :timeout=>1000) do |message|
22
- JMS::logger.info message.inspect
23
- end
24
- end
@@ -1,41 +0,0 @@
1
- #
2
- # Sample Asynchronous Consumer:
3
- # Retrieve all messages from the queue in a separate thread
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'jms'
11
- require 'yaml'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- continue = true
20
-
21
- trap("INT") {
22
- JMS::logger.info "CTRL + C"
23
- continue = false
24
- }
25
-
26
- # Consume all available messages on the queue
27
- JMS::Connection.start(config) do |connection|
28
-
29
- # Define Asynchronous code block to be called every time a message is received
30
- connection.on_message(:queue_name => 'ExampleQueue') do |message|
31
- JMS::logger.info message.inspect
32
- end
33
-
34
- # Since the on_message handler above is in a separate thread the thread needs
35
- # to do some other work. For this example it will just sleep for 10 seconds
36
- while(continue)
37
- sleep 10
38
- end
39
-
40
- JMS::logger.info "closing ..."
41
- end
@@ -1,25 +0,0 @@
1
- #
2
- # Sample Producer:
3
- # Write messages to the queue
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'yaml'
11
- require 'jms'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- JMS::Connection.session(config) do |session|
20
- session.producer(:queue_name => 'ExampleQueue') do |producer|
21
- producer.delivery_mode_sym = :non_persistent
22
- producer.send(session.message("Hello World: #{Time.now}"))
23
- JMS::logger.info "Successfully sent one message to queue ExampleQueue"
24
- end
25
- end
@@ -1,24 +0,0 @@
1
- #
2
- # Sample Publisher:
3
- # Write messages to a topic
4
- #
5
-
6
- # Allow examples to be run in-place without requiring a gem install
7
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
8
-
9
- require 'rubygems'
10
- require 'yaml'
11
- require 'jms'
12
-
13
- jms_provider = ARGV[0] || 'activemq'
14
-
15
- # Load Connection parameters from configuration file
16
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
17
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
18
-
19
- JMS::Connection.session(config) do |session|
20
- session.producer(:topic_name => 'SampleTopic') do |producer|
21
- producer.send(session.message("Hello World: #{Time.now}"))
22
- JMS::logger.info "Successfully published one message to topic SampleTopic"
23
- end
24
- end
@@ -1,31 +0,0 @@
1
- #
2
- # Sample Topic Subscriber:
3
- # Retrieve all messages from a topic using a non-durable subscription
4
- #
5
- # Try starting multiple copies of this Consumer. All active instances should
6
- # receive the same messages
7
- #
8
- # Since the topic subscription is non-durable, it will only receive new messages.
9
- # Any messages sent prior to the instance starting will not be received.
10
- # Also, any messages sent after the instance has stopped will not be received
11
- # when the instance is re-started, only new messages sent after it started will
12
- # be received.
13
-
14
- # Allow examples to be run in-place without requiring a gem install
15
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
16
-
17
- require 'rubygems'
18
- require 'jms'
19
- require 'yaml'
20
-
21
- jms_provider = ARGV[0] || 'activemq'
22
-
23
- # Load Connection parameters from configuration file
24
- config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
25
- raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
26
-
27
- JMS::Connection.session(config) do |session|
28
- session.consume(:topic_name => 'SampleTopic', :timeout=>30000) do |message|
29
- JMS::logger.info message.inspect
30
- end
31
- end
data/lib/jms/logging.rb DELETED
@@ -1,50 +0,0 @@
1
- ################################################################################
2
- # Copyright 2008, 2009, 2010, 2011 J. Reid Morrison
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You 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 implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
- # Add Logging capabilities
18
- module JMS
19
-
20
- # Returns the logger being used by jruby-jms
21
- # Unless previously set, it will try to use the Rails logger and if it
22
- # is not present, it will return a new Ruby logger
23
- def self.logger
24
- @logger ||= (self.rails_logger || self.ruby_logger)
25
- end
26
-
27
- # Replace the logger for jruby-jms
28
- def self.logger=(logger)
29
- @logger = logger
30
- end
31
-
32
- # Use the ruby logger, but add needed trace level logging which will result
33
- # in debug log entries
34
- def self.ruby_logger(level=nil, target=STDOUT)
35
- require 'logger'
36
-
37
- l = ::Logger.new(target)
38
- l.instance_eval "alias :trace :debug"
39
- l.instance_eval "alias :trace? :debug?"
40
- l.level = level || ::Logger::INFO
41
- l
42
- end
43
-
44
- private
45
- def self.rails_logger
46
- (defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
47
- (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
48
- end
49
-
50
- end
@@ -1,3 +0,0 @@
1
- file.reference.jruby-jms-examples=/Users/rmorrison/Sandbox/jruby-jms/examples
2
- file.reference.jruby-jms-lib=/Users/rmorrison/Sandbox/jruby-jms/lib
3
- file.reference.jruby-jms-test=/Users/rmorrison/Sandbox/jruby-jms/test
@@ -1,5 +0,0 @@
1
- clean=Remove any temporary products.
2
- clobber=Remove any generated file.
3
- doc=Generate RDOC documentation
4
- gem=Build gem
5
- test=Run Test Suite
@@ -1,21 +0,0 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
-
3
- # Maintain gem's version:
4
- require 'jms/version'
5
-
6
- # Describe your gem and declare its dependencies:
7
- Gem::Specification.new do |spec|
8
- spec.name = 'jruby-jms'
9
- spec.version = JMS::VERSION
10
- spec.platform = 'java'
11
- spec.authors = ['Reid Morrison']
12
- spec.email = ['reidmo@gmail.com']
13
- spec.homepage = 'https://github.com/reidmorrison/jruby-jms'
14
- spec.summary = 'JRuby interface into JMS'
15
- spec.description = 'JRuby-JMS is a Java and Ruby library that exposes the Java JMS API in a ruby friendly way. For JRuby only.'
16
- spec.files = FileList["./**/*"].exclude('*.gem', './nbproject/*').map{|f| f.sub(/^\.\//, '')}
17
- spec.test_files = Dir["test/**/*"]
18
- spec.license = "Apache License V2.0"
19
- spec.has_rdoc = true
20
- spec.add_dependency 'gene_pool'
21
- end