Commit 5969e048 authored by Marcel Hoppe's avatar Marcel Hoppe

add manual ack and drop support

parent bb82f689
......@@ -7,17 +7,18 @@
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="rbenv: 2.6.3" jdkType="RUBY_SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activestorage (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailbox (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actiontext (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activestorage (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="amq-protocol (v2.3.0, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="arel (v9.0.0, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.2, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bunny (v2.14.2, rbenv: 2.6.3) [gem]" level="application" />
......@@ -41,7 +42,7 @@
<orderEntry type="library" scope="PROVIDED" name="rails (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.4, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v5.2.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v6.0.0.rc1, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v12.3.2, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets (v3.7.2, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets-rails (v3.2.1, rbenv: 2.6.3) [gem]" level="application" />
......@@ -51,5 +52,6 @@
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.5, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.0, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.3, rbenv: 2.6.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.1.6, rbenv: 2.6.3) [gem]" level="application" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -52,8 +52,14 @@ module ActiveBunny
(method_list.map(&:to_sym) - queues.keys).each do |m|
queues[m] = channel(name).queue("#{Rails.application.class.name.deconstantize}.#{simple_name}.#{m}", durable: true, auto_delete: true)
queues[m].bind("#{simple_name}.#{m}")
queues[m].subscribe do |delivery_info, properties, payload|
name.constantize.new.send(m, payload)
queues[m].subscribe(manual_ack: true) do |delivery_info, properties, payload|
obj = name.constantize.new
obj.send(m, payload)
if obj.send(:ack?)
self.channel(name).ack(delivery_info.delivery_tag, false)
else
self.channel(name).nack(delivery_info.delivery_tag, false, obj.send(:requeue?))
end
end
end
end
......
......@@ -6,5 +6,23 @@ module ActiveBunny
extend ActiveSupport::DescendantsTracker
extend ::ActiveBunny::Basics
def drop
self.nack = true
self.drop = true
end
def failure
self.nack = true
end
alias error failure
alias nack failure
def ack?
not self.nack
end
def requeue?
not self.drop
end
end
end
\ No newline at end of file
class UserPublisher < ActiveBunny::Publisher
create_model_hooks except: [:after_update]
def test
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment