jruby-jms 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,316 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: JMS::MessageConsumer</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">JMS::MessageConsumer</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/jms/message_consumer_rb.html">
59
+ lib/jms/message_consumer.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ Interface javax.jms.<a href="MessageConsumer.html">MessageConsumer</a>
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000046">each</a>&nbsp;&nbsp;
90
+ <a href="#M000045">get</a>&nbsp;&nbsp;
91
+ <a href="#M000047">on_message</a>&nbsp;&nbsp;
92
+ <a href="#M000048">on_message_statistics</a>&nbsp;&nbsp;
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+
98
+
99
+ <!-- if includes -->
100
+
101
+ <div id="section">
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ <!-- if method_list -->
111
+ <div id="methods">
112
+ <h3 class="section-bar">Public Instance methods</h3>
113
+
114
+ <div id="method-M000046" class="method-detail">
115
+ <a name="M000046"></a>
116
+
117
+ <div class="method-heading">
118
+ <a href="#M000046" class="method-signature">
119
+ <span class="method-name">each</span><span class="method-args">(params={}, &amp;proc)</span>
120
+ </a>
121
+ </div>
122
+
123
+ <div class="method-description">
124
+ <p>
125
+ For <a href="MessageConsumer.html#M000046">each</a> message available to be
126
+ consumed call the Proc supplied Returns the statistics gathered when
127
+ :statistics =&gt; true, otherwise nil
128
+ </p>
129
+ <p>
130
+ Parameters:
131
+ </p>
132
+ <pre>
133
+ :timeout How to timeout waiting for messages on the Queue or Topic
134
+ -1 : Wait forever
135
+ 0 : Return immediately if no message is available
136
+ x : Wait for x milli-seconds for a message to be received from the broker
137
+ Note: Messages may still be on the queue, but the broker has not supplied any messages
138
+ in the time interval specified
139
+ Default: 0
140
+
141
+ :statistics Capture statistics on how many messages have been read
142
+ true : This method will capture statistics on the number of messages received
143
+ and the time it took to process them.
144
+ The statistics can be reset by calling MessageConsumer::each again
145
+ with :statistics =&gt; true
146
+
147
+ The statistics gathered are returned when :statistics =&gt; true and :async =&gt; false
148
+ </pre>
149
+ <p><a class="source-toggle" href="#"
150
+ onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
151
+ <div class="method-source-code" id="M000046-source">
152
+ <pre>
153
+ <span class="ruby-comment cmt"># File lib/jms/message_consumer.rb, line 58</span>
154
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>(<span class="ruby-identifier">params</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
155
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Destination::each requires a code block to be executed for each message received&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">proc</span>
156
+
157
+ <span class="ruby-identifier">message_count</span> = <span class="ruby-keyword kw">nil</span>
158
+ <span class="ruby-identifier">start_time</span> = <span class="ruby-keyword kw">nil</span>
159
+
160
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:statistics</span>]
161
+ <span class="ruby-identifier">message_count</span> = <span class="ruby-value">0</span>
162
+ <span class="ruby-identifier">start_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
163
+ <span class="ruby-keyword kw">end</span>
164
+
165
+ <span class="ruby-comment cmt"># Receive messages according to timeout</span>
166
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword kw">do</span>
167
+ <span class="ruby-identifier">proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">message</span>)
168
+ <span class="ruby-identifier">message_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">message_count</span>
169
+ <span class="ruby-keyword kw">end</span>
170
+
171
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">message_count</span>.<span class="ruby-identifier">nil?</span>
172
+ <span class="ruby-identifier">duration</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">start_time</span>
173
+ {<span class="ruby-identifier">:messages</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">message_count</span>,
174
+ <span class="ruby-identifier">:duration</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">duration</span>,
175
+ <span class="ruby-identifier">:messages_per_second</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">duration</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> (<span class="ruby-identifier">message_count</span><span class="ruby-operator">/</span><span class="ruby-identifier">duration</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>,
176
+ <span class="ruby-identifier">:ms_per_msg</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">message_count</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> (<span class="ruby-identifier">duration</span><span class="ruby-operator">*</span><span class="ruby-value">1000.0</span>)<span class="ruby-operator">/</span><span class="ruby-identifier">message_count</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
177
+ }
178
+ <span class="ruby-keyword kw">end</span>
179
+ <span class="ruby-keyword kw">end</span>
180
+ </pre>
181
+ </div>
182
+ </div>
183
+ </div>
184
+
185
+ <div id="method-M000045" class="method-detail">
186
+ <a name="M000045"></a>
187
+
188
+ <div class="method-heading">
189
+ <a href="#M000045" class="method-signature">
190
+ <span class="method-name">get</span><span class="method-args">(params={})</span>
191
+ </a>
192
+ </div>
193
+
194
+ <div class="method-description">
195
+ <p>
196
+ Obtain a message from the Destination or Topic In <a
197
+ href="../JMS.html">JMS</a> terms, the message is received from the
198
+ Destination :timeout follows the rules for MQSeries:
199
+ </p>
200
+ <pre>
201
+ -1 : Wait forever
202
+ 0 : Return immediately if no message is available
203
+ x : Wait for x milli-seconds for a message to be received from the broker
204
+ Note: Messages may still be on the queue, but the broker has not supplied any messages
205
+ in the time interval specified
206
+ Default: 0
207
+ </pre>
208
+ <p><a class="source-toggle" href="#"
209
+ onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
210
+ <div class="method-source-code" id="M000045-source">
211
+ <pre>
212
+ <span class="ruby-comment cmt"># File lib/jms/message_consumer.rb, line 28</span>
213
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">params</span>={})
214
+ <span class="ruby-identifier">timeout</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:timeout</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
215
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">timeout</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span>
216
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">receive</span>
217
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">timeout</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
218
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">receiveNoWait</span>
219
+ <span class="ruby-keyword kw">else</span>
220
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">receive</span>(<span class="ruby-identifier">timeout</span>)
221
+ <span class="ruby-keyword kw">end</span>
222
+ <span class="ruby-keyword kw">end</span>
223
+ </pre>
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <div id="method-M000047" class="method-detail">
229
+ <a name="M000047"></a>
230
+
231
+ <div class="method-heading">
232
+ <a href="#M000047" class="method-signature">
233
+ <span class="method-name">on_message</span><span class="method-args">(params={}, &amp;proc)</span>
234
+ </a>
235
+ </div>
236
+
237
+ <div class="method-description">
238
+ <p>
239
+ Receive messages in a separate thread when they arrive Allows messages to
240
+ be recieved in a separate thread. I.e. Asynchronously This method will
241
+ return to the caller before messages are processed. It is then the callers
242
+ responsibility to keep the program active so that messages can then be
243
+ processed.
244
+ </p>
245
+ <p>
246
+ Parameters:
247
+ </p>
248
+ <pre>
249
+ :statistics Capture statistics on how many messages have been read
250
+ true : This method will capture statistics on the number of messages received
251
+ and the time it took to process them.
252
+ The timer starts when each() is called and finishes when either the last message was received,
253
+ or when Destination::statistics is called. In this case MessageConsumer::statistics
254
+ can be called several times during processing without affecting the end time.
255
+ Also, the start time and message count is not reset until MessageConsumer::each
256
+ is called again with :statistics =&gt; true
257
+
258
+ The statistics gathered are returned when :statistics =&gt; true and :async =&gt; false
259
+ </pre>
260
+ <p><a class="source-toggle" href="#"
261
+ onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
262
+ <div class="method-source-code" id="M000047-source">
263
+ <pre>
264
+ <span class="ruby-comment cmt"># File lib/jms/message_consumer.rb, line 103</span>
265
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_message</span>(<span class="ruby-identifier">params</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
266
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;MessageConsumer::on_message requires a code block to be executed for each message received&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">proc</span>
267
+
268
+ <span class="ruby-ivar">@listener</span> = <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-constant">MessageListenerImpl</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>,<span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
269
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">setMessageListener</span> <span class="ruby-ivar">@listener</span>
270
+ <span class="ruby-keyword kw">end</span>
271
+ </pre>
272
+ </div>
273
+ </div>
274
+ </div>
275
+
276
+ <div id="method-M000048" class="method-detail">
277
+ <a name="M000048"></a>
278
+
279
+ <div class="method-heading">
280
+ <a href="#M000048" class="method-signature">
281
+ <span class="method-name">on_message_statistics</span><span class="method-args">()</span>
282
+ </a>
283
+ </div>
284
+
285
+ <div class="method-description">
286
+ <p>
287
+ Return the current statistics for a running MessageConsumer::on_message
288
+ </p>
289
+ <p><a class="source-toggle" href="#"
290
+ onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
291
+ <div class="method-source-code" id="M000048-source">
292
+ <pre>
293
+ <span class="ruby-comment cmt"># File lib/jms/message_consumer.rb, line 111</span>
294
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_message_statistics</span>
295
+ <span class="ruby-identifier">stats</span> = <span class="ruby-ivar">@listener</span>.<span class="ruby-identifier">statistics</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listener</span>
296
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;First call MessageConsumer::on_message with :statistics=&gt;true before calling MessageConsumer::statistics()&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stats</span>
297
+ <span class="ruby-identifier">stats</span>
298
+ <span class="ruby-keyword kw">end</span>
299
+ </pre>
300
+ </div>
301
+ </div>
302
+ </div>
303
+
304
+
305
+ </div>
306
+
307
+
308
+ </div>
309
+
310
+
311
+ <div id="validator-badges">
312
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
313
+ </div>
314
+
315
+ </body>
316
+ </html>
@@ -0,0 +1,262 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: JMS::MessageListenerImpl</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">JMS::MessageListenerImpl</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/jms/message_listener_impl_rb.html">
59
+ lib/jms/message_listener_impl.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ For internal use only by <a href="Connection.html">JMS::Connection</a>
84
+ </p>
85
+
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+ <div id="method-list">
92
+ <h3 class="section-bar">Methods</h3>
93
+
94
+ <div class="name-list">
95
+ <a href="#M000086">new</a>&nbsp;&nbsp;
96
+ <a href="#M000087">onMessage</a>&nbsp;&nbsp;
97
+ <a href="#M000088">statistics</a>&nbsp;&nbsp;
98
+ </div>
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ <!-- if includes -->
105
+ <div id="includes">
106
+ <h3 class="section-bar">Included Modules</h3>
107
+
108
+ <div id="includes-list">
109
+ <span class="include-name">JMS::MessageListener</span>
110
+ </div>
111
+ </div>
112
+
113
+ <div id="section">
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <!-- if method_list -->
123
+ <div id="methods">
124
+ <h3 class="section-bar">Public Class methods</h3>
125
+
126
+ <div id="method-M000086" class="method-detail">
127
+ <a name="M000086"></a>
128
+
129
+ <div class="method-heading">
130
+ <a href="#M000086" class="method-signature">
131
+ <span class="method-name">new</span><span class="method-args">(params={}, &amp;proc)</span>
132
+ </a>
133
+ </div>
134
+
135
+ <div class="method-description">
136
+ <p>
137
+ Parameters:
138
+ </p>
139
+ <pre>
140
+ :statistics Capture statistics on how many messages have been read
141
+ true : This method will capture statistics on the number of messages received
142
+ and the time it took to process them.
143
+ The timer starts when the listener instance is created and finishes when either the last message was received,
144
+ or when Destination::statistics is called. In this case MessageConsumer::statistics
145
+ can be called several times during processing without affecting the end time.
146
+ Also, the start time and message count is not reset until MessageConsumer::each
147
+ is called again with :statistics =&gt; true
148
+
149
+ The statistics gathered are returned when :statistics =&gt; true and :async =&gt; false
150
+ </pre>
151
+ <p><a class="source-toggle" href="#"
152
+ onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
153
+ <div class="method-source-code" id="M000086-source">
154
+ <pre>
155
+ <span class="ruby-comment cmt"># File lib/jms/message_listener_impl.rb, line 35</span>
156
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
157
+ <span class="ruby-ivar">@proc</span> = <span class="ruby-identifier">proc</span>
158
+
159
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:statistics</span>]
160
+ <span class="ruby-ivar">@message_count</span> = <span class="ruby-value">0</span>
161
+ <span class="ruby-ivar">@start_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
162
+ <span class="ruby-keyword kw">end</span>
163
+ <span class="ruby-keyword kw">end</span>
164
+ </pre>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <h3 class="section-bar">Public Instance methods</h3>
170
+
171
+ <div id="method-M000087" class="method-detail">
172
+ <a name="M000087"></a>
173
+
174
+ <div class="method-heading">
175
+ <a href="#M000087" class="method-signature">
176
+ <span class="method-name">onMessage</span><span class="method-args">(message)</span>
177
+ </a>
178
+ </div>
179
+
180
+ <div class="method-description">
181
+ <p>
182
+ Method called for every message received on the queue Per the <a
183
+ href="../JMS.html">JMS</a> specification, this method will be called
184
+ sequentially for each message on the queue. This method will not be called
185
+ again until its prior invocation has completed. Must be <a
186
+ href="MessageListenerImpl.html#M000087">onMessage</a>() since on_message()
187
+ does not work for interface methods that must be implemented
188
+ </p>
189
+ <p><a class="source-toggle" href="#"
190
+ onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
191
+ <div class="method-source-code" id="M000087-source">
192
+ <pre>
193
+ <span class="ruby-comment cmt"># File lib/jms/message_listener_impl.rb, line 48</span>
194
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">onMessage</span>(<span class="ruby-identifier">message</span>)
195
+ <span class="ruby-keyword kw">begin</span>
196
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@message_count</span>
197
+ <span class="ruby-ivar">@message_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
198
+ <span class="ruby-ivar">@last_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
199
+ <span class="ruby-keyword kw">end</span>
200
+ <span class="ruby-ivar">@proc</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">message</span>
201
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SyntaxError</span>, <span class="ruby-constant">NameError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">boom</span>
202
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-value str">&quot;Unhandled Exception processing JMS Message. Doesn't compile: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">boom</span>
203
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Ignoring poison message:\n#{message.inspect}&quot;</span>
204
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-identifier">boom</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
205
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bang</span>
206
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-value str">&quot;Unhandled Exception processing JMS Message. Doesn't compile: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">bang</span>
207
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Ignoring poison message:\n#{message.inspect}&quot;</span>
208
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-identifier">boom</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
209
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exc</span>
210
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Unhandled Exception processing JMS Message. Exception occurred:\n#{exc}&quot;</span>
211
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Ignoring poison message:\n#{message.inspect}&quot;</span>
212
+ <span class="ruby-constant">JMS</span><span class="ruby-operator">::</span><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
213
+ <span class="ruby-keyword kw">end</span>
214
+ <span class="ruby-keyword kw">end</span>
215
+ </pre>
216
+ </div>
217
+ </div>
218
+ </div>
219
+
220
+ <div id="method-M000088" class="method-detail">
221
+ <a name="M000088"></a>
222
+
223
+ <div class="method-heading">
224
+ <a href="#M000088" class="method-signature">
225
+ <span class="method-name">statistics</span><span class="method-args">()</span>
226
+ </a>
227
+ </div>
228
+
229
+ <div class="method-description">
230
+ <p>
231
+ Return Statistics gathered for this listener
232
+ </p>
233
+ <p><a class="source-toggle" href="#"
234
+ onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
235
+ <div class="method-source-code" id="M000088-source">
236
+ <pre>
237
+ <span class="ruby-comment cmt"># File lib/jms/message_listener_impl.rb, line 71</span>
238
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">statistics</span>
239
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;First call MessageConsumer::on_message with :statistics=&gt;true before calling MessageConsumer::statistics()&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@message_count</span>
240
+ <span class="ruby-identifier">duration</span> =(<span class="ruby-ivar">@last_time</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>) <span class="ruby-operator">-</span> <span class="ruby-ivar">@start_time</span>
241
+ {<span class="ruby-identifier">:messages</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@message_count</span>,
242
+ <span class="ruby-identifier">:duration</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">duration</span>,
243
+ <span class="ruby-identifier">:messages_per_second</span> =<span class="ruby-operator">&gt;</span> (<span class="ruby-ivar">@message_count</span><span class="ruby-operator">/</span><span class="ruby-identifier">duration</span>).<span class="ruby-identifier">to_i</span>}
244
+ <span class="ruby-keyword kw">end</span>
245
+ </pre>
246
+ </div>
247
+ </div>
248
+ </div>
249
+
250
+
251
+ </div>
252
+
253
+
254
+ </div>
255
+
256
+
257
+ <div id="validator-badges">
258
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
259
+ </div>
260
+
261
+ </body>
262
+ </html>