examples/producer-consumer/producer.rb in jruby-hornetq-0.4.0 vs examples/producer-consumer/producer.rb in jruby-hornetq-0.5.0.alpha
- old
+ new
@@ -12,21 +12,21 @@
# Using Connect.session since a session does not have to be started in order
# to produce messages
HornetQ::Client::Connection.session('hornetq://localhost') do |session|
# Create a non-durable TestQueue to receive messages sent to the TestAddress
session.create_queue_ignore_exists('TestAddress', 'TestQueue', false)
-
+
# Using the Producer pattern send messages to the Address 'TestAddress'
session.producer('TestAddress') do |producer|
# Create a non-durable message
message = session.create_message(false)
# Mark message as text
message.type_sym = :text
# Always set the message type prior to setting the body so that the message
# is correctly created for you
message.body = "#{Time.now}: ### Hello, World ###"
-
+
producer.send(message)
-
+
puts "Sent Message: #{message.inspect}"
end
end