2008. 2. 13




  &



      1
2
kiwamu
•
•
      /


      3
kiwamu
• Ruby 2006
•         AP4R

• http://d.hatena.ne.jp/kiwamu/
                4
shino
•
                 !

•         ...C


      5
shino
•
• http://d.hatena.ne.jp/ita-wasa
•
                 6
•
• http://www.future.co.jp/index.html

•    :

•    : 1989.11.28

•        :    1,007   663   (2007.12.31   )

•    :    ...
8
9
10
1.

2.

3.

4.

5.

6.
     11
1.

     12
13
1-1. AP4R        ?

1-2.

1-3. AP4R        ?

1-4
            14
AP4R        ?

       15
AP4R                     ?

• Ruby
• Asynchronous Processing for Ruby
•
                  16
AP4R

•

• “RtFA”
           17
RtFA
• Pure Java
•                    API (≠ JMS)

•
               18
“RtFA”




         http://www.future.co.jp/company/news/061227.html
           19
•1   1

•
•
         20
• 100
• AP    “RtFA”




        21
From Java
       to Ruby


22     http://www.oreilly.co.jp/books/9784873113203/
From RtFA to AP4R
• Java

•
                 API,   etc

            23
• 2006   OSS        (MIT)

•
•
               24
AP4R

 •
 •

       25
26
27
Synchronously
Client           Server




              Sequential tasks
         28
Synchronously
Client            Server


              A   B   C   D   E



              Sequential tasks
         28
Better solution
Client   Server Messaging Server




               29
Better solution
Client   Server Messaging Server



         A   B




                 29
Asynchronously
Client   Server Messaging Server



         A   B




                 30
Asynchronously
Client   Server Messaging Server



         A   B           C   D   E




                 30
•
•
•
    31
32
Client   Server Messaging Server




                33
Client   Server Messaging Servers




                34
AP4R        ?

       35
36
?

37
38
Ruby
•
•
•
•               ...etc
           39
AP4R
•
 •           API

 •   Rails


• All in one support
 •
 •
                   40
41
?

42
43
44
45
•        ...

•              !



    46
47
•
• N/W
•
•
        48
             ... etc
49
AP4R        ...


       50
51
API




           SAF
      52
53
•
• Interactivemediums.com

           54
55
•
• Web
•            β


        56
AP4R
•
•
•
•
    CPU

          57
• AP4R            ×2

• Rails        × 4 / AP4R

•1
• MySQL
          58
Interactivemediums.com



          59
•
•
    TextMe for Business
           ( http://textmeforbusiness.com )

• 2007    7
                    60
http://textmeforbusiness.com/




              61
on SMS
             AP4R queues
acceptance


             inbound           Text
                            processing


...
AP4R        ?

       63
•
•
•
•

    64
Coffee break

     65
:Firefox =>




              (c) 2007 Mozilla Japan
         66
Foxkeh




:Firefox =>




                 (c) 2007 Mozilla Japan
         67
Duke




:Java =>




       68          https://duke.dev.java.net/
69
:AP4R => ...


     70
Copyright © 2007 by Kanican




                 Licensed under Creative Commons License.

                              71
> “AP4R”.sub(/4/,            ”A”)

> “APAR”.downcase
> “apar”
>

           Dictionary    http://www.alc.co.jp/
          ...
Copyright © 2007 by Kanican




                 Licensed under Creative Commons License.
                            73
Copyright © 2007 by Kanican




                              74
Maro
 75
76
1.

2.

3.

4.

5.

6.
     77
2.


     78
API




           SAF
      79
API

80
PUT


81
ap4r.async_to({destination},
              {data}
              [,{options}])




   c.f. RDoc: http://ap4r.rubyforge.org/...
Class AsyncShopController < ApplicationController

 def order           # synchronous part
   o = Order.new(:name => param...
User   Apache   Rails   AP4R




                84
User   Apache       Rails   AP4R

            order
                            message put




                    85
Class AsyncShopController < ApplicationController

 def order           # synchronous part
   o = Order.new(:name => param...
User   Apache       Rails   AP4R

            order
                            message put




                    87
User   Apache   Rails              AP4R




                        dispatch
                88
User   Apache    Rails   AP4R




           payment

                 89
Class AsyncShopController < ApplicationController

 def order           # synchronous part
   o = Order.new(:name => param...
91
92
User   Apache   Rails   AP4R




                93
94
User   Apache   Rails   AP4R




                95
96
User   Apache   Rails      AP4R




                        URL rewrite




                97
User   Apache      Rails      AP4R




                           URL rewrite
                HTTP




                   97
User   Apache      Rails      AP4R




                           URL rewrite
                HTTP




                   98
•               : HTTP POST

•           :
    • SOAP
    • XML-RPC
    • dRuby
                99
100
2


Task “busy”

Task “heavy”
               101
busy


URL rewrite


               heavy




         102
dispatchers:
  -
    targets: queue.very_busy.*
    threads: 10
    modify_rules:
      url: proc {|url| url.host = quot;b...
API




            SAF
      104
3.

     105
•
•


    106
Client           Server


                A       B


               order payment

         107
AP4R
Client   Rails         AP4R   Rails × 3




                 108
Client   Rails         AP4R   Rails × 3




           A


         order

                 109
Client   Rails         AP4R   Rails × 3




           A                      B


         order                payment

 ...
Client   Rails         AP4R   Rails × 3




                        100
                         75
                      ...
•
•
•
    112
113
114
1.

2.

3.

4.

5.

6.
     115
4.


     116
API




            SAF
      117
Stored And Forward


        118
119
Rails             app-DB         AP4R      msg-DB


         CRUD          Store
        SAF create
         commit
      ...
Enterprise Integration Patterns:
      Designing, Building, and
      Deploying Messaging Solutions
       by Gregor Hohpe...
SAF


      122
123
Rails   app-DB   AP4R



start




end


                 124
Rails          app-DB   AP4R



start
                CRUD




end


                        124
Rails            app-DB   AP4R



start
                CRUD

                commit




end


                          124
Rails            app-DB        AP4R



start
                CRUD

                commit

                message put / c...
Rails            app-DB        AP4R



start
                CRUD

                commit

                message put / c...
Rails            app-DB        AP4R



start
                CRUD

                commit

                message put / c...
125
...

•
•

    126
...

•
•

    127
☺



128
129
Ap4r::Client#transaction
Class ShopController < ApplicationController
  def order             # synchronous side
    ap4r....
131
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)




end
                ...
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)   Insert into SAF table
...
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)   Insert into SAF table
...
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)   Insert into SAF table
...
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)   Insert into SAF table
...
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)   Insert into SAF table
...
SAF


      133
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit

        message put / commit


