SlideShare una empresa de Scribd logo
1 de 231
Descargar para leer sin conexión
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   )

•    :       250 18         160 46
                      7
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


 delivery    outbound                    delivery
                             delivery
                            processing

                                                Third Party
             routing                            application


                       62
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/
           Photo   http://www.flickr.com/photos/jeffclow/29738818/
                        72
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/doc/
                  82
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
User   Apache   Rails   AP4R




                84
User   Apache       Rails   AP4R

            order
                            message put




                    85
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
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 => 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
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;busy.async.hostquot;}
  -
    targets: queue.very_heavy.*
    threads: 1
    modify_rules:
      url: proc {|url| url.host = quot;heavy.async.hostquot;}


                         103
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

                 110
Client   Rails         AP4R   Rails × 3




                        100
                         75
                         50
                         25
                          0


                 111
•
•
•
    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
                           Forward
                     message put
                                  insert /commit

        SAF delete
                      ✓
                           120
Enterprise Integration Patterns:
      Designing, Building, and
      Deploying Messaging Solutions
       by Gregor Hohpe,Bobby Woolf


  Guaranteed Delivery [122]




121
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 / commit


end


                          124
Rails            app-DB        AP4R



start
                CRUD

                commit

                message put / commit


end
                         data
                          124
Rails            app-DB        AP4R



start
                CRUD

                commit

                message put / commit


end
                         data      messages
                          124
125
...

•
•

    126
...

•
•

    127
☺



128
129
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
131
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

 ap4r.async_to(...)




end
                        132
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

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



end
                        132
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

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



end                     Commit database



                        132
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

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



end                     Commit database
                        Queue messages


                        132
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

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


end                     Commit database
                        Queue messages


                        132
ap4r.transaction

ap4r.transaction do
  ...               # CRUD on database

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


end                     Commit database
                        Queue messages
                                   Forward
                        132
SAF


      133
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   134
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   134
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   135
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   135
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   135
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   136
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   136
start
        CRUD

        commit

        message put / commit


end
                 data          messages

                   136
start
        CRUD

        commit
                                counterchange
        message put / commit


end
                 data          messages

                   137
start
        CRUD

         message put / commit
                                counterchange
        commit


end
                 data       messages

                   138
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   139
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   139
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   140
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   140
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   140
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   141
start
        CRUD

         message put / commit

        commit


end
                 data       messages

                   141
start
        CRUD

         message put / commit

        commit


end
                 data       messages

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

☠
143
SAF


      144
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     145
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     146
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     146
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     147
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     147
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     147
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data       ☺     messages

                     147
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     147
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     148
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     148
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     149
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     149
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     149
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data       ☺     messages

                     149
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     150
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     150
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     151
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     151
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               data              messages
             messages
                     151
start    CRUD

        SAF create

         commit
          message put / commit
                           Recoverable
        SAF update
end
               data               messages
             messages
                     151
start    CRUD

        SAF create

         commit
          message put / commit
                           Recoverable
        SAF update
end
               data
             messages      ☺      messages

                     151
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     152
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     152
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
                data             messages

                     153
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               data              messages
             messages
                     153
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update
end
               data
             messages      ☺     messages

                     153
start    CRUD

        SAF create

         commit
          message put / commit

        SAF update         Duplicated
end
               data
             messages      ☺      messages

                     153
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_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
functional test


rake ..         CRUD


            message put
                        Stub
            assert

            assert


                  169
Async

•
•
• e.g.

                 170
