AP4R on Developers Summit 2008

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    AP4R on Developers Summit 2008 - Presentation Transcript

    1. 2008. 2. 13 & 1
    2. 2
    3. kiwamu • • / 3
    4. kiwamu • Ruby 2006 • AP4R • http://d.hatena.ne.jp/kiwamu/ 4
    5. shino • ! • ...C 5
    6. shino • • http://d.hatena.ne.jp/ita-wasa • 6
    7. • • http://www.future.co.jp/index.html • : • : 1989.11.28 • : 1,007 663 (2007.12.31 ) • : 250 18 160 46 7
    8. 8
    9. 9
    10. 10
    11. 1. 2. 3. 4. 5. 6. 11
    12. 1. 12
    13. 13
    14. 1-1. AP4R ? 1-2. 1-3. AP4R ? 1-4 14
    15. AP4R ? 15
    16. AP4R ? • Ruby • Asynchronous Processing for Ruby • 16
    17. AP4R • • “RtFA” 17
    18. RtFA • Pure Java • API (≠ JMS) • 18
    19. “RtFA” http://www.future.co.jp/company/news/061227.html 19
    20. •1 1 • • 20
    21. • 100 • AP “RtFA” 21
    22. From Java to Ruby 22 http://www.oreilly.co.jp/books/9784873113203/
    23. From RtFA to AP4R • Java • API, etc 23
    24. • 2006 OSS (MIT) • • 24
    25. AP4R • • 25
    26. 26
    27. 27
    28. Synchronously Client Server Sequential tasks 28
    29. Synchronously Client Server A B C D E Sequential tasks 28
    30. Better solution Client Server Messaging Server 29
    31. Better solution Client Server Messaging Server A B 29
    32. Asynchronously Client Server Messaging Server A B 30
    33. Asynchronously Client Server Messaging Server A B C D E 30
    34. • • • 31
    35. 32
    36. Client Server Messaging Server 33
    37. Client Server Messaging Servers 34
    38. AP4R ? 35
    39. 36
    40. ? 37
    41. 38
    42. Ruby • • • • ...etc 39
    43. AP4R • • API • Rails • All in one support • • 40
    44. 41
    45. ? 42
    46. 43
    47. 44
    48. 45
    49. • ... • ! 46
    50. 47
    51. • • N/W • • 48 ... etc
    52. 49
    53. AP4R ... 50
    54. 51
    55. API SAF 52
    56. 53
    57. • • Interactivemediums.com 54
    58. 55
    59. • • Web • β 56
    60. AP4R • • • • CPU 57
    61. • AP4R ×2 • Rails × 4 / AP4R •1 • MySQL 58
    62. Interactivemediums.com 59
    63. • • TextMe for Business ( http://textmeforbusiness.com ) • 2007 7 60
    64. http://textmeforbusiness.com/ 61
    65. on SMS AP4R queues acceptance inbound Text processing delivery outbound delivery delivery processing Third Party routing application 62
    66. AP4R ? 63
    67. • • • • 64
    68. Coffee break 65
    69. :Firefox => (c) 2007 Mozilla Japan 66
    70. Foxkeh :Firefox => (c) 2007 Mozilla Japan 67
    71. Duke :Java => 68 https://duke.dev.java.net/
    72. 69
    73. :AP4R => ... 70
    74. Copyright © 2007 by Kanican Licensed under Creative Commons License. 71
    75. > “AP4R”.sub(/4/, ”A”) > “APAR”.downcase > “apar” > Dictionary http://www.alc.co.jp/ Photo http://www.flickr.com/photos/jeffclow/29738818/ 72
    76. Copyright © 2007 by Kanican Licensed under Creative Commons License. 73
    77. Copyright © 2007 by Kanican 74
    78. Maro 75
    79. 76
    80. 1. 2. 3. 4. 5. 6. 77
    81. 2. 78
    82. API SAF 79
    83. API 80
    84. PUT 81
    85. ap4r.async_to({destination}, {data} [,{options}]) c.f. RDoc: http://ap4r.rubyforge.org/doc/ 82
    86. Class AsyncShopController < ApplicationController def order # synchronous part o = Order.new(:name => params[:name]) o.save! ap4r.async_to({:action => ‘payment’}, {:order_id => o.id}) redirect_to ... end def payment # asynchronous part Payment.new(:order_id => params[:order_id]).save! ... render :text => ‘true’ end end 83
    87. User Apache Rails AP4R 84
    88. User Apache Rails AP4R order message put 85
    89. Class AsyncShopController < ApplicationController def order # synchronous part o = Order.new(:name => params[:name]) o.save! ap4r.async_to({:action => ‘payment’}, {:order_id => o.id}) redirect_to ... end def payment # asynchronous part Payment.new(:order_id => params[:order_id]).save! ... render :text => ‘true’ end end 86
    90. User Apache Rails AP4R order message put 87
    91. User Apache Rails AP4R dispatch 88
    92. User Apache Rails AP4R payment 89
    93. Class AsyncShopController < ApplicationController def order # synchronous part o = Order.new(:name => params[:name]) o.save! ap4r.async_to({:action => ‘payment’}, {:order_id => o.id}) redirect_to ... end def payment # asynchronous part Payment.new(:order_id => params[:order_id]).save! ... render :text => ‘true’ end end 90
    94. 91
    95. 92
    96. User Apache Rails AP4R 93
    97. 94
    98. User Apache Rails AP4R 95
    99. 96
    100. User Apache Rails AP4R URL rewrite 97
    101. User Apache Rails AP4R URL rewrite HTTP 97
    102. User Apache Rails AP4R URL rewrite HTTP 98
    103. • : HTTP POST • : • SOAP • XML-RPC • dRuby 99
    104. 100
    105. 2 Task “busy” Task “heavy” 101
    106. busy URL rewrite heavy 102
    107. dispatchers: - targets: queue.very_busy.* threads: 10 modify_rules: url: proc {|url| url.host = \"busy.async.host\"} - targets: queue.very_heavy.* threads: 1 modify_rules: url: proc {|url| url.host = \"heavy.async.host\"} 103
    108. API SAF 104
    109. 3. 105
    110. • • 106
    111. Client Server A B order payment 107
    112. AP4R Client Rails AP4R Rails × 3 108
    113. Client Rails AP4R Rails × 3 A order 109
    114. Client Rails AP4R Rails × 3 A B order payment 110
    115. Client Rails AP4R Rails × 3 100 75 50 25 0 111
    116. • • • 112
    117. 113
    118. 114
    119. 1. 2. 3. 4. 5. 6. 115
    120. 4. 116
    121. API SAF 117
    122. Stored And Forward 118
    123. 119
    124. Rails app-DB AP4R msg-DB CRUD Store SAF create commit Forward message put insert /commit SAF delete ✓ 120
    125. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions by Gregor Hohpe,Bobby Woolf Guaranteed Delivery [122] 121
    126. SAF 122
    127. 123
    128. Rails app-DB AP4R start end 124
    129. Rails app-DB AP4R start CRUD end 124
    130. Rails app-DB AP4R start CRUD commit end 124
    131. Rails app-DB AP4R start CRUD commit message put / commit end 124
    132. Rails app-DB AP4R start CRUD commit message put / commit end data 124
    133. Rails app-DB AP4R start CRUD commit message put / commit end data messages 124
    134. 125
    135. ... • • 126
    136. ... • • 127
    137. ☺ 128
    138. 129
    139. Ap4r::Client#transaction Class ShopController < ApplicationController def order # synchronous side ap4r.transaction do o = Order.new(:name => params[:order_id]) o.save! ap4r.async_to({:action => ‘payment’}, {:order_id => o.id}) end redirect_to ... end end 130
    140. 131
    141. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) end 132
    142. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) Insert into SAF table end 132
    143. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) Insert into SAF table end Commit database 132
    144. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) Insert into SAF table end Commit database Queue messages 132
    145. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) Insert into SAF table Store end Commit database Queue messages 132
    146. ap4r.transaction ap4r.transaction do ... # CRUD on database ap4r.async_to(...) Insert into SAF table Store end Commit database Queue messages Forward 132
    147. SAF 133
    148. start CRUD commit message put / commit end data messages 134
    149. start CRUD commit message put / commit end data messages 134
    150. start CRUD commit message put / commit end data messages 135
    151. start CRUD commit message put / commit end data messages 135
    152. start CRUD commit message put / commit end data messages 135
    153. start CRUD commit message put / commit end data messages 136
    154. start CRUD commit message put / commit end data messages 136
    155. start CRUD commit message put / commit end data messages 136
    156. start CRUD commit counterchange message put / commit end data messages 137
    157. start CRUD message put / commit counterchange commit end data messages 138
    158. start CRUD message put / commit commit end data messages 139
    159. start CRUD message put / commit commit end data messages 139
    160. start CRUD message put / commit commit end data messages 140
    161. start CRUD message put / commit commit end data messages 140
    162. start CRUD message put / commit commit end data messages 140
    163. start CRUD message put / commit commit end data messages 141
    164. start CRUD message put / commit commit end data messages 141
    165. start CRUD message put / commit commit end data messages 141
    166. • • N/W • • ... etc 142
    167. ☺ ☠ 143
    168. SAF 144
    169. start CRUD SAF create commit message put / commit SAF update end data messages 145
    170. start CRUD SAF create commit message put / commit SAF update end data messages 146
    171. start CRUD SAF create commit message put / commit SAF update end data messages 146
    172. start CRUD SAF create commit message put / commit SAF update end data messages 147
    173. start CRUD SAF create commit message put / commit SAF update end data messages 147
    174. start CRUD SAF create commit message put / commit SAF update end data messages 147
    175. start CRUD SAF create commit message put / commit SAF update end data ☺ messages 147
    176. start CRUD SAF create commit message put / commit SAF update end data messages 147
    177. start CRUD SAF create commit message put / commit SAF update end data messages 148
    178. start CRUD SAF create commit message put / commit SAF update end data messages 148
    179. start CRUD SAF create commit message put / commit SAF update end data messages 149
    180. start CRUD SAF create commit message put / commit SAF update end data messages 149
    181. start CRUD SAF create commit message put / commit SAF update end data messages 149
    182. start CRUD SAF create commit message put / commit SAF update end data ☺ messages 149
    183. start CRUD SAF create commit message put / commit SAF update end data messages 150
    184. start CRUD SAF create commit message put / commit SAF update end data messages 150
    185. start CRUD SAF create commit message put / commit SAF update end data messages 151
    186. start CRUD SAF create commit message put / commit SAF update end data messages 151
    187. start CRUD SAF create commit message put / commit SAF update end data messages messages 151
    188. start CRUD SAF create commit message put / commit Recoverable SAF update end data messages messages 151
    189. start CRUD SAF create commit message put / commit Recoverable SAF update end data messages ☺ messages 151
    190. start CRUD SAF create commit message put / commit SAF update end data messages 152
    191. start CRUD SAF create commit message put / commit SAF update end data messages 152
    192. start CRUD SAF create commit message put / commit SAF update end data messages 153
    193. start CRUD SAF create commit message put / commit SAF update end data messages messages 153
    194. start CRUD SAF create commit message put / commit SAF update end data messages ☺ messages 153
    195. start CRUD SAF create commit message put / commit SAF update Duplicated end data messages ☺ messages 153
    196. 154
    197. at-least-once 155
    198. API SAF 156
    199. 5. 157
    200. • • Capistrano (2.x) • 158
    201. 2 • Functional • • • Async • • 159
    202. gihyo.jp • AP4R Ruby • 4 (2007.9.6 - 9.27) • http://gihyo.jp/dev/feature/01/ap4r 160
    203. 161
    204. TDD / BDD 162
    205. ☺ 163
    206. • ... • N/W • • 164
    207. 2 • Functional • • • Async • • 165
    208. Functional • • 166
    209. 167
    210. def test_order post :order, :order => {:item => \"introduction to AP4R\"} assert_response :redirect assert_redirected_to :action => 'index' messages = @controller.ap4r.queued_messages # ... (1) assert_equal 1, messages.keys.size, \"should have messages in just ONE queue\" assert messages.key?(\"queue.async_shop.payment\"), \"queue name is INCORRECT\" # ... (2) assert_equal 1, messages[\"queue.async_shop.payment\"].size, \"should have just ONE message for payment\" assert_match /order_id=\\d+/, messages[\"queue.async_shop.payment\"].first[:body], \"parameter order_id should be included with a numeric value\" # ... (3) end 1. 2. assert 3. assert 168
    211. functional test rake .. CRUD message put Stub assert assert 169
    212. Async • • • e.g. 170
    213. 171
    214. [RAILS_ROOT]/test/async/ap4r_test_helper.rb ENV[\"RAILS_ENV\"] = \"test\" require File.expand_path(File.dirname(__FILE__) + \"/../../config/environment\") require \"ap4r/service_handler\" ap4r_test_helper = Ap4r::ServiceHandler.new require 'test_help' class Test::Unit::TestCase self.use_transactional_fixtures = false self.use_instantiated_fixtures = false # Add more helper methods to be used by all tests here... cattr_accessor :ap4r_helper def ap4r_helper @@ap4r_helper end def with_services(&block) ap4r_helper.with_services(&block) end end Test::Unit::TestCase.ap4r_helper = ap4r_test_helper 172
    215. [RAILS_ROOT]/test/async/async_shop_test.rb require \"#{File.dirname(__FILE__)}/ap4r_test_helper\" require 'net/http' class AsyncShopTest < Test::Unit::TestCase def test_http_dispatch ap4r_helper.stop_dispatchers # ... (1) assert_rows_added(Order, 1) { # ... (3) do_order # ... (2) } assert_rows_added(Payment, 1) { # ... (6) ap4r_helper.start_dispatchers # ... (4) ap4r_helper.wait_all_done # ... (5) } end private # Requests to <tt>async_shop/order</tt>. def do_order(item_name = \"test item\") Net::HTTP.start(\"localhost\", 3000, nil, nil) do |http| http.request_post(\"/async_shop/order\", \"order[item]=#{item_name}\") do |res| #nop end end end def assert_rows_added(model, rows) rows_before = model.count yield rows_after = model.count assert_equal rows, rows_after - rows_before, \"table '#{model.table_name}' should count up by #{rows}\" end end 173
    216. 1. dispatcher 2. HTTP POST Rails 3. orders assert 4. dispatcher 5. 6. payment assert 174
    217. async test rake .. service control HTTP CRUD message put assert HTTP CRUD assert 175
    218. • 2 • Functional • Async • 176
    219. 6. 177
    220. AP4R .. 178
    221. 179
    222. API SAF 180
    223. • API • Rails • 181
    224. • dispatcher • SAF • 182
    225. 183
    226. ver.0.3.x ☑ ☑ URL ☑ DLQ / SAF □ : Stomp, HTTP 184
    227. ver.0.4.x □ OSS Cacti, ZABBIX □ AP4R □ 185
    228. ver.0.5.x □ □ □ 186
    229. □ ☑ □ □ Ruby off Rails 187
    230. AP4R@RubyForge • wiki: http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage • source: svn co http://ap4r.rubyforge.org/svn/trunk/ap4r • ML: http://rubyforge.org/mailman/listinfo/ap4r-user Your patches are welcome! Thank you. by Kanican 188
    231. • Future Architect logo belongs to Future Architect, Inc. Japan. All rights reserved. • Rails logo is trademarks of David Heinemeier Hansson. All rights reserved. • The Ruby logo is copyrighted (c) 2006, Yukihiro Matsumoto. It is released under the terms of the Creative Commons Attribution-ShareAlike 2.5 License. 189

    + Kato KiwamuKato Kiwamu, 2 years ago

    custom

    652 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 652
      • 652 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 10
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories