jruby-jms 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/HISTORY.md +15 -0
  2. data/README.md +27 -28
  3. data/Rakefile +7 -1
  4. data/doc/classes/JMS.html +265 -0
  5. data/doc/classes/JMS/BytesMessage.html +215 -0
  6. data/doc/classes/JMS/Connection.html +1145 -0
  7. data/doc/classes/JMS/MapMessage.html +333 -0
  8. data/doc/classes/JMS/Message.html +1085 -0
  9. data/doc/classes/JMS/MessageConsumer.html +316 -0
  10. data/doc/classes/JMS/MessageListenerImpl.html +262 -0
  11. data/doc/classes/JMS/ObjectMessage.html +170 -0
  12. data/doc/classes/JMS/OracleAQConnectionFactory.html +184 -0
  13. data/doc/classes/JMS/QueueBrowser.html +155 -0
  14. data/doc/classes/JMS/Session.html +947 -0
  15. data/doc/classes/JMS/SessionPool.html +411 -0
  16. data/doc/classes/JMS/TextMessage.html +194 -0
  17. data/doc/created.rid +1 -0
  18. data/doc/files/README_md.html +440 -0
  19. data/doc/files/lib/jms/bytes_message_rb.html +122 -0
  20. data/doc/files/lib/jms/connection_rb.html +140 -0
  21. data/doc/files/lib/jms/imports_rb.html +108 -0
  22. data/doc/files/lib/jms/logging_rb.html +129 -0
  23. data/doc/files/lib/jms/map_message_rb.html +122 -0
  24. data/doc/files/lib/jms/message_consumer_rb.html +122 -0
  25. data/doc/files/lib/jms/message_listener_impl_rb.html +122 -0
  26. data/doc/files/lib/jms/message_rb.html +122 -0
  27. data/doc/files/lib/jms/object_message_rb.html +122 -0
  28. data/doc/files/lib/jms/oracle_a_q_connection_factory_rb.html +122 -0
  29. data/doc/files/lib/jms/queue_browser_rb.html +122 -0
  30. data/doc/files/lib/jms/session_pool_rb.html +108 -0
  31. data/doc/files/lib/jms/session_rb.html +164 -0
  32. data/doc/files/lib/jms/text_message_rb.html +122 -0
  33. data/doc/files/lib/jms_rb.html +131 -0
  34. data/doc/fr_class_index.html +39 -0
  35. data/doc/fr_file_index.html +42 -0
  36. data/doc/fr_method_index.html +120 -0
  37. data/doc/index.html +24 -0
  38. data/doc/rdoc-style.css +208 -0
  39. data/examples/advanced/session_pool.rb +37 -0
  40. data/examples/client-server/replier.rb +29 -0
  41. data/examples/client-server/requestor.rb +40 -0
  42. data/examples/jms.yml +85 -9
  43. data/examples/performance/consumer.rb +6 -8
  44. data/examples/performance/producer.rb +10 -10
  45. data/examples/producer-consumer/browser.rb +24 -0
  46. data/examples/{consumer.rb → producer-consumer/consumer.rb} +5 -4
  47. data/examples/producer-consumer/consumer_async.rb +30 -0
  48. data/examples/{producer.rb → producer-consumer/producer.rb} +5 -3
  49. data/examples/publish-subscribe/publish.rb +24 -0
  50. data/examples/publish-subscribe/subscribe.rb +31 -0
  51. data/lib/jms/bytes_message.rb +52 -0
  52. data/lib/jms/connection.rb +170 -162
  53. data/lib/jms/imports.rb +21 -0
  54. data/lib/jms/logging.rb +17 -1
  55. data/lib/jms/{javax_jms_map_message.rb → map_message.rb} +2 -2
  56. data/lib/jms/message.rb +285 -0
  57. data/lib/jms/{javax_jms_message_consumer.rb → message_consumer.rb} +6 -3
  58. data/lib/jms/{message_listener.rb → message_listener_impl.rb} +3 -3
  59. data/lib/jms/{javax_jms_object_message.rb → object_message.rb} +1 -1
  60. data/lib/jms/oracle_a_q_connection_factory.rb +35 -0
  61. data/lib/jms/{javax_jms_queue_browser.rb → queue_browser.rb} +5 -4
  62. data/lib/jms/{javax_jms_session.rb → session.rb} +23 -25
  63. data/lib/jms/session_pool.rb +148 -0
  64. data/lib/jms/{javax_jms_text_message.rb → text_message.rb} +1 -1
  65. data/test/connection_test.rb +31 -29
  66. data/test/jms.yml +8 -9
  67. data/test/message_test.rb +29 -29
  68. data/test/session_test.rb +39 -39
  69. metadata +62 -22
  70. data/lib/jms/javax_jms_message.rb +0 -264
