Sha256: d91ab6d7dd095399ad0196ac4240f9057d7b0fd2f97ed51f4c015631ead8f7e8

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'rubygems'
require 'jsparrow'

JSparrow::Connection.configure do |connection|
  connection.use_jms_client_jar '/opt/openjms/lib/openjms-0.7.7-beta-1.jar'

  connection.use_jndi_properties :initial_context_factory => 'org.exolab.jms.jndi.InitialContextFactory',
                                 :provider_url            => 'tcp://localhost:3035'
                               # :security_principal      => 'user',
                               # :security_credentials    => 'password'

  connection.enable_connection_factories :queue_connection_factory => 'ConnectionFactory'
  
  connection.enable_queues :test_queue => 'TestQueue'
end

jms_client = JSparrow::Connection.new_client
jms_client.start

jms_client.queue_sender(:test_queue).send_text_message('jsparrow rocks!') do |msg|
  msg.set_string_property('recipient', 'jsparrow-example')
end

jms_client.queue_receiver(:test_queue).receive_message(
    :timeout  => 5000,
    :selector => "recipient = 'jsparrow-example'"
  ) do |msg|
  
  puts "is text message? #{msg.is_text_message?}"    # is text message? true
  puts "message: #{msg.text}"                        # message: jsparrow rocks!
end

jms_client.stop

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jsparrow-1.1.2 sample/sample_queue.rb
jsparrow-1.1.1 sample/sample.rb