From shino at rubyforge.org Mon Sep 3 00:55:28 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 3 Sep 2007 00:55:28 -0400 (EDT) Subject: [ap4r-devel] [290] branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb: rename test method. Message-ID: <20070903045528.0CAD95240E9D@rubyforge.org> Revision: 290 Author: shino Date: 2007-09-03 00:55:27 -0400 (Mon, 03 Sep 2007) Log Message: ----------- rename test method. Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb Modified: branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-08-31 08:22:22 UTC (rev 289) +++ branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-09-03 04:55:27 UTC (rev 290) @@ -10,7 +10,7 @@ # - HTTP session holding support is needed? class AsyncShopTest < Test::Unit::TestCase - def test_http_dispatch + def test_order_to_payment ap4r_helper.stop_dispatchers assert_rows_added(Order, 1) { From shino at rubyforge.org Mon Sep 3 01:09:46 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 3 Sep 2007 01:09:46 -0400 (EDT) Subject: [ap4r-devel] [291] branches/200709_gihyo/async_shop/as_rails/test/async: change helper (service handler) method name Message-ID: <20070903050946.47E625240CA1@rubyforge.org> Revision: 291 Author: shino Date: 2007-09-03 01:09:45 -0400 (Mon, 03 Sep 2007) Log Message: ----------- change helper (service handler) method name Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb Modified: branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb 2007-09-03 04:55:27 UTC (rev 290) +++ branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb 2007-09-03 05:09:45 UTC (rev 291) @@ -6,7 +6,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../config/environment") require "ap4r/service_handler" -ap4r_test_helper = Ap4r::ServiceHandler.new +ap4r_service_handler = Ap4r::ServiceHandler.new # ap4r_test_helper.start_rails_service # at_exit { ap4r_test_helper.stop_rails_service } @@ -24,15 +24,15 @@ self.use_instantiated_fixtures = false # Add more helper methods to be used by all tests here... - cattr_accessor :ap4r_helper + cattr_accessor :ap4r_service - def ap4r_helper - @@ap4r_helper + def ap4r_service + @@ap4r_service end def with_services(&block) - ap4r_helper.with_services(&block) + ap4r_service.with_services(&block) end end -Test::Unit::TestCase.ap4r_helper = ap4r_test_helper +Test::Unit::TestCase.ap4r_service = ap4r_service_handler Modified: branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-09-03 04:55:27 UTC (rev 290) +++ branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-09-03 05:09:45 UTC (rev 291) @@ -11,15 +11,15 @@ class AsyncShopTest < Test::Unit::TestCase def test_order_to_payment - ap4r_helper.stop_dispatchers + ap4r_service.stop_dispatchers assert_rows_added(Order, 1) { do_order } assert_rows_added(Payment, 1) { - ap4r_helper.start_dispatchers - ap4r_helper.wait_all_done + ap4r_service.start_dispatchers + ap4r_service.wait_all_done } end From shino at rubyforge.org Mon Sep 3 03:27:06 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 3 Sep 2007 03:27:06 -0400 (EDT) Subject: [ap4r-devel] [292] branches/200709_gihyo/async_shop/as_rails: refactoring: change a key name, line break, and assert messages Message-ID: <20070903072706.ECA515240FCB@rubyforge.org> Revision: 292 Author: shino Date: 2007-09-03 03:27:05 -0400 (Mon, 03 Sep 2007) Log Message: ----------- refactoring: change a key name, line break, and assert messages Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb branches/200709_gihyo/async_shop/as_rails/test/functional/async_shop_controller_test.rb branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb Modified: branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-09-03 05:09:45 UTC (rev 291) +++ branches/200709_gihyo/async_shop/as_rails/test/async/async_shop_test.rb 2007-09-03 07:27:05 UTC (rev 292) @@ -40,6 +40,7 @@ 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}" + assert_equal rows, rows_after - rows_before, + "table '#{model.table_name}' should count up by #{rows}" end end Modified: branches/200709_gihyo/async_shop/as_rails/test/functional/async_shop_controller_test.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/functional/async_shop_controller_test.rb 2007-09-03 05:09:45 UTC (rev 291) +++ branches/200709_gihyo/async_shop/as_rails/test/functional/async_shop_controller_test.rb 2007-09-03 07:27:05 UTC (rev 292) @@ -22,10 +22,13 @@ assert_redirected_to :action => 'index' messages = @controller.ap4r.queued_messages - assert_equal 1, messages.keys.size, "should have just ONE queued message" + assert_equal 1, messages.keys.size, "should have messages in just ONE queue" assert messages.key?("queue.async_shop.payment"), "queue name is INCORRECT" - assert_match /order_id=\d+/, messages["queue.async_shop.payment"].first[:message], - "parameter order_id should be included" + + 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" end end Modified: branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb 2007-09-03 05:09:45 UTC (rev 291) +++ branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb 2007-09-03 07:27:05 UTC (rev 292) @@ -13,7 +13,7 @@ private def __queue_put(queue_name, message, headers) - queued_messages[queue_name] << {:headers => headers, :message => message} + queued_messages[queue_name] << {:headers => headers, :body => message} end end From kato-k at rubyforge.org Wed Sep 5 23:30:07 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 5 Sep 2007 23:30:07 -0400 (EDT) Subject: [ap4r-devel] [293] trunk/ap4r/lib/ap4r/message_store_ext.rb: Modified: Base64 endode for massage body to avoid PostgreSQL encoding trouble. Message-ID: <20070906033007.8456E5240EBE@rubyforge.org> Revision: 293 Author: kato-k Date: 2007-09-05 23:30:07 -0400 (Wed, 05 Sep 2007) Log Message: ----------- Modified: Base64 endode for massage body to avoid PostgreSQL encoding trouble. Modified Paths: -------------- trunk/ap4r/lib/ap4r/message_store_ext.rb Modified: trunk/ap4r/lib/ap4r/message_store_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-09-03 07:27:05 UTC (rev 292) +++ trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-09-06 03:30:07 UTC (rev 293) @@ -44,6 +44,8 @@ require 'postgres-pr/connection' end + require 'Base64' + class PostgreSQL < Base #:nodoc: TYPE = self.name.split('::').last.downcase @@ -123,7 +125,7 @@ begin inserts.each do |insert| if insert[:queue] - pgsql.query "INSERT INTO #{@queues_table} (id,queue,headers,object) VALUES('#{connection.quote insert[:id]}', '#{connection.quote insert[:queue]}', '#{connection.quote YAML.dump(insert[:headers])}', '#{connection.quote insert[:message]}')" + pgsql.query "INSERT INTO #{@queues_table} (id,queue,headers,object) VALUES('#{connection.quote insert[:id]}', '#{connection.quote insert[:queue]}', '#{connection.quote YAML.dump(insert[:headers])}', '#{connection.quote Base64.encode64(insert[:message])}')" else pgsql.query "REPLACE #{@topics_table} (topic,headers,object) VALUES('#{connection.quote insert[:topic]}','#{connection.quote YAML.dump(insert[:headers])}','#{connection.quote insert[:message]}')" end @@ -176,11 +178,11 @@ message = nil if type == :queue connection.query "SELECT object FROM #{@queues_table} WHERE id='#{id}'" do |result| - message = result[0][0] if result[0] + message = Base64.decode64(result[0][0]) if result[0] end else connection.query "SELECT object FROM #{@topics_table} WHERE topic='#{queue_or_topic}'" do |result| - message = result[0][0] if result[0] + message = Base64.decode64(result[0][0]) if result[0] end end message From kato-k at rubyforge.org Sun Sep 9 22:31:18 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Sun, 9 Sep 2007 22:31:18 -0400 (EDT) Subject: [ap4r-devel] [294] trunk/ap4r/lib/ap4r/message_store_ext.rb: Fixed: incorrect module name. Message-ID: <20070910023118.1FE5A5240BF4@rubyforge.org> Revision: 294 Author: kato-k Date: 2007-09-09 22:31:16 -0400 (Sun, 09 Sep 2007) Log Message: ----------- Fixed: incorrect module name. Modified Paths: -------------- trunk/ap4r/lib/ap4r/message_store_ext.rb Modified: trunk/ap4r/lib/ap4r/message_store_ext.rb =================================================================== --- trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-09-06 03:30:07 UTC (rev 293) +++ trunk/ap4r/lib/ap4r/message_store_ext.rb 2007-09-10 02:31:16 UTC (rev 294) @@ -43,9 +43,9 @@ rescue LoadError require 'postgres-pr/connection' end + + require 'base64' - require 'Base64' - class PostgreSQL < Base #:nodoc: TYPE = self.name.split('::').last.downcase From kato-k at rubyforge.org Tue Sep 11 06:23:15 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Tue, 11 Sep 2007 06:23:15 -0400 (EDT) Subject: [ap4r-devel] [295] trunk: Added SAF recovery function and modified SAF table's column type from :binary to :text. Message-ID: <20070911102315.8887E5240A85@rubyforge.org> Revision: 295 Author: kato-k Date: 2007-09-11 06:23:14 -0400 (Tue, 11 Sep 2007) Log Message: ----------- Added SAF recovery function and modified SAF table's column type from :binary to :text. (If there is a backslash in data for binary type, PostgreSQL warnings occur...) Modified Paths: -------------- trunk/ap4r/lib/ap4r/stored_message.rb trunk/samples/HelloWorld/app/controllers/saf_controller.rb trunk/samples/HelloWorld/app/views/saf/list.rhtml trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb Modified: trunk/ap4r/lib/ap4r/stored_message.rb =================================================================== --- trunk/ap4r/lib/ap4r/stored_message.rb 2007-09-10 02:31:16 UTC (rev 294) +++ trunk/ap4r/lib/ap4r/stored_message.rb 2007-09-11 10:23:14 UTC (rev 295) @@ -5,10 +5,12 @@ begin require 'active_record' require 'uuid' + require 'reliable-msg' rescue LoadError require 'rubygems' require 'activerecord' require 'uuid' + require 'reliable-msg' end module Ap4r @@ -21,8 +23,9 @@ STATUS_STORED = 0 STATUS_FORWARDED = 1 - STATUS_FAILED = -1 - + @@status_value_of = { :unforwarded => STATUS_STORED, + :forwarded => STATUS_FORWARDED } + PHYSICAL = :physical LOGICAL = :logical @@ -40,8 +43,8 @@ s.duplication_check_id = UUID.new s.queue = queue_name s.status = STATUS_STORED - s.object = Marshal::dump(queue_message) - s.headers = Marshal::dump(rm_options) + s.object = YAML.dump(queue_message) + s.headers = YAML.dump(rm_options) end begin @@ -84,5 +87,99 @@ self end + # List the records which have specified status. + # The statuses are :forwarded, :unforwarded and :all. + # :unforwarded means unprocessed or error during forward process. + # + # Only 3 column (id, queue name, created datetime) are displayed as a summary. + def self.find_on(status = :unforwarded) + puts "id, queue name, created datetime" + puts "--------------------------------" + + case status + when :all + results = StoredMessage.find(:all).each do |res| + puts "#{res.id}, #{res.queue}, #{res.created_at}" + end + when :forwarded, :unforwarded + results = StoredMessage.find(:all, :conditions => { :status => @@status_value_of[status] }).each do |res| + puts "#{res.id}, #{res.queue}, #{res.created_at}" + end + else + puts "undefined status: #{status.to_s}." + puts "Usage: Ap4r::StoredMessage.find_on [ :forwarded | :unforwarded | :all ]" + end + return "#{results ? results.size : 0} messages on #{status.to_s} are displayed." + end + + # Update status value. + def self.update_status(id, status) + return "undefined status: #{status}" unless @@status_value_of.keys.include? status + stored_message = StoredMessage.find(id) + + before_status = stored_message.status + after_status = @@status_value_of[status] + + stored_message.status = after_status + stored_message.save! + return "The message (id = #{id}) was updated from #{before_status} to #{after_status}." + end + + # Try to forward the ONE message which status is unforwarded. + # If the message is forwarded successfully, the status will be 1 (:forwarded). + def self.reforward(id) + stored_message = StoredMessage.find(id) + if stored_message.status == @@status_value_of[:forwarded] + return "The message (id = #{id}) was already forwarded." + end + begin + stored_message.forward_and_update_status + rescue + return "The message (id = #{stored_message.id}) was failed to forward." + else + return "The message (id = #{stored_message.id}) was forwarded successfully." + end + end + + # Try to forward all messages which status are unforwarded. + # This method issue commit command to database every transaction_num. + def self.reforward_all(transaction_num = 10) + is_all_succeeded = true + stored_messages = StoredMessage.find(:all, + :conditions => {:status => @@status_value_of[:unforwarded]}) + total_num = stored_messages.size + + 0.step(total_num, transaction_num) do |offset| + target_sms = stored_messages[offset..(offset + transaction_num - 1)] + next if target_sms.empty? + begin + StoredMessage.transaction do + target_sms.each do |target_sm| + target_sm.forward_and_update_status + end + end + rescue Exception => error + puts error.message + puts "The messages were failed to forward: id = #{target_sms.map{|sm| sm.id}.join(',')}" + is_all_succeeded = false + else + puts "The messages were forwarded successfully: id = #{target_sms.map{|sm| sm.id}.join(',')}" + end + end + return is_all_succeeded + end + + def forward_and_update_status + queue_name = self.queue + queue_headers = YAML.load(self.headers) + queue_messages = YAML.load(self.object) + + q = ::ReliableMsg::Queue.new(queue_name, :drb_uri => Ap4r::AsyncHelper::Base::DRUBY_URI) + q.put(queue_messages, queue_headers) + + self.status = STATUS_FORWARDED + self.save! + end + end end Modified: trunk/samples/HelloWorld/app/controllers/saf_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/saf_controller.rb 2007-09-10 02:31:16 UTC (rev 294) +++ trunk/samples/HelloWorld/app/controllers/saf_controller.rb 2007-09-11 10:23:14 UTC (rev 295) @@ -52,19 +52,8 @@ def recovery @stored_message = ::Ap4r::StoredMessage.find(params[:id]) + @stored_message.forward_and_update_status - headers = Marshal::load(@stored_message.headers) - body = Marshal::load(@stored_message.object) - - url_options = {:controller => 'dummy'} # url is overwritten by :target_url in rm_options - async_params = body - rm_options = headers.merge({ :queue => @stored_message.queue}) - - ap4r.async_to(url_options, async_params, rm_options) - - @stored_message.status = 2 # change status value for now, let's destroy if it's unnecessary. - @stored_message.save - redirect_to :action => 'list' end end Modified: trunk/samples/HelloWorld/app/views/saf/list.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/saf/list.rhtml 2007-09-10 02:31:16 UTC (rev 294) +++ trunk/samples/HelloWorld/app/views/saf/list.rhtml 2007-09-11 10:23:14 UTC (rev 295) @@ -16,8 +16,8 @@ <%= stored_message.id %> <%= stored_message.duplication_check_id %> <%= stored_message.queue %> - <%= Marshal::load(stored_message.headers).inspect %> - <%= Marshal::load(stored_message.object).inspect %> + <%= YAML.load(stored_message.headers).inspect %> + <%= YAML.load(stored_message.object).inspect %> <%= stored_message.status %> <%= stored_message.created_at %> <%= stored_message.updated_at %> Modified: trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb =================================================================== --- trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb 2007-09-10 02:31:16 UTC (rev 294) +++ trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb 2007-09-11 10:23:14 UTC (rev 295) @@ -7,8 +7,8 @@ create_table :stored_messages do |t| t.column :duplication_check_id, :string, :null => false t.column :queue, :string, :null => false - t.column :headers, :binary, :null => false - t.column :object, :binary, :null => false + t.column :headers, :text, :null => false + t.column :object, :text, :null => false t.column :status, :integer, :null => false t.column :created_at, :datetime, :null => false t.column :updated_at, :datetime, :null => false From shino at rubyforge.org Thu Sep 13 03:21:10 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 13 Sep 2007 03:21:10 -0400 (EDT) Subject: [ap4r-devel] [296] branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb: change key name :queue_name to :queue in rm headers. Message-ID: <20070913072110.C3A525240F11@rubyforge.org> Revision: 296 Author: shino Date: 2007-09-13 03:21:09 -0400 (Thu, 13 Sep 2007) Log Message: ----------- change key name :queue_name to :queue in rm headers. Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb Modified: branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-11 10:23:14 UTC (rev 295) +++ branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-13 07:21:09 UTC (rev 296) @@ -136,7 +136,7 @@ def __get_queue_name(options, rm_options) if options[:url].kind_of?(Hash) - rm_options[:queue_name] ||= + rm_options[:queue] ||= @@default_queue_prefix.clone.concat(options[:url][:controller].to_s).concat('.').concat(options[:url][:action].to_s) else rm_options[:queue_name] ||= From kato-k at rubyforge.org Thu Sep 13 22:59:13 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 13 Sep 2007 22:59:13 -0400 (EDT) Subject: [ap4r-devel] [297] trunk: Modified type for headers and object column in SAF table. Message-ID: <20070914025913.B5387A970019@rubyforge.org> Revision: 297 Author: kato-k Date: 2007-09-13 22:59:12 -0400 (Thu, 13 Sep 2007) Log Message: ----------- Modified type for headers and object column in SAF table. Generally they use binary type, but use text type for PostgreSQL to avoid warnings. Modified Paths: -------------- trunk/ap4r/lib/ap4r/stored_message.rb trunk/samples/HelloWorld/app/views/saf/list.rhtml trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb Modified: trunk/ap4r/lib/ap4r/stored_message.rb =================================================================== --- trunk/ap4r/lib/ap4r/stored_message.rb 2007-09-13 07:21:09 UTC (rev 296) +++ trunk/ap4r/lib/ap4r/stored_message.rb 2007-09-14 02:59:12 UTC (rev 297) @@ -28,7 +28,25 @@ PHYSICAL = :physical LOGICAL = :logical - + + def dumped_headers + # The warning occurs when putting backslash into binaly type in PostgreSQL. + if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + self.headers + else + Marshal::dump(self.headers) + end + end + + def dumped_object + # The warning occurs when putting backslash into binaly type in PostgreSQL. + if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + self.object + else + Marshal::dump(self.object) + end + end + # Insert queue information, such as queue name and message, for next logic. # # duplication_check_id is generated from UUID and should be unique @@ -43,8 +61,15 @@ s.duplication_check_id = UUID.new s.queue = queue_name s.status = STATUS_STORED - s.object = YAML.dump(queue_message) - s.headers = YAML.dump(rm_options) + + # The warning occurs when putting backslash into binaly type in PostgreSQL. + if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + s.object = YAML.dump(queue_message) + s.headers = YAML.dump(rm_options) + else + s.object = Marshal::dump(queue_message) + s.headers = Marshal::dump(rm_options) + end end begin @@ -90,28 +115,23 @@ # List the records which have specified status. # The statuses are :forwarded, :unforwarded and :all. # :unforwarded means unprocessed or error during forward process. - # - # Only 3 column (id, queue name, created datetime) are displayed as a summary. - def self.find_on(status = :unforwarded) - puts "id, queue name, created datetime" - puts "--------------------------------" - + def self.find_status_of(status = :unforwarded) case status when :all - results = StoredMessage.find(:all).each do |res| - puts "#{res.id}, #{res.queue}, #{res.created_at}" - end + StoredMessage.find(:all) when :forwarded, :unforwarded - results = StoredMessage.find(:all, :conditions => { :status => @@status_value_of[status] }).each do |res| - puts "#{res.id}, #{res.queue}, #{res.created_at}" - end + StoredMessage.find(:all, :conditions => { :status => @@status_value_of[status] }) else - puts "undefined status: #{status.to_s}." + puts "Undefined status: #{status.to_s}." puts "Usage: Ap4r::StoredMessage.find_on [ :forwarded | :unforwarded | :all ]" end - return "#{results ? results.size : 0} messages on #{status.to_s} are displayed." end + # Return id, queue_name and created date time. + def to_summary_string + return "#{self.id}, #{self.queue}, #{self.created_at}" + end + # Update status value. def self.update_status(id, status) return "undefined status: #{status}" unless @@status_value_of.keys.include? status @@ -122,32 +142,26 @@ stored_message.status = after_status stored_message.save! - return "The message (id = #{id}) was updated from #{before_status} to #{after_status}." end # Try to forward the ONE message which status is unforwarded. - # If the message is forwarded successfully, the status will be 1 (:forwarded). + # If the message is forwarded successfully, the status will be "1" that means forwarded. def self.reforward(id) stored_message = StoredMessage.find(id) if stored_message.status == @@status_value_of[:forwarded] - return "The message (id = #{id}) was already forwarded." + raise "The message (id = #{id}) was already forwarded." end - begin - stored_message.forward_and_update_status - rescue - return "The message (id = #{stored_message.id}) was failed to forward." - else - return "The message (id = #{stored_message.id}) was forwarded successfully." - end + stored_message.forward_and_update_status end # Try to forward all messages which status are unforwarded. # This method issue commit command to database every transaction_num. def self.reforward_all(transaction_num = 10) - is_all_succeeded = true + stored_messages = StoredMessage.find(:all, :conditions => {:status => @@status_value_of[:unforwarded]}) total_num = stored_messages.size + failed_num = 0 0.step(total_num, transaction_num) do |offset| target_sms = stored_messages[offset..(offset + transaction_num - 1)] @@ -160,20 +174,24 @@ end rescue Exception => error puts error.message - puts "The messages were failed to forward: id = #{target_sms.map{|sm| sm.id}.join(',')}" - is_all_succeeded = false - else - puts "The messages were forwarded successfully: id = #{target_sms.map{|sm| sm.id}.join(',')}" + failed_num += target_sms.size end end - return is_all_succeeded + return [total_num - failed_num, failed_num] end def forward_and_update_status queue_name = self.queue - queue_headers = YAML.load(self.headers) - queue_messages = YAML.load(self.object) + # The warning occurs when putting backslash into binaly type in PostgreSQL. + if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + queue_headers = YAML.load(self.headers) + queue_messages = YAML.load(self.object) + else + queue_headers = Marshal::load(self.headers) + queue_messages = Marshal::load(self.object) + end + q = ::ReliableMsg::Queue.new(queue_name, :drb_uri => Ap4r::AsyncHelper::Base::DRUBY_URI) q.put(queue_messages, queue_headers) Modified: trunk/samples/HelloWorld/app/views/saf/list.rhtml =================================================================== --- trunk/samples/HelloWorld/app/views/saf/list.rhtml 2007-09-13 07:21:09 UTC (rev 296) +++ trunk/samples/HelloWorld/app/views/saf/list.rhtml 2007-09-14 02:59:12 UTC (rev 297) @@ -16,8 +16,8 @@ <%= stored_message.id %> <%= stored_message.duplication_check_id %> <%= stored_message.queue %> - <%= YAML.load(stored_message.headers).inspect %> - <%= YAML.load(stored_message.object).inspect %> + <%= stored_message.dumped_headers.inspect %> + <%= stored_message.dumped_object.inspect %> <%= stored_message.status %> <%= stored_message.created_at %> <%= stored_message.updated_at %> Modified: trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb =================================================================== --- trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb 2007-09-13 07:21:09 UTC (rev 296) +++ trunk/samples/HelloWorld/db/migrate/001_create_table_for_saf.rb 2007-09-14 02:59:12 UTC (rev 297) @@ -7,8 +7,8 @@ create_table :stored_messages do |t| t.column :duplication_check_id, :string, :null => false t.column :queue, :string, :null => false - t.column :headers, :text, :null => false - t.column :object, :text, :null => false + t.column :headers, :binary, :null => false + t.column :object, :binary, :null => false t.column :status, :integer, :null => false t.column :created_at, :datetime, :null => false t.column :updated_at, :datetime, :null => false From kato-k at rubyforge.org Tue Sep 18 05:06:41 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Tue, 18 Sep 2007 05:06:41 -0400 (EDT) Subject: [ap4r-devel] [298] trunk/ap4r: Added: migration file for SAF table to PostgreSQL. Message-ID: <20070918090641.706425240951@rubyforge.org> Revision: 298 Author: kato-k Date: 2007-09-18 05:06:40 -0400 (Tue, 18 Sep 2007) Log Message: ----------- Added: migration file for SAF table to PostgreSQL. Modified Paths: -------------- trunk/ap4r/Rakefile Added Paths: ----------- trunk/ap4r/lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-09-14 02:59:12 UTC (rev 297) +++ trunk/ap4r/Rakefile 2007-09-18 09:06:40 UTC (rev 298) @@ -8,7 +8,7 @@ # copy rails plugin from sample before gem build FileUtils.mkdir_p('./rails_plugin/ap4r/lib') -FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/') +FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/xxx_create_table_for_saf.rb') FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/init.rb', './rails_plugin/ap4r/') FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/async_helper.rb', './rails_plugin/ap4r/lib/') FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/ap4r_client.rb', './rails_plugin/ap4r/lib/') Added: trunk/ap4r/lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb =================================================================== --- trunk/ap4r/lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb (rev 0) +++ trunk/ap4r/lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb 2007-09-18 09:06:40 UTC (rev 298) @@ -0,0 +1,21 @@ +# Author:: Kiwamu Kato +# Copyright:: Copyright (c) 2006 Future System Consulting Corp. +# Licence:: MIT Licence + +class CreateTableForSaf < ActiveRecord::Migration + def self.up + create_table :stored_messages do |t| + t.column :duplication_check_id, :string, :null => false + t.column :queue, :string, :null => false + t.column :headers, :text, :null => false + t.column :object, :text, :null => false + t.column :status, :integer, :null => false + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + end + + def self.down + drop_table :stored_messages + end +end From shino at rubyforge.org Tue Sep 18 05:10:11 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 18 Sep 2007 05:10:11 -0400 (EDT) Subject: [ap4r-devel] [299] trunk/samples/HelloWorld/vendor/plugins/ap4r/: remove plugin files to update from gihyo branch. Message-ID: <20070918091011.E70425240951@rubyforge.org> Revision: 299 Author: shino Date: 2007-09-18 05:10:11 -0400 (Tue, 18 Sep 2007) Log Message: ----------- remove plugin files to update from gihyo branch. Removed Paths: ------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/ From shino at rubyforge.org Tue Sep 18 05:12:24 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 18 Sep 2007 05:12:24 -0400 (EDT) Subject: [ap4r-devel] [300] trunk/samples/HelloWorld/vendor/plugins/ap4r/: add plugin files from gihyo branch. Message-ID: <20070918091224.C69CD5240956@rubyforge.org> Revision: 300 Author: shino Date: 2007-09-18 05:12:24 -0400 (Tue, 18 Sep 2007) Log Message: ----------- add plugin files from gihyo branch. Added Paths: ----------- trunk/samples/HelloWorld/vendor/plugins/ap4r/ Copied: trunk/samples/HelloWorld/vendor/plugins/ap4r (from rev 296, branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r) From shino at rubyforge.org Tue Sep 18 05:17:42 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 18 Sep 2007 05:17:42 -0400 (EDT) Subject: [ap4r-devel] [301] trunk/ap4r/History.txt: Add a line "test supoprt" Message-ID: <20070918091742.DFE595240951@rubyforge.org> Revision: 301 Author: shino Date: 2007-09-18 05:17:42 -0400 (Tue, 18 Sep 2007) Log Message: ----------- Add a line "test supoprt" Modified Paths: -------------- trunk/ap4r/History.txt Modified: trunk/ap4r/History.txt =================================================================== --- trunk/ap4r/History.txt 2007-09-18 09:12:24 UTC (rev 300) +++ trunk/ap4r/History.txt 2007-09-18 09:17:42 UTC (rev 301) @@ -3,6 +3,7 @@ === 0.3.3 (June ?, 2007) * Added: Support with hoe. * Added: Support PostgreSQL as reliable RDBMS persistence. +* Added: Test supports, stub of queueing and service controls. === 0.3.2 (June 7th, 2007) * Fixed: util/loc.rb doesn't work. From shino at rubyforge.org Wed Sep 19 01:37:26 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 01:37:26 -0400 (EDT) Subject: [ap4r-devel] [302] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb: Fix: bug in treating rm_options. Message-ID: <20070919053726.C5E645240F34@rubyforge.org> Revision: 302 Author: shino Date: 2007-09-19 01:37:24 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix: bug in treating rm_options. :queue and :queue_name are mixedi by error. Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-18 09:17:42 UTC (rev 301) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-19 05:37:24 UTC (rev 302) @@ -139,10 +139,10 @@ rm_options[:queue] ||= @@default_queue_prefix.clone.concat(options[:url][:controller].to_s).concat('.').concat(options[:url][:action].to_s) else - rm_options[:queue_name] ||= + rm_options[:queue] ||= @@default_queue_prefix.clone.chomp(".").concat(URI::parse(options[:url]).path.gsub("/", ".")) end - rm_options[:queue_name] + rm_options[:queue] end end From shino at rubyforge.org Wed Sep 19 01:40:15 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 01:40:15 -0400 (EDT) Subject: [ap4r-devel] [303] branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb: Fix: in rm_options, :queue and :queue_name are mixed in error. Message-ID: <20070919054015.16FED5240F3E@rubyforge.org> Revision: 303 Author: shino Date: 2007-09-19 01:40:14 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix: in rm_options, :queue and :queue_name are mixed in error. Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb Modified: branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-19 05:37:24 UTC (rev 302) +++ branches/200709_gihyo/async_shop/as_rails/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-19 05:40:14 UTC (rev 303) @@ -139,10 +139,10 @@ rm_options[:queue] ||= @@default_queue_prefix.clone.concat(options[:url][:controller].to_s).concat('.').concat(options[:url][:action].to_s) else - rm_options[:queue_name] ||= + rm_options[:queue] ||= @@default_queue_prefix.clone.chomp(".").concat(URI::parse(options[:url]).path.gsub("/", ".")) end - rm_options[:queue_name] + rm_options[:queue] end end From kato-k at rubyforge.org Wed Sep 19 02:19:49 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 19 Sep 2007 02:19:49 -0400 (EDT) Subject: [ap4r-devel] [304] trunk/samples/HelloWorld/Rakefile: Modified: rescue hoe loaderror. Message-ID: <20070919061949.F04185240F30@rubyforge.org> Revision: 304 Author: kato-k Date: 2007-09-19 02:19:49 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Modified: rescue hoe loaderror. Modified Paths: -------------- trunk/samples/HelloWorld/Rakefile Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2007-09-19 05:40:14 UTC (rev 303) +++ trunk/samples/HelloWorld/Rakefile 2007-09-19 06:19:49 UTC (rev 304) @@ -1,80 +1,90 @@ -require 'rubygems' -require 'hoe' +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.join(File.dirname(__FILE__), 'config', 'boot') +require(File.join(File.dirname(__FILE__), 'config', 'boot')) + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + require 'tasks/rails' -VERSION = '0.3.3' # HelloWorld release tasks -------------------------------------------------------- +begin + require 'rubygems' + require 'hoe' -Hoe.new('HelloWorld', VERSION) do |p| - p.author = ["Shunichi Shinohara", "Kiwamu Kato"] - p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") - #p.clean_globs = - p.description = <<-EOF - One of AP4R's sample applications. - EOF - p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} + VERSION = '0.3.3' - #p.extra_deps << - p.name = 'HelloWorld' - p.need_tar = false - p.need_zip = false - #p.rdoc_pattern = - #p.remote_rdoc_dir = - #p.rsync = - p.rubyforge_name = 'ap4r' - #p.spec_extra = - p.summary = 'One of AP4Rs sample applications' - #p.test_globs = 'test/**/*_test.rb' - p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' - p.version = VERSION -end + Hoe.new('HelloWorld', VERSION) do |p| + p.author = ["Shunichi Shinohara", "Kiwamu Kato"] + p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") + #p.clean_globs = + p.description = <<-EOF + One of AP4R's sample applications. + EOF + p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} - -desc 'Create Manifest.txt' -task :create_manifest do - path_list = [] - Find.find('.') do |path| - next unless File.file? path - next if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ - path_list << path + #p.extra_deps << + p.name = 'HelloWorld' + p.need_tar = false + p.need_zip = false + #p.rdoc_pattern = + #p.remote_rdoc_dir = + #p.rsync = + p.rubyforge_name = 'ap4r' + #p.spec_extra = + p.summary = 'One of AP4Rs sample applications' + #p.test_globs = 'test/**/*_test.rb' + p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' + p.version = VERSION end - File.open('Manifest.txt', 'w') do |manifest| - path_list.sort.each do |path| - /.\// =~ path - manifest.puts($~.post_match) + desc 'Create Manifest.txt' + task :create_manifest do + path_list = [] + Find.find('.') do |path| + next unless File.file? path + next if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + path_list << path end + + File.open('Manifest.txt', 'w') do |manifest| + path_list.sort.each do |path| + /.\// =~ path + manifest.puts($~.post_match) + end + end end -end -# Sample release tasks ------------------------------------------------------ -desc 'Create sample HelloWorld tarball' -task :tar do + # Sample release tasks ------------------------------------------------------ + desc 'Create sample HelloWorld tarball' + task :tar do - FileUtils.mkdir_p('../temp/samples/HelloWorld') - FileUtils.rm_rf('../temp/samples/HelloWorld') + FileUtils.mkdir_p('../temp/samples/HelloWorld') + FileUtils.rm_rf('../temp/samples/HelloWorld') - FileUtils.cp_r('.', '../temp/samples/HelloWorld') - Find.find('../temp/samples') do |path| - next unless File.file? path - FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ - end + FileUtils.cp_r('.', '../temp/samples/HelloWorld') + Find.find('../temp/samples') do |path| + next unless File.file? path + FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + end - FileUtils.mkdir_p('./pkg') - FileUtils.cp_r('../temp/samples/HelloWorld','./pkg') - FileUtils.rm_rf('../temp') + FileUtils.mkdir_p('./pkg') + FileUtils.cp_r('../temp/samples/HelloWorld','./pkg') + FileUtils.rm_rf('../temp') - Dir.chdir('./pkg/HelloWorld') - `rake db:migrate` - Dir.chdir('../') + Dir.chdir('./pkg/HelloWorld') + `rake db:migrate` + Dir.chdir('../') - sh "tar czf HelloWorld-#{VERSION}.tar.gz ./HelloWorld/" - Dir.chdir('../') + sh "tar czf HelloWorld-#{VERSION}.tar.gz ./HelloWorld/" + Dir.chdir('../') + end +rescue end From shino at rubyforge.org Wed Sep 19 02:23:57 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 02:23:57 -0400 (EDT) Subject: [ap4r-devel] [305] trunk/ap4r/README.txt: Fix typo, HTTP 'PUT' to 'POST' Message-ID: <20070919062357.3234F5240F30@rubyforge.org> Revision: 305 Author: shino Date: 2007-09-19 02:23:56 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix typo, HTTP 'PUT' to 'POST' Modified Paths: -------------- trunk/ap4r/README.txt Modified: trunk/ap4r/README.txt =================================================================== --- trunk/ap4r/README.txt 2007-09-19 06:19:49 UTC (rev 304) +++ trunk/ap4r/README.txt 2007-09-19 06:23:56 UTC (rev 305) @@ -12,12 +12,12 @@ For more information, please step in AP4R homepage! -== FEATURES/PROBLEMS: +== FEATURES / PROBLEMS TO SOLVE: * Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously. * Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under the favor of reliable-msg. * Load balancing over multiple AP4R processes on single/multiple servers is supported. -* Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP PUT, and more. +* Asynchronous logics are called via various protocols, such as XML-RPC, SOAP, HTTP POST, and more. * Using store and forward function, at-least-once QoS level is provided. == TYPICAL PROCESS FLOW: From kato-k at rubyforge.org Wed Sep 19 03:19:32 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 19 Sep 2007 03:19:32 -0400 (EDT) Subject: [ap4r-devel] [306] trunk/ap4r/Rakefile: Modified: copy logic from sample application's plugin Message-ID: <20070919071932.34EB4A970016@rubyforge.org> Revision: 306 Author: kato-k Date: 2007-09-19 03:19:28 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Modified: copy logic from sample application's plugin Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-09-19 06:23:56 UTC (rev 305) +++ trunk/ap4r/Rakefile 2007-09-19 07:19:28 UTC (rev 306) @@ -9,10 +9,7 @@ # copy rails plugin from sample before gem build FileUtils.mkdir_p('./rails_plugin/ap4r/lib') FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/xxx_create_table_for_saf.rb') -FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/init.rb', './rails_plugin/ap4r/') -FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/async_helper.rb', './rails_plugin/ap4r/lib/') -FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/ap4r_client.rb', './rails_plugin/ap4r/lib/') -FileUtils.cp(HelloWorld + '/vendor/plugins/ap4r/lib/message_builder.rb', './rails_plugin/ap4r/lib/') +FileUtils.cp_r(Dir.glob(HelloWorld + '/vendor/plugins/ap4r/*').reject{|f| f =~ /tmp$|CVS|\.svn/}, './rails_plugin/ap4r') Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| p.author = ["Shunichi Shinohara", "Kiwamu Kato"] From shino at rubyforge.org Wed Sep 19 04:09:49 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 04:09:49 -0400 (EDT) Subject: [ap4r-devel] [307] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb: Fix: Message bodies are not passed to AP4R server Message-ID: <20070919080949.BE958A97000D@rubyforge.org> Revision: 307 Author: shino Date: 2007-09-19 04:09:48 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix: Message bodies are not passed to AP4R server when dispatch_mode is XML-RPC or SOAP. This fix is rather ad-hoc one, and needs refactoring. (See TODO message in diff) Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-19 07:19:28 UTC (rev 306) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-09-19 08:09:48 UTC (rev 307) @@ -108,9 +108,16 @@ message_builder.instance_eval(&block) end queue_name = message_builder.queue_name - queue_message = message_builder.format_message_body queue_headers = message_builder.message_headers + # TODO: proces flow of Converter and MessageBuilder should (probably) be reversed 2007/09/19 by shino + # This branching is ad-hoc fix + if queue_headers[:dispatch_mode] == :HTTP + queue_message = message_builder.format_message_body + else + queue_message = message_builder.message_body + end + if Thread.current[:use_saf] stored_message = ::Ap4r::StoredMessage.store(queue_name, queue_message, queue_headers) From shino at rubyforge.org Wed Sep 19 04:15:53 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 04:15:53 -0400 (EDT) Subject: [ap4r-devel] [308] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb: Fix: typo Message-ID: <20070919081553.AC37A5240F32@rubyforge.org> Revision: 308 Author: shino Date: 2007-09-19 04:15:53 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix: typo Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb 2007-09-19 08:09:48 UTC (rev 307) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/message_builder.rb 2007-09-19 08:15:53 UTC (rev 308) @@ -122,7 +122,7 @@ case @format when :text - return @message_budy.to_s + return @message_body.to_s when :xml return @message_body.to_xml @to_xml_options when :json From shino at rubyforge.org Wed Sep 19 04:31:06 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 04:31:06 -0400 (EDT) Subject: [ap4r-devel] [309] branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb: Misc: remove comment lines. Message-ID: <20070919083107.8DA5F52408DC@rubyforge.org> Revision: 309 Author: shino Date: 2007-09-19 04:30:49 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Misc: remove comment lines. Modified Paths: -------------- branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb Modified: branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb =================================================================== --- branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb 2007-09-19 08:15:53 UTC (rev 308) +++ branches/200709_gihyo/async_shop/as_rails/test/async/ap4r_test_helper.rb 2007-09-19 08:30:49 UTC (rev 309) @@ -7,16 +7,7 @@ require "ap4r/service_handler" ap4r_service_handler = Ap4r::ServiceHandler.new -# ap4r_test_helper.start_rails_service -# at_exit { ap4r_test_helper.stop_rails_service } -# ap4r_test_helper.start_ap4r_service -# at_exit { ap4r_test_helper.stop_ap4r_service } - -# puts -# at_exit { puts } - -# Test::Unit also use at_exit hook, so load at the end require 'test_help' class Test::Unit::TestCase From shino at rubyforge.org Wed Sep 19 04:56:52 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Wed, 19 Sep 2007 04:56:52 -0400 (EDT) Subject: [ap4r-devel] [310] trunk/samples/HelloWorld/app/controllers/sync_hello_controller.rb: Fix: add semi-colon at the end of rake command. Message-ID: <20070919085652.35427524099A@rubyforge.org> Revision: 310 Author: shino Date: 2007-09-19 04:56:51 -0400 (Wed, 19 Sep 2007) Log Message: ----------- Fix: add semi-colon at the end of rake command. I don't know much about this, but otherwise, it hangs up on Mac OS X. Modified Paths: -------------- trunk/samples/HelloWorld/app/controllers/sync_hello_controller.rb Modified: trunk/samples/HelloWorld/app/controllers/sync_hello_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/sync_hello_controller.rb 2007-09-19 08:30:49 UTC (rev 309) +++ trunk/samples/HelloWorld/app/controllers/sync_hello_controller.rb 2007-09-19 08:56:51 UTC (rev 310) @@ -102,7 +102,7 @@ end def create_saf - system("rake db:migrate") + system("rake db:migrate;") render :nothing => true end From kato-k at rubyforge.org Wed Sep 19 06:04:32 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Wed, 19 Sep 2007 06:04:32 -0400 (EDT) Subject: [ap4r-devel] [311] tags/ap4r-0.3.3/: tag 0.3.3 Message-ID: <20070919100432.9365F52407AD@rubyforge.org> Revision: 311 Author: kato-k Date: 2007-09-19 06:04:31 -0400 (Wed, 19 Sep 2007) Log Message: ----------- tag 0.3.3 Added Paths: ----------- tags/ap4r-0.3.3/ Copied: tags/ap4r-0.3.3 (from rev 310, trunk) From shino at rubyforge.org Fri Sep 21 03:58:34 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Fri, 21 Sep 2007 03:58:34 -0400 (EDT) Subject: [ap4r-devel] [312] trunk/ap4r/Rakefile: Refactoring Message-ID: <20070921075834.F2C165240F4F@rubyforge.org> Revision: 312 Author: shino Date: 2007-09-21 03:58:34 -0400 (Fri, 21 Sep 2007) Log Message: ----------- Refactoring - namespace for hoe - copying rails plugin from HelloWorld becomes a task - add the namespace "release" - etc. Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-09-19 10:04:31 UTC (rev 311) +++ trunk/ap4r/Rakefile 2007-09-21 07:58:34 UTC (rev 312) @@ -2,84 +2,92 @@ require 'hoe' require File.join(File.dirname(__FILE__), 'lib/ap4r', 'version') -HelloWorld = '../samples/HelloWorld' +namespace :hoe do + Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| + p.author = ["Shunichi Shinohara", "Kiwamu Kato"] + p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") + #p.clean_globs = + p.description = <<-EOF + Asynchronous Processing for Ruby. + EOF + p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} -# AP4R release tasks -------------------------------------------------------- + p.extra_deps << ['reliable-msg', '=1.1.0'] + p.extra_deps << ['activesupport'] + p.extra_deps << ['mongrel'] + p.extra_deps << ['rake'] + p.extra_deps << ['hoe'] -# copy rails plugin from sample before gem build -FileUtils.mkdir_p('./rails_plugin/ap4r/lib') -FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', './lib/ap4r/xxx_create_table_for_saf.rb') -FileUtils.cp_r(Dir.glob(HelloWorld + '/vendor/plugins/ap4r/*').reject{|f| f =~ /tmp$|CVS|\.svn/}, './rails_plugin/ap4r') + p.name = 'ap4r' + p.need_tar = false + p.need_zip = false + #p.rdoc_pattern = + #p.remote_rdoc_dir = + #p.rsync = + p.rubyforge_name = 'ap4r' + #p.spec_extra = + p.summary = 'Asynchronous Processing for Ruby.' + p.test_globs = 'spec/**/*_spec.rb' + p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' + p.version = Ap4r::VERSION::STRING + end.spec.dependencies.delete_if {|dep| dep.name == "hoe"} -Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| - p.author = ["Shunichi Shinohara", "Kiwamu Kato"] - p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") - #p.clean_globs = - p.description = <<-EOF - Asynchronous Processing for Ruby. - EOF - p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} +end - p.extra_deps << ['reliable-msg', '=1.1.0'] - p.extra_deps << ['activesupport'] - p.extra_deps << ['mongrel'] - p.extra_deps << ['rake'] - p.extra_deps << ['hoe'] +task :pkg => "release:copy_plugin" - p.name = 'ap4r' - p.need_tar = false - p.need_zip = false - #p.rdoc_pattern = - #p.remote_rdoc_dir = - #p.rsync = - p.rubyforge_name = 'ap4r' - #p.spec_extra = - p.summary = 'Asynchronous Processing for Ruby.' - p.test_globs = 'spec/**/*_spec.rb' - p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' - p.version = Ap4r::VERSION::STRING -end.spec.dependencies.delete_if {|dep| dep.name == "hoe"} +# AP4R release tasks -------------------------------------------------------- +HelloWorld = '../samples/HelloWorld' -desc 'Create Manifest.txt' -task :create_manifest do - - path_list = [] - Find.find('.') do |path| - next unless File.file? path - next if path =~ /\.svn|tmp$|CVS|.rb\~/ - path_list << path +namespace :release do + desc "copy rails plugin from sample before gem build" + task :copy_plugin do + FileUtils.rm_rf('./rails_plugin/ap4r') + FileUtils.mkdir_p('./rails_plugin/ap4r/lib') + FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', + './lib/ap4r/xxx_create_table_for_saf.rb') + FileUtils.cp_r(Dir.glob(HelloWorld + '/vendor/plugins/ap4r/*').reject{|f| f =~ /tmp$|CVS|\.svn/}, + './rails_plugin/ap4r') + # TODO: dot files and tilde files are copied 2007/09/20 by shino end - File.open('Manifest.txt', 'w') do |manifest| - path_list.sort.each do |path| - /.\// =~ path - manifest.puts($~.post_match) + desc "Create Manifest.txt" + task :create_manifest => [:copy_plugin] do + path_list = [] + Find.find('.') do |path| + next unless File.file?(path) + next if path =~ /\.svn|tmp$|CVS|\~$/ + path_list << path end + + File.open('Manifest.txt', 'w') do |manifest| + path_list.sort.each do |path| + /.\// =~ path + manifest.puts($~.post_match) + end + end end - -end + # Sample release tasks ------------------------------------------------------ + desc 'Make sample tarball (Now only one sample "HelloWorld").' + task :sample do + FileUtils.mkdir_p('./pkg/samples') + FileUtils.rm_rf('./pkg/samples/HelloWorld') + + FileUtils.cp_r(HelloWorld, './pkg/samples/') + Find.find('./pkg/samples') do |path| + next unless File.file? path + FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~/ + end - -# Sample release tasks ------------------------------------------------------ -desc 'Make samle tarball (Now only HelloWorld sample).' -task :sample do - FileUtils.mkdir_p('./pkg/samples') - FileUtils.rm_rf('./pkg/samples/HelloWorld') - - FileUtils.cp_r(HelloWorld, './pkg/samples/') - Find.find('./pkg/samples') do |path| - next unless File.file? path - FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~/ + Dir.chdir('./pkg/samples/HelloWorld') + `rake db:migrate` + Dir.chdir('../../') + + `tar czf HelloWorld-#{Ap4r::VERSION::STRING}.tar.gz ./samples/HelloWorld/` + Dir.chdir('../') end - - Dir.chdir('./pkg/samples/HelloWorld') - `rake db:migrate` - Dir.chdir('../../') - - `tar czvf HelloWorld-#{Ap4r::VERSION::STRING}.tar.gz ./samples/HelloWorld/` - Dir.chdir('../') end @@ -113,7 +121,7 @@ # AP4R misc tools ---------------------------------------------------------------- desc "display code statistics" -task :stats do +task :stats => "release:copy_plugin" do require 'rubygems' require 'active_support' require 'code_statistics' From shino at rubyforge.org Thu Sep 27 00:12:05 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 00:12:05 -0400 (EDT) Subject: [ap4r-devel] [313] trunk/ap4r/Rakefile: remove ./doc/ from the create_manifest task Message-ID: <20070927041205.68C9B5240DC6@rubyforge.org> Revision: 313 Author: shino Date: 2007-09-27 00:12:04 -0400 (Thu, 27 Sep 2007) Log Message: ----------- remove ./doc/ from the create_manifest task Modified Paths: -------------- trunk/ap4r/Rakefile Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2007-09-21 07:58:34 UTC (rev 312) +++ trunk/ap4r/Rakefile 2007-09-27 04:12:04 UTC (rev 313) @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'lib/ap4r', 'version') namespace :hoe do - Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| + hoe = Hoe.new('ap4r', Ap4r::VERSION::STRING) do |p| p.author = ["Shunichi Shinohara", "Kiwamu Kato"] p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") #p.clean_globs = @@ -21,7 +21,8 @@ p.name = 'ap4r' p.need_tar = false p.need_zip = false - #p.rdoc_pattern = + p.rdoc_pattern = /^(lib|bin|ext|rails_plugin)|txt$/ + #p.remote_rdoc_dir = #p.rsync = p.rubyforge_name = 'ap4r' @@ -30,10 +31,10 @@ p.test_globs = 'spec/**/*_spec.rb' p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' p.version = Ap4r::VERSION::STRING - end.spec.dependencies.delete_if {|dep| dep.name == "hoe"} + end + hoe.spec.dependencies.delete_if {|dep| dep.name == "hoe"} end - task :pkg => "release:copy_plugin" # AP4R release tasks -------------------------------------------------------- @@ -43,6 +44,7 @@ namespace :release do desc "copy rails plugin from sample before gem build" task :copy_plugin do + # TODO: Should use file task ? 2007/09/27 by shino FileUtils.rm_rf('./rails_plugin/ap4r') FileUtils.mkdir_p('./rails_plugin/ap4r/lib') FileUtils.cp(HelloWorld + '/db/migrate/001_create_table_for_saf.rb', @@ -57,6 +59,7 @@ path_list = [] Find.find('.') do |path| next unless File.file?(path) + next if path =~ /^\.\/doc\// next if path =~ /\.svn|tmp$|CVS|\~$/ path_list << path end From shino at rubyforge.org Thu Sep 27 00:12:19 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 00:12:19 -0400 (EDT) Subject: [ap4r-devel] [314] trunk/ap4r/Manifest.txt: update manifest Message-ID: <20070927041219.D6C565240DC6@rubyforge.org> Revision: 314 Author: shino Date: 2007-09-27 00:12:19 -0400 (Thu, 27 Sep 2007) Log Message: ----------- update manifest Modified Paths: -------------- trunk/ap4r/Manifest.txt Modified: trunk/ap4r/Manifest.txt =================================================================== --- trunk/ap4r/Manifest.txt 2007-09-27 04:12:04 UTC (rev 313) +++ trunk/ap4r/Manifest.txt 2007-09-27 04:12:19 UTC (rev 314) @@ -9,14 +9,15 @@ config/queues.cfg config/queues_disk.cfg config/queues_mysql.cfg +config/queues_pgsql.cfg lib/ap4r.rb -lib/ap4r/001_create_table_for_saf.rb lib/ap4r/carrier.rb lib/ap4r/dispatcher.rb lib/ap4r/message_store_ext.rb lib/ap4r/mongrel.rb lib/ap4r/mongrel_ap4r.rb lib/ap4r/multi_queue.rb +lib/ap4r/postgresql.sql lib/ap4r/queue_manager_ext.rb lib/ap4r/queue_manager_ext_debug.rb lib/ap4r/retention_history.rb @@ -30,13 +31,16 @@ lib/ap4r/util/irm.rb lib/ap4r/util/queue_client.rb lib/ap4r/version.rb +lib/ap4r/xxx_create_table_for_saf.rb +lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb rails_plugin/ap4r/init.rb +rails_plugin/ap4r/lib/ap4r/queue_put_stub.rb +rails_plugin/ap4r/lib/ap4r/service_handler.rb rails_plugin/ap4r/lib/ap4r_client.rb rails_plugin/ap4r/lib/async_helper.rb rails_plugin/ap4r/lib/message_builder.rb +rails_plugin/ap4r/tasks/ap4r.rake script/irm -script/loop.cmd -script/loop.rb script/mongrel_ap4r script/start script/stop From shino at rubyforge.org Thu Sep 27 02:41:00 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:41:00 -0400 (EDT) Subject: [ap4r-devel] [315] trunk/samples/HelloWorld/: change svn:ignore Message-ID: <20070927064100.F17C85240E19@rubyforge.org> Revision: 315 Author: shino Date: 2007-09-27 02:40:59 -0400 (Thu, 27 Sep 2007) Log Message: ----------- change svn:ignore Property Changed: ---------------- trunk/samples/HelloWorld/ Property changes on: trunk/samples/HelloWorld ___________________________________________________________________ Name: svn:ignore + uuid.state pkg pkg/* From shino at rubyforge.org Thu Sep 27 02:41:19 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:41:19 -0400 (EDT) Subject: [ap4r-devel] [316] trunk/samples/HelloWorld: change svn:ignore Message-ID: <20070927064119.E048C5240E1F@rubyforge.org> Revision: 316 Author: shino Date: 2007-09-27 02:41:19 -0400 (Thu, 27 Sep 2007) Log Message: ----------- change svn:ignore Property Changed: ---------------- trunk/samples/HelloWorld/config/ trunk/samples/HelloWorld/db/ trunk/samples/HelloWorld/doc/ trunk/samples/HelloWorld/log/ Property changes on: trunk/samples/HelloWorld/config ___________________________________________________________________ Name: svn:ignore + ap4r.yml Property changes on: trunk/samples/HelloWorld/db ___________________________________________________________________ Name: svn:ignore + *.db schema.rb Property changes on: trunk/samples/HelloWorld/doc ___________________________________________________________________ Name: svn:ignore + app plugins rails Property changes on: trunk/samples/HelloWorld/log ___________________________________________________________________ Name: svn:ignore + *.log From shino at rubyforge.org Thu Sep 27 02:41:52 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:41:52 -0400 (EDT) Subject: [ap4r-devel] [317] trunk/samples/HelloWorld/README: delete default README file create by rails command Message-ID: <20070927064154.E99FC5240E25@rubyforge.org> Revision: 317 Author: shino Date: 2007-09-27 02:41:51 -0400 (Thu, 27 Sep 2007) Log Message: ----------- delete default README file create by rails command Removed Paths: ------------- trunk/samples/HelloWorld/README Deleted: trunk/samples/HelloWorld/README =================================================================== --- trunk/samples/HelloWorld/README 2007-09-27 06:41:19 UTC (rev 316) +++ trunk/samples/HelloWorld/README 2007-09-27 06:41:51 UTC (rev 317) @@ -1,182 +0,0 @@ -== Welcome to Rails - -Rails is a web-application and persistence framework that includes everything -needed to create database-backed web-applications according to the -Model-View-Control pattern of separation. This pattern splits the view (also -called the presentation) into "dumb" templates that are primarily responsible -for inserting pre-built data in between HTML tags. The model contains the -"smart" domain objects (such as Account, Product, Person, Post) that holds all -the business logic and knows how to persist themselves to a database. The -controller handles the incoming requests (such as Save New Account, Update -Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting started - -1. At the command prompt, start a new rails application using the rails command - and your application name. Ex: rails myapp - (If you've downloaded rails in a complete tgz or zip, this step is already done) -2. Change directory into myapp and start the web server: script/server (run with --help for options) -3. Go to http://localhost:3000/ and get "Welcome aboard: You?re riding the Rails!" -4. Follow the guidelines to start developing your application - - -== Web Servers - -By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise -Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server, -Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures -that you can always get up and running quickly. - -Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is -suitable for development and deployment of Rails applications. If you have Ruby Gems installed, -getting up and running with mongrel is as easy as: gem install mongrel. -More info at: http://mongrel.rubyforge.org - -If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than -Mongrel and WEBrick and also suited for production use, but requires additional -installation and currently only works well on OS X/Unix (Windows users are encouraged -to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from -http://www.lighttpd.net. - -And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby -web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not -for production. - -But of course its also possible to run Rails on any platform that supports FCGI. -Apache, LiteSpeed, IIS are just a few. For more information on FCGI, -please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI - - -== Debugging Rails - -Have "tail -f" commands running on the server.log and development.log. Rails will -automatically display debugging and runtime information to these files. Debugging -info will also be shown in the browser on requests from 127.0.0.1. - - -== Breakpoints - -Breakpoint support is available through the script/breakpointer client. This -means that you can break out of execution at any point in the code, investigate -and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - breakpoint "Breaking out from the list" - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the breakpointer window. Here you can do things like: - -Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you press CTRL-D - - -== Console - -You can interact with the domain model by starting the console through script/console. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like script/console production. - -To reload your controllers and models after launching the console run reload! - -To reload your controllers and models after launching the console run reload! - - - -== Description of contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from ApplicationController - which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby - syntax. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the common - header/footer method of wrapping views. In your views, define a layout using the - layout :default and create a file named default.rhtml. Inside default.rhtml, - call <% yield %> to render the view using this layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are generated - for you automatically when using script/generate for controllers. Helpers can be used to - wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -components - Self-contained mini-applications that can bundle together controllers, models, and views. - -db - Contains the database schema in schema.rb. db/migrate contains all - the sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when generated - using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. This should be - set as the DOCUMENT_ROOT of your web server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - This directory is in the load path. From shino at rubyforge.org Thu Sep 27 02:43:39 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:43:39 -0400 (EDT) Subject: [ap4r-devel] [318] trunk/samples/HelloWorld/public/: modify svn:ignore Message-ID: <20070927064339.6931A5240E07@rubyforge.org> Revision: 318 Author: shino Date: 2007-09-27 02:43:39 -0400 (Thu, 27 Sep 2007) Log Message: ----------- modify svn:ignore Property Changed: ---------------- trunk/samples/HelloWorld/public/ Property changes on: trunk/samples/HelloWorld/public ___________________________________________________________________ Name: svn:ignore + HelloWorld.txt From shino at rubyforge.org Thu Sep 27 02:44:36 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:44:36 -0400 (EDT) Subject: [ap4r-devel] [319] trunk/samples/HelloWorld/README.txt: fill FIXMEs Message-ID: <20070927064436.E14215240E1C@rubyforge.org> Revision: 319 Author: shino Date: 2007-09-27 02:44:36 -0400 (Thu, 27 Sep 2007) Log Message: ----------- fill FIXMEs Modified Paths: -------------- trunk/samples/HelloWorld/README.txt Modified: trunk/samples/HelloWorld/README.txt =================================================================== --- trunk/samples/HelloWorld/README.txt 2007-09-27 06:43:39 UTC (rev 318) +++ trunk/samples/HelloWorld/README.txt 2007-09-27 06:44:36 UTC (rev 319) @@ -1,32 +1,36 @@ HelloWorld - by FIX (your name) - FIX (url) + by AP4R + http://ap4r.rubyforge.org/wiki/wiki.pl == DESCRIPTION: - -FIX (describe your package) +A sample application which utilize AP4R (Asynchronous Processing for Ruby). + == FEATURES/PROBLEMS: - -* FIX (list of features or problems) +* SAF support +* Testing suport +* etc... + == SYNOPSIS: - FIX (code sample of usage) +Please refer rdoc http://ap4r.rubyforge.org/doc/ . == REQUIREMENTS: -* FIX (list of requirements) +* Reliable Messaging(reliable-msg) +* DRb, UUID +* Rails == INSTALL: -* FIX (sudo gem install, anything else) +* Untargz. == LICENSE: (The MIT License) -Copyright (c) 2007 FIX +Copyright (c) 2007 Future Architect Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From shino at rubyforge.org Thu Sep 27 02:46:51 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:46:51 -0400 (EDT) Subject: [ap4r-devel] [320] trunk/samples/HelloWorld/Rakefile: Add namespaces, hoe and release. Message-ID: <20070927064651.572C65240E1C@rubyforge.org> Revision: 320 Author: shino Date: 2007-09-27 02:46:50 -0400 (Thu, 27 Sep 2007) Log Message: ----------- Add namespaces, hoe and release. Refactor release:tar task to use Pathname mainly. Delete stats task because it's included by rails default (probably). Modified Paths: -------------- trunk/samples/HelloWorld/Rakefile Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2007-09-27 06:44:36 UTC (rev 319) +++ trunk/samples/HelloWorld/Rakefile 2007-09-27 06:46:50 UTC (rev 320) @@ -3,50 +3,55 @@ require(File.join(File.dirname(__FILE__), 'config', 'boot')) +require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' +require 'active_support' # HelloWorld release tasks -------------------------------------------------------- begin - require 'rubygems' - require 'hoe' + namespace :hoe do + require 'hoe' - VERSION = '0.3.3' + AP4R_VERSION = '0.3.3' - Hoe.new('HelloWorld', VERSION) do |p| - p.author = ["Shunichi Shinohara", "Kiwamu Kato"] - p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") - #p.clean_globs = - p.description = <<-EOF - One of AP4R's sample applications. - EOF - p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} + Hoe.new('HelloWorld', AP4R_VERSION) do |p| + p.author = ["Shunichi Shinohara", "Kiwamu Kato"] + p.changes = p.paragraphs_of('History.txt', 1..2).join("\n\n") + #p.clean_globs = + p.description = "One of AP4R's sample applications." + p.email = %q{shinohara.shunichi at future.co.jp, kato.kiwamu at future.co.jp} - #p.extra_deps << - p.name = 'HelloWorld' - p.need_tar = false - p.need_zip = false - #p.rdoc_pattern = - #p.remote_rdoc_dir = - #p.rsync = - p.rubyforge_name = 'ap4r' - #p.spec_extra = - p.summary = 'One of AP4Rs sample applications' - #p.test_globs = 'test/**/*_test.rb' - p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' - p.version = VERSION + #p.extra_deps << + p.name = 'HelloWorld' + p.need_tar = false + p.need_zip = false + #p.rdoc_pattern = + #p.remote_rdoc_dir = + #p.rsync = + p.rubyforge_name = 'ap4r' + #p.spec_extra = + p.summary = 'One of AP4Rs sample applications' + #p.test_globs = 'test/**/*_test.rb' + p.url = 'http://ap4r.rubyforge.org/wiki/wiki.pl?HomePage' + p.version = AP4R_VERSION + end end +rescue +end +namespace :release do desc 'Create Manifest.txt' task :create_manifest do path_list = [] Find.find('.') do |path| next unless File.file? path - next if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + next if path =~ /^\.\/(doc|tmp|pkg)\// + next if path =~ /\.svn|CVS|\~$|.log$|.pid$|.db$|uuid.state$/ path_list << path end @@ -60,46 +65,30 @@ # Sample release tasks ------------------------------------------------------ - desc 'Create sample HelloWorld tarball' + desc 'Create HelloWorld tarball' task :tar do + pkg_dir = Pathname.pwd + "./pkg" + hw_dir = pkg_dir + "HelloWorld" + hw_dir.rmtree if hw_dir.exist? + hw_dir.mkpath - FileUtils.mkdir_p('../temp/samples/HelloWorld') - FileUtils.rm_rf('../temp/samples/HelloWorld') + Pathname.pwd.each_entry do |p| + next if p.to_s =~ /^\.|pkg|tmp|doc/ + FileUtils.cp_r(p.to_s, hw_dir.to_s) + end - FileUtils.cp_r('.', '../temp/samples/HelloWorld') - Find.find('../temp/samples') do |path| - next unless File.file? path - FileUtils.rm_rf(path) if path =~ /\.svn|tmp$|CVS|.rb\~|.log|.pid/ + hw_dir.find do |path| + next unless path.to_str =~ /\.svn|CVS|\~$|\.log$|\.pid$|uuid.state$/ + path.rmtree end - FileUtils.mkdir_p('./pkg') - FileUtils.cp_r('../temp/samples/HelloWorld','./pkg') - FileUtils.rm_rf('../temp') + Dir.chdir "./pkg" do + Dir.chdir "./HelloWorld" do + sh "touch log/development.log" + sh "rake db:migrate" + end + sh "tar -czf HelloWorld-#{AP4R_VERSION}.tar.gz ./HelloWorld/" + end - Dir.chdir('./pkg/HelloWorld') - `rake db:migrate` - Dir.chdir('../') - - sh "tar czf HelloWorld-#{VERSION}.tar.gz ./HelloWorld/" - Dir.chdir('../') end - -rescue end - - -# misc tools ---------------------------------------------------------------- - -desc "display code statistics" -task :stats do - require 'rubygems' - require 'active_support' - require 'code_statistics' - CodeStatistics::TEST_TYPES.concat(["Local specs"]) - CodeStatistics.new( - ["Core Sources", "lib"], - ["Rails plugin", "rails_plugin"], - ["Scripts", "script"], - ["Local specs", "spec/local"] - ).to_s -end From shino at rubyforge.org Thu Sep 27 02:47:48 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 02:47:48 -0400 (EDT) Subject: [ap4r-devel] [321] trunk/samples/HelloWorld/Manifest.txt: update Message-ID: <20070927064748.D17165240E21@rubyforge.org> Revision: 321 Author: shino Date: 2007-09-27 02:47:47 -0400 (Thu, 27 Sep 2007) Log Message: ----------- update Modified Paths: -------------- trunk/samples/HelloWorld/Manifest.txt Modified: trunk/samples/HelloWorld/Manifest.txt =================================================================== --- trunk/samples/HelloWorld/Manifest.txt 2007-09-27 06:46:50 UTC (rev 320) +++ trunk/samples/HelloWorld/Manifest.txt 2007-09-27 06:47:47 UTC (rev 321) @@ -1,6 +1,5 @@ History.txt Manifest.txt -README README.txt Rakefile app/apis/async_world_api.rb @@ -35,6 +34,7 @@ app/views/shop/account.rhtml app/views/shop/order.rhtml app/views/sync_hello/index.rhtml +config/ap4r.yml config/ap4r.yml.sample config/boot.rb config/database.yml @@ -44,17 +44,17 @@ config/environments/test.rb config/mongrel_cluster.yml config/routes.rb -db/hello_world_development.db -db/hello_world_production.db db/migrate/001_create_table_for_saf.rb db/schema.rb public/.htaccess public/404.html public/500.html +public/HelloWorld.txt public/dispatch.cgi public/dispatch.fcgi public/dispatch.rb public/favicon.ico +public/images/ap4r_logo.png public/images/rails.png public/javascripts/application.js public/javascripts/controls.js @@ -79,14 +79,13 @@ script/server test/async/ap4r_test_helper.rb test/async/hello_world_stories_test.rb -test/functional/async_shop_controller_test.rb -test/functional/msg_retention_controller_test.rb -test/functional/shop_controller_test.rb test/integration/ap4r_queue_stub.rb test/integration/hello_rails_integration_with_ap4r_test.rb test/test_helper.rb -tmp/sessions/hoge.txt vendor/plugins/ap4r/init.rb +vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb +vendor/plugins/ap4r/lib/ap4r/service_handler.rb vendor/plugins/ap4r/lib/ap4r_client.rb vendor/plugins/ap4r/lib/async_helper.rb vendor/plugins/ap4r/lib/message_builder.rb +vendor/plugins/ap4r/tasks/ap4r.rake From shino at rubyforge.org Thu Sep 27 03:16:38 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Thu, 27 Sep 2007 03:16:38 -0400 (EDT) Subject: [ap4r-devel] [322] trunk/samples/HelloWorld/Rakefile: Add stats configuration task for RSpec Message-ID: <20070927071638.73F13A970008@rubyforge.org> Revision: 322 Author: shino Date: 2007-09-27 03:16:37 -0400 (Thu, 27 Sep 2007) Log Message: ----------- Add stats configuration task for RSpec Modified Paths: -------------- trunk/samples/HelloWorld/Rakefile Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2007-09-27 06:47:47 UTC (rev 321) +++ trunk/samples/HelloWorld/Rakefile 2007-09-27 07:16:37 UTC (rev 322) @@ -92,3 +92,17 @@ end end + +namespace :spec do + task :stats_setup do + require "code_statistics" + %w(controllers helpers models views).map{ |flavor| + ["#{flavor.capitalize} specs", "#{RAILS_ROOT}/spec/#{flavor}"] + }.select{ |name, dir| File.directory?(dir) }.each { |name, dir| + STATS_DIRECTORIES << [name, dir] + CodeStatistics::TEST_TYPES << name + } + end +end + +task :stats => "spec:stats_setup" From shino at rubyforge.org Fri Sep 28 00:07:24 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Fri, 28 Sep 2007 00:07:24 -0400 (EDT) Subject: [ap4r-devel] [323] trunk/samples/HelloWorld: Remove release:tar task. Message-ID: <20070928040725.6BEEC5240E51@rubyforge.org> Revision: 323 Author: shino Date: 2007-09-28 00:07:20 -0400 (Fri, 28 Sep 2007) Log Message: ----------- Remove release:tar task. Because the default "package" task from Hoe is almost the same one. Slight difference is packaged file prefix is tgz rather than tar.gz. Need to fix wiki or to wrap the task to rename the file. Modified Paths: -------------- trunk/samples/HelloWorld/Manifest.txt trunk/samples/HelloWorld/Rakefile Modified: trunk/samples/HelloWorld/Manifest.txt =================================================================== --- trunk/samples/HelloWorld/Manifest.txt 2007-09-27 07:16:37 UTC (rev 322) +++ trunk/samples/HelloWorld/Manifest.txt 2007-09-28 04:07:20 UTC (rev 323) @@ -2,7 +2,10 @@ Manifest.txt README.txt Rakefile +app +app/apis app/apis/async_world_api.rb +app/controllers app/controllers/application.rb app/controllers/async_shop_controller.rb app/controllers/async_world_controller.rb @@ -10,6 +13,7 @@ app/controllers/saf_controller.rb app/controllers/shop_controller.rb app/controllers/sync_hello_controller.rb +app/helpers app/helpers/application_helper.rb app/helpers/async_shop_helper.rb app/helpers/async_world_helper.rb @@ -17,35 +21,53 @@ app/helpers/saf_helper.rb app/helpers/shop_helper.rb app/helpers/sync_hello_helper.rb +app/models app/models/ap4r_class.rb app/models/ap4r_group.rb app/models/world_request.rb +app/views +app/views/async_shop +app/views/async_world app/views/async_world/execute.rhtml +app/views/layouts app/views/layouts/application.rhtml app/views/layouts/saf.rhtml +app/views/msg_retention app/views/msg_retention/load2replace_by_js.rhtml app/views/msg_retention/retention.rhtml app/views/msg_retention/status_img.rhtml +app/views/saf app/views/saf/_form.rhtml app/views/saf/edit.rhtml app/views/saf/list.rhtml app/views/saf/new.rhtml app/views/saf/show.rhtml +app/views/shop app/views/shop/account.rhtml app/views/shop/order.rhtml +app/views/sync_hello app/views/sync_hello/index.rhtml +components +config config/ap4r.yml config/ap4r.yml.sample config/boot.rb config/database.yml config/environment.rb +config/environments config/environments/development.rb config/environments/production.rb config/environments/test.rb config/mongrel_cluster.yml config/routes.rb +db +db/migrate db/migrate/001_create_table_for_saf.rb -db/schema.rb +doc +lib +lib/tasks +log +public public/.htaccess public/404.html public/500.html @@ -54,8 +76,10 @@ public/dispatch.fcgi public/dispatch.rb public/favicon.ico +public/images public/images/ap4r_logo.png public/images/rails.png +public/javascripts public/javascripts/application.js public/javascripts/controls.js public/javascripts/dragdrop.js @@ -63,29 +87,49 @@ public/javascripts/prototype.js public/public_original.html public/robots.txt +public/stylesheets public/stylesheets/scaffold.css +script script/about script/breakpointer script/console script/destroy script/generate +script/performance script/performance/benchmarker script/performance/profiler script/plugin +script/process script/process/inspector script/process/reaper script/process/spawner script/runner script/server +test +test/async test/async/ap4r_test_helper.rb test/async/hello_world_stories_test.rb +test/fixtures +test/functional +test/integration test/integration/ap4r_queue_stub.rb test/integration/hello_rails_integration_with_ap4r_test.rb +test/mocks +test/mocks/development +test/mocks/test test/test_helper.rb +test/unit +tmp +vendor +vendor/plugins +vendor/plugins/ap4r vendor/plugins/ap4r/init.rb +vendor/plugins/ap4r/lib +vendor/plugins/ap4r/lib/ap4r vendor/plugins/ap4r/lib/ap4r/queue_put_stub.rb vendor/plugins/ap4r/lib/ap4r/service_handler.rb vendor/plugins/ap4r/lib/ap4r_client.rb vendor/plugins/ap4r/lib/async_helper.rb vendor/plugins/ap4r/lib/message_builder.rb +vendor/plugins/ap4r/tasks vendor/plugins/ap4r/tasks/ap4r.rake Modified: trunk/samples/HelloWorld/Rakefile =================================================================== --- trunk/samples/HelloWorld/Rakefile 2007-09-27 07:16:37 UTC (rev 322) +++ trunk/samples/HelloWorld/Rakefile 2007-09-28 04:07:20 UTC (rev 323) @@ -28,7 +28,7 @@ #p.extra_deps << p.name = 'HelloWorld' - p.need_tar = false + p.need_tar = true p.need_zip = false #p.rdoc_pattern = #p.remote_rdoc_dir = @@ -49,48 +49,18 @@ task :create_manifest do path_list = [] Find.find('.') do |path| - next unless File.file? path - next if path =~ /^\.\/(doc|tmp|pkg)\// - next if path =~ /\.svn|CVS|\~$|.log$|.pid$|.db$|uuid.state$/ - path_list << path + next if path =~ /^\.\/?$|doc\/|tmp\/|pkg/ + next if path =~ /\.svn|CVS|\~$|\.log$|\.pid$|\.db$|uuid.state$|schema.rb$/ + path_list << path[2..-1] end File.open('Manifest.txt', 'w') do |manifest| path_list.sort.each do |path| - /.\// =~ path - manifest.puts($~.post_match) + manifest.puts(path) end end end - - # Sample release tasks ------------------------------------------------------ - desc 'Create HelloWorld tarball' - task :tar do - pkg_dir = Pathname.pwd + "./pkg" - hw_dir = pkg_dir + "HelloWorld" - hw_dir.rmtree if hw_dir.exist? - hw_dir.mkpath - - Pathname.pwd.each_entry do |p| - next if p.to_s =~ /^\.|pkg|tmp|doc/ - FileUtils.cp_r(p.to_s, hw_dir.to_s) - end - - hw_dir.find do |path| - next unless path.to_str =~ /\.svn|CVS|\~$|\.log$|\.pid$|uuid.state$/ - path.rmtree - end - - Dir.chdir "./pkg" do - Dir.chdir "./HelloWorld" do - sh "touch log/development.log" - sh "rake db:migrate" - end - sh "tar -czf HelloWorld-#{AP4R_VERSION}.tar.gz ./HelloWorld/" - end - - end end namespace :spec do