data/doc/index.html ADDED
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ RDoc Documentation
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>RDoc Documentation</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/README_md.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
@@ -0,0 +1,37 @@
1
+ #
2
+ # How to use the session pool in a multi-threaded application such as Rails
3
+ # This example shows how to have multiple producers publishing information
4
+ # to topics
5
+ #
6
+
7
+ # Allow examples to be run in-place without requiring a gem install
8
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
9
+
10
+ require 'rubygems'
11
+ require 'yaml'
12
+ require 'jms'
13
+
14
+ jms_provider = ARGV[0] || 'activemq'
15
+
16
+ ### This part would typically go in a Rails Initializer ###
17
+
18
+ # Load Connection parameters from configuration file
19
+ config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
20
+ raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
21
+
22
+ JMS_CONNECTION = JMS::Connection.new(config)
23
+ JMS_CONNECTION.start
24
+ JMS_SESSION_POOL = JMS_CONNECTION.create_session_pool(config)
25
+
26
+ # Ensure connections are released if application is shutdown
27
+ at_exit do
28
+ JMS_SESSION_POOL.close
29
+ JMS_CONNECTION.close
30
+ end
31
+
32
+ ### This part would typically go in the Rails Model ###
33
+
34
+ JMS_SESSION_POOL.producer(:queue_name => 'SampleQueue') do |session, producer|
35
+ producer.send(session.message("Hello World"))
36
+ end
37
+
@@ -0,0 +1,29 @@
1
+ #
2
+ # Sample request/reply pattern replier:
3
+ # Basically does the following:
4
+ # 1) Consume messages from ExampleQueue indefinitely
5
+ # 2) Get JMSReplyTo from consumed message
6
+ # 3) Produce and send response to received message
7
+ #
8
+
9
+ # Allow examples to be run in-place without requiring a gem install
10
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
11
+
12
+ require 'rubygems'
13
+ require 'jms'
14
+ require 'yaml'
15
+
16
+ jms_provider = ARGV[0] || 'activemq'
17
+
18
+ # Load Connection parameters from configuration file
19
+ config = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'jms.yml'))[jms_provider]
20
+ raise "JMS Provider option:#{jms_provider} not found in jms.yml file" unless config
21
+
22
+ JMS::Connection.session(config) do |session|
23
+ session.consume(:queue_name => "ExampleQueue", :timeout => -1) do |message|
24
+ p "Got message: #{message.data}. Replying politely."
25
+ session.producer(:destination => message.reply_to) do |producer|
26
+ producer.send(session.message("Hello to you too!"))
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+ #
2
+ # Sample request/reply pattern requestor implementation:
3
+ # Basically what this does is:
4
+ # 1) Create temporary Queue to MQ Session
5
+ # 2) Create consumer to session (This is important to be up before producer to make sure response isn't available before consumer is up)
6
+ # 3) Create producer to session
7
+ # 4) Create message for session
8
+ # 5) Set message's JMSReplyTo to point to the temporary queue created in #1
9
+ # 6) Send message to send queue
10
+ # 7) Consume the first message available from the temporary queue within the time set in :timeout
11
+ # 8) Close temporary queue, consumer, producer and session by ending the blocks
12
+ #
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 'yaml'
19
+ require 'jms'
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.temporary_queue do |temporary_queue|
29
+ session.consumer(:destination => temporary_queue) do |consumer|
30
+ session.producer(:queue_name => "ExampleQueue") do |producer|
31
+ message = session.message("Hello World")
32
+ message.jms_reply_to = temporary_queue
33
+ producer.send(message)
34
+ end
35
+ response_message = consumer.get(:timeout => 5000) # Using timeout of 5seconds here
36
+ response = response_message != nil ? response_message.data : nil # Get message data as response if response_message is available
37
+ p response
38
+ end
39
+ end
40
+ end
data/examples/jms.yml CHANGED
@@ -1,17 +1,73 @@
1
1
  # This YAML file contains the configuration options for several different