171
[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
[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
1. dispatcher
2. HTTP POST    Rails
3. orders                     assert
4. dispatcher
5.
6. payment                     assert



                        174
async test


rake ..
                 service control
            HTTP
                            CRUD

                            message put
             assert
                                          HTTP
                            CRUD
             assert

                      175
•              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/trunk/ap4r


• ML: http://rubyforge.org/mailman/listinfo/ap4r-user


Your patches are welcome!
Thank you.


                                                               by Kanican
                              188
•   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

Más contenido relacionado

La actualidad más candente

DNS: from manual records to a modern & dynamic approach
DNS: from manual records to a modern & dynamic approachDNS: from manual records to a modern & dynamic approach
DNS: from manual records to a modern & dynamic approach
Scaleway
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Simplilearn
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5
Chef
 
My sql replication advanced techniques presentation
My sql replication advanced techniques presentationMy sql replication advanced techniques presentation
My sql replication advanced techniques presentation
epee
 

La actualidad más candente (20)

Oscon 2011 - ATS
Oscon 2011 - ATSOscon 2011 - ATS
Oscon 2011 - ATS
 
DNS: from manual records to a modern & dynamic approach
DNS: from manual records to a modern & dynamic approachDNS: from manual records to a modern & dynamic approach
DNS: from manual records to a modern & dynamic approach
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
 
OSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspecOSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspec
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
Designing Fault Tolerant Microservices
Designing Fault Tolerant MicroservicesDesigning Fault Tolerant Microservices
Designing Fault Tolerant Microservices
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Common configuration with Data Bags - Fundamentals Webinar Series Part 4Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
What I did in My Internship @ WSO2
What I did in My Internship @ WSO2What I did in My Internship @ WSO2
What I did in My Internship @ WSO2
 
My internship presentation at WSO2
My internship presentation at WSO2My internship presentation at WSO2
My internship presentation at WSO2
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with Chef
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Performance scalability brandonlyon
Performance scalability brandonlyonPerformance scalability brandonlyon
Performance scalability brandonlyon
 
My sql replication advanced techniques presentation
My sql replication advanced techniques presentationMy sql replication advanced techniques presentation
My sql replication advanced techniques presentation
 
HARE 2010 Review
HARE 2010 ReviewHARE 2010 Review
HARE 2010 Review
 
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
London Hashicorp Meetup #8 -  Testing Programmable Infrastructure By Matt LongLondon Hashicorp Meetup #8 -  Testing Programmable Infrastructure By Matt Long
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 

Destacado

Stormの注目の新機能TridentAPI
Stormの注目の新機能TridentAPIStormの注目の新機能TridentAPI
Stormの注目の新機能TridentAPI
AdvancedTechNight
 

Destacado (20)

【テスト】テスト用のアップロード
【テスト】テスト用のアップロード【テスト】テスト用のアップロード
【テスト】テスト用のアップロード
 
Rails5β + herokuで遊んでみた
Rails5β +  herokuで遊んでみたRails5β +  herokuで遊んでみた
Rails5β + herokuで遊んでみた
 
Elixir 社内布教 第一節
Elixir 社内布教 第一節Elixir 社内布教 第一節
Elixir 社内布教 第一節
 
君達はまだAlloyの本当のすごさを知らない
君達はまだAlloyの本当のすごさを知らない君達はまだAlloyの本当のすごさを知らない
君達はまだAlloyの本当のすごさを知らない
 
最適化で身近な◯◯のワクワクを取り戻そう
最適化で身近な◯◯のワクワクを取り戻そう最適化で身近な◯◯のワクワクを取り戻そう
最適化で身近な◯◯のワクワクを取り戻そう
 
Stormの注目の新機能TridentAPI
Stormの注目の新機能TridentAPIStormの注目の新機能TridentAPI
Stormの注目の新機能TridentAPI
 
Beats
BeatsBeats
Beats
 
LT 手作りGit
LT 手作りGitLT 手作りGit
LT 手作りGit
 
本を管理するためのオレオレベストプラクティス
本を管理するためのオレオレベストプラクティス本を管理するためのオレオレベストプラクティス
本を管理するためのオレオレベストプラクティス
 
Ai入門 in prolog
Ai入門 in prologAi入門 in prolog
Ai入門 in prolog
 
BIが可愛い
BIが可愛いBIが可愛い
BIが可愛い
 
最近のTUI(Terminal-based User Interface)事情
最近のTUI(Terminal-based User Interface)事情最近のTUI(Terminal-based User Interface)事情
最近のTUI(Terminal-based User Interface)事情
 
デジタルファブリケーションノススメ
デジタルファブリケーションノススメデジタルファブリケーションノススメ
デジタルファブリケーションノススメ
 
もうすぐ春だしAWSでさくらをやってみた
もうすぐ春だしAWSでさくらをやってみたもうすぐ春だしAWSでさくらをやってみた
もうすぐ春だしAWSでさくらをやってみた
 
[JavaScript][gulp.js] 一緒に楽しよう!gulp.jsのあれこれ
[JavaScript][gulp.js] 一緒に楽しよう!gulp.jsのあれこれ[JavaScript][gulp.js] 一緒に楽しよう!gulp.jsのあれこれ
[JavaScript][gulp.js] 一緒に楽しよう!gulp.jsのあれこれ
 
Llvm Talk 社内LT大会資料
Llvm Talk 社内LT大会資料Llvm Talk 社内LT大会資料
Llvm Talk 社内LT大会資料
 
「自己紹介/家族紹介」のコミュニケーション活動例
「自己紹介/家族紹介」のコミュニケーション活動例「自己紹介/家族紹介」のコミュニケーション活動例
「自己紹介/家族紹介」のコミュニケーション活動例
 
MongoDBアプリの実例
MongoDBアプリの実例MongoDBアプリの実例
MongoDBアプリの実例
 
Java?ruby? そろそろgoで行ってみませんか?
Java?ruby? そろそろgoで行ってみませんか? Java?ruby? そろそろgoで行ってみませんか?
Java?ruby? そろそろgoで行ってみませんか?
 
Fluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNSFluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNS
 

Similar a AP4R on Developers Summit 2008

Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdfCisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
ssusercbaa33
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
Ford AntiTrust
 

Similar a AP4R on Developers Summit 2008 (20)

AP4R on RubyConf2007
AP4R on RubyConf2007AP4R on RubyConf2007
AP4R on RubyConf2007
 
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
 
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdfCisco Wireless LAN Controller Command Reference, Release 7.4.pdf
Cisco Wireless LAN Controller Command Reference, Release 7.4.pdf
 
Rack
RackRack
Rack
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - Deployment
 
MySQL Replication
MySQL ReplicationMySQL Replication
MySQL Replication
 
Ruby on Rails in UbiSunrise
Ruby on Rails in UbiSunriseRuby on Rails in UbiSunrise
Ruby on Rails in UbiSunrise
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
How to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thriveHow to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thrive
 
Deployment with Ruby on Rails
Deployment with Ruby on RailsDeployment with Ruby on Rails
Deployment with Ruby on Rails
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Server side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHPServer side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHP
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
Rails Performance
Rails PerformanceRails Performance
Rails Performance
 
Resin Outperforms NginX
Resin Outperforms NginXResin Outperforms NginX
Resin Outperforms NginX
 
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
pppr - 解決 JavaScript 無法被搜尋引擎正確索引的問題
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

AP4R on Developers Summit 2008

  • 2. 2
  • 4. kiwamu • Ruby 2006 • AP4R • http://d.hatena.ne.jp/kiwamu/ 4
  • 5. shino • ! • ...C 5
  • 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
  • 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
  • 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
  • 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
  • 35. 32
  • 36. Client Server Messaging Server 33
  • 37. Client Server Messaging Servers 34
  • 38. AP4R ? 35
  • 39. 36
  • 40. ? 37
  • 41. 38
  • 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
  • 58. 55
  • 61. • AP4R ×2 • Rails × 4 / AP4R •1 • MySQL 58
  • 63. • • TextMe for Business ( http://textmeforbusiness.com ) • 2007 7 60
  • 65. on SMS AP4R queues acceptance inbound Text processing delivery outbound delivery delivery processing Third Party routing application 62
  • 66. AP4R ? 63
  • 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
  • 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
  • 79. 76
  • 81. 2. 78
  • 82. API SAF 79
  • 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
  • 106. busy URL rewrite heavy 102
  • 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. 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
  • 120. 4. 116
  • 121. API SAF 117
  • 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
  • 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
  • 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
  • 198. API SAF 156
  • 199. 5. 157
  • 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
  • 206. ... • N/W • • 164
  • 207. 2 • Functional • • • Async • • 165
  • 209. 167
  • 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. functional test rake .. CRUD message put Stub assert assert 169
  • 213. 171
  • 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. [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. 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
  • 225. 183
  • 226. ver.0.3.x ☑ ☑ URL ☑ DLQ / SAF □ : Stomp, HTTP 184
  • 227. ver.0.4.x □ OSS Cacti, ZABBIX □ AP4R □ 185
  • 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