README.rdoc in leandrosilva-sparrow-1.0.0 vs README.rdoc in leandrosilva-sparrow-1.0.1
- old
+ new
@@ -1,7 +1,67 @@
= sparrow
Sparrow is a JMS client (JRuby based).
+=== Install
+
+Add Github as a source for your RubyGem:
+
+ gem sources -a http://gems.github.com
+
+Make install:
+
+ sudo gem install leandrosilva-sparrow
+
+=== Example
+
+===== Three steps to send and receive JMS messages to/from a Java EE application server.
+
+WARNING: OC4J will be used as Java EE application server, but any other could be used with no problems.
+
+1) Create my_sparrow_test.rb file and require the gems
+
+ require 'rubygems'
+ require 'sparrow'
+
+2) Create and setup a sparrow JMS client
+
+ jms_client = Sparrow::JMS::Connection::Client.new do |properties|
+ properties.client_jar_file = '/oc4j_extended_101330/j2ee/home/oc4jclient.jar'
+ properties.initial_context_factory = 'oracle.j2ee.naming.ApplicationClientInitialContextFactory'
+ properties.provider_url = 'ormi://localhost:23791'
+ properties.security_principal = 'oc4jadmin'
+ properties.security_credentials = 'welcome'
+ end
+
+ jms_client.enable_connection_factories(
+ :queue_connection_factory => 'jms/MyQueueCF'
+ )
+
+ jms_client.enable_queues(
+ :my_queue => 'jms/MyQueue'
+ )
+
+3) OK! You can send and receive messages right now!
+
+ jms_client.queue_sender(:my_queue).send_text_message('sparrow rocks!') do |msg|
+ msg.set_string_property('recipient', 'sparrow-example')
+ end
+
+ jms_client.queue_receiver(:my_queue).receive_message(
+ :timeout => 5000,
+ :selector => "recipient = 'sparrow-example'"
+ ) do |msg|
+
+ puts msg.is_text_message? # true
+ puts msg.text # sparrow rocks!
+ end
+
+So, now start the OC4J server, create the connection factory (jms/MyQueueCF) and queue (jms/MyQueue), and run above script:
+
+ jruby my_sparrow_test.rb
+
+sparrow rocks! =)
+
== Copyright
Copyright (c) 2009 Leandro Silva. See LICENSE for details.