Sha256: 332faeba03d06bbfa185281cec301d6f798b2fa44ec16f2998b63dd8b41afb27
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# # HornetQ In VM Producer and consumer: # Example of how to produce and consume messages with the same Java VM # # Allow examples to be run in-place without requiring a gem install $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib' require 'rubygems' require 'hornetq' # Create and start an InVM HornetQ server instance HornetQ::Server::Factory.start('hornetq://invm') do |server| # Allow a CTRL-C to stop this process server.enable_shutdown_on_signal HornetQ::Client::Factory.start('hornetq://invm') do |session| session.create_queue("MyAddress","MyQueue", nil, false) producer = session.create_producer('MyAddress') consumer = session.create_consumer('MyQueue') # Create a non-durable message to send message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false) message.body = "#{Time.now}: ### Hello, World ###" producer.send(message) # Receive a single message, return immediately if no message available if message = consumer.receive_immediate puts "Received:[#{message.body}]" message.acknowledge else puts "No message found" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jruby-hornetq-0.2.5.alpha | examples/client/invm.rb |
jruby-hornetq-0.2.3.alpha | examples/client/invm.rb |