Skip to content

Commit

Permalink
support init subscription before enqueue message
Browse files Browse the repository at this point in the history
  • Loading branch information
archfish committed Dec 31, 2019
1 parent 8555284 commit 384ba0c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mqjob/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Mqjob
VERSION = "0.3.9"
VERSION = "0.3.10"
end
3 changes: 2 additions & 1 deletion lib/mqjob/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def from_topic(name, opts={})
# opts
# in publish message in X seconds
# at publish message at specific time
# init_subscription Boolean 是否先初始化一个订阅
def enqueue(msg, opts={})
@mq ||= Plugin.client(topic_opts[:client])

@mq.publish(topic, msg, topic_opts)
@mq.publish(topic, msg, topic_opts.merge(opts))
true
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/plugin/pulsar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ def listen(topic, worker, opts = {})
# opts
# in publish message in X seconds
# at publish message at specific time
# init_subscription Boolean
def publish(topic, msg, opts = {})
create_consumer(topic, opts) if opts[:init_subscription]

base_cmd = ::Pulsar::Proto::BaseCommand.new(
type: ::Pulsar::Proto::BaseCommand::Type::SEND,
send: ::Pulsar::Proto::CommandSend.new(
Expand Down

0 comments on commit 384ba0c

Please sign in to comment.