2
2
  # JMS Providers
3
3
  #
4
- # The Examples that ship with jruby-jms will use the entry 'default' unless
4
+ # The Examples that ship with jruby-jms will use the entry 'activemq' unless
5
5
  # overriden at the command line. For example:
6
6
  # jruby producer.rb activemq
7
7
  #
8
+
8
9
  ---
10
+ # Active MQ Centralized Broker
9
11
  activemq:
10
12
  :factory: org.apache.activemq.ActiveMQConnectionFactory
11
- :broker_url: tcp://localhost:61616
13
+ :broker_url: tcp://127.0.0.1:61616
14
+ :username: system
15
+ :password: manager
16
+ :require_jars:
17
+ - ~/Applications/apache-activemq-5.4.2-fuse-03-09/activemq-all-5.4.2-fuse-03-09.jar
18
+ # ActiveMQ 5.5 Requires additional jar files
19
+ # - ~/Applications/apache-activemq-5.5.0/activemq-all-5.5.0.jar
20
+ # - ~/Applications/apache-activemq-5.5.0/lib/optional/slf4j-log4j12-1.5.11.jar
21
+ # - ~/Applications/apache-activemq-5.5.0/lib/optional/log4j-1.2.14.jar
22
+
23
+ # ActiveMQ In VM Broker (Supports messaging within a JVM instance)
24
+ activemq-vm:
25
+ :factory: org.apache.activemq.ActiveMQConnectionFactory
26
+ :broker_url: vm://127.0.0.1
27
+ :object_message_serialization_defered: true
28
+ :require_jars:
29
+ - ~/Applications/apache-activemq-5.4.2-fuse-03-09/activemq-all-5.4.2-fuse-03-09.jar
30
+
31
+ # ActiveMQ with failover to slave instance
32
+ activemq-ha:
33
+ :factory: org.apache.activemq.ActiveMQConnectionFactory
34
+ :broker_url: failover://(tcp://msg1:61616,tcp://msg2:61616)?randomize=false&timeout=30000&initialReconnectDelay=100&useExponentialBackOff=true
35
+ :require_jars:
36
+ - ~/Applications/apache-activemq-5.4.2-fuse-03-09/activemq-all-5.4.2-fuse-03-09.jar
37
+
38
+ # JBoss 4 Messaging
39
+ :jndi_name: ConnectionFactory
40
+ :jndi_context:
41
+ java.naming.factory.initial: org.jnp.interfaces.NamingContextFactory
42
+ java.naming.provider.url: jnp://localhost:1099
43
+ java.naming.security.principal: user
44
+ java.naming.security.credentials: pwd
12
45
  :require_jars:
13
- - ~/Applications/apache-activemq-5.4.2/activemq-all-5.4.2.jar
46
+ - ~/Applications/jboss-messaging-client/1.4.0.SP3/javassist.jar
47
+ - ~/Applications/jboss-messaging-client/1.4.0.SP3/jboss-aop-jdk50.jar
48
+ - ~/Applications/jboss-messaging-client/1.4.0.SP3/jboss-messaging-client.jar
49
+ - ~/Applications/jboss-messaging-client/1.4.0.SP3/jbossall-client.jar
50
+ - ~/Applications/jboss-messaging-client/1.4.0.SP3/trove.jar
14
51
 
52
+ # Apache Qpid
53
+ qpid:
54
+ :jndi_name: local
55
+ :jndi_context:
56
+ java.naming.factory.initial: org.apache.qpid.jndi.PropertiesFileInitialContextFactory
57
+ connectionfactory.local: amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'
58
+ :require_jars:
59
+ - ~/Applications/javax.jms.jar
60
+ - ~/Applications/qpid-0.8/lib/backport-util-concurrent-2.2.jar
61
+ - ~/Applications/qpid-0.8/lib/commons-collections-3.2.jar
62
+ - ~/Applications/qpid-0.8/lib/commons-lang-2.2.jar
63
+ - ~/Applications/qpid-0.8/lib/mina-core-1.0.1.jar
64
+ - ~/Applications/qpid-0.8/lib/qpid-client-0.8.jar
65
+ - ~/Applications/qpid-0.8/lib/qpid-common-0.8.jar
66
+ - ~/Applications/qpid-0.8/lib/slf4j-api-1.6.1.jar
67
+ - ~/Applications/qpid-0.8/lib/log4j-1.2.12.jar
68
+ - ~/Applications/qpid-0.8/lib/slf4j-log4j12-1.6.1.jar
69
+
70
+ # HornetQ Broker
15
71
  hornetq:
16
72
  # Connect to a local HornetQ Broker using JNDI
17
73
  :jndi_name: /ConnectionFactory
@@ -22,9 +78,29 @@ hornetq:
22
78
  java.naming.security.principal: guest
23
79
  java.naming.security.credentials: guest
24
80
  :require_jars:
25
- - ~/Applications/hornetq-2.1.2.Final/lib/hornetq-core-client.jar
26
- - ~/Applications/hornetq-2.1.2.Final/lib/hornetq-core.jar
27
- - ~/Applications/hornetq-2.1.2.Final/lib/hornetq-jms-client.jar
28
- - ~/Applications/hornetq-2.1.2.Final/lib/jboss-jms-api.jar
29
- - ~/Applications/hornetq-2.1.2.Final/lib/jnp-client.jar
30
- - ~/Applications/hornetq-2.1.2.Final/lib/netty.jar
81
+ - ~/Applications/hornetq-2.2.2.Final/lib/hornetq-core-client.jar
82
+ - ~/Applications/hornetq-2.2.2.Final/lib/hornetq-core.jar
83
+ - ~/Applications/hornetq-2.2.2.Final/lib/hornetq-jms-client.jar
84
+ - ~/Applications/hornetq-2.2.2.Final/lib/jboss-jms-api.jar
85
+ - ~/Applications/hornetq-2.2.2.Final/lib/jnp-client.jar
86
+ - ~/Applications/hornetq-2.2.2.Final/lib/netty.jar
87
+
88
+ # IBM WebSphere MQ
89
+ wmq:
90
+ :factory: com.ibm.mq.jms.MQQueueConnectionFactory
91
+ :queue_manager: LOCAL
92
+ :host_name: localhost
93
+ :channel: MY.CLIENT.CHL
94
+ :port: 1414
95
+ # Transport Type: com.ibm.mq.jms.JMSC::MQJMS_TP_CLIENT_MQ_TCPIP
96
+ :transport_type: 1
97
+ :username: mqm
98
+ :require_jars:
99
+ - /opt/mqm/lib/com.ibm.mqjms.jar
100
+
101
+ # Oracle AQ 9
102
+ oracleaq:
103
+ :factory => 'JMS::OracleAQConnectionFactory',
104
+ :url => 'jdbc:oracle:thin:@hostname:1521:instanceid',
105
+ :username => 'aquser',
106
+ :password => 'mypassword'