end
                 data          messages

          ...
start
        CRUD

        commit
                                counterchange
        message put / commit


end
      ...
start
        CRUD

         message put / commit
                                counterchange
        commit


end
     ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
start
        CRUD

         message put / commit

        commit


end
                 data       messages

            ...
•
• N/W
•
•
              ... etc
        142
☺

☠
143
SAF


      144
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               d...
start    CRUD

        SAF create

         commit
          message put / commit
                           Recoverable
 ...
start    CRUD

        SAF create

         commit
          message put / commit
                           Recoverable
 ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                ...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               d...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               d...
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update         Duplicated
e...
154
at-least-once
      155
API




            SAF
      156
5.

     157
•
• Capistrano (2.x)
•
                 158
2
    • Functional
     •
     •

    • Async
     •
     •
               159
gihyo.jp

• AP4R Ruby
• 4 (2007.9.6 - 9.27)
• http://gihyo.jp/dev/feature/01/ap4r

                   160
161
TDD / BDD

    162
☺



163
•             ...

• N/W
•
•
        164
2
    • Functional
     •
     •

    • Async
     •
     •
               165
Functional

•
•

            166
167
def test_order
  post :order, :order => {:item => quot;introduction to AP4Rquot;}
  assert_response :redirect
  assert_red...
functional test


rake ..         CRUD


            message put
                        Stub
            assert

        ...
Async

•
•
• e.g.

                 170
171
[RAILS_ROOT]/test/async/ap4r_test_helper.rb
 ENV[quot;RAILS_ENVquot;] = quot;testquot;
 require File.expand_path(File.dirn...
[RAILS_ROOT]/test/async/async_shop_test.rb
require quot;#{File.dirname(__FILE__)}/ap4r_test_helperquot;
require 'net/http'...
1. dispatcher
2. HTTP POST    Rails
3. orders                     assert
4. dispatcher
5.
6. payment                     a...
async test


rake ..
                 service control
            HTTP
                            CRUD

                 ...
•              2
• Functional
• Async
•
                   176
6.

     177
AP4R     ..

   178
179
API




            SAF
      180
•         API



• Rails
•
           181
• dispatcher

• SAF
•
               182
183
ver.0.3.x

☑
☑ URL
☑ DLQ / SAF
□                   : Stomp, HTTP
              184
ver.0.4.x


□ OSS                Cacti,
    ZABBIX

□       AP4R

□
               185
ver.0.5.x



□
□
□
    186
□
☑

□
□ Ruby off Rails
              187
AP4R@RubyForge
• wiki: http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage

• source:    svn co http://ap4r.rubyforge.org/svn/...
•   Future Architect logo belongs to Future Architect, Inc.
    Japan. All rights reserved.

•   Rails logo is trademarks ...
Upcoming SlideShare
Loading in...5
×

AP4R on Developers Summit 2008

1,146

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,146
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

AP4R on Developers Summit 2008

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

    Clipping is a handy way to collect important slides you want to go back to later.

×