Ruby SDK有点令人困惑,因为文档有两种订阅方法。现在我不相信其中一个here。
另一种是源代码中所说的预期方法:
# To create a subscription, use the {Topic#subscribe} method.
但是在它指向的代码中,传入的选项会经过一个过滤过程,不允许我指定application
协议。
def endpoint_opts(endpoint,opts = {})
case
when endpoint.is_a?(SQS::Queue)
# auto add a policy to the queue to allow the topic
# to send the queue messages
unless opts[:update_policy] == false
policy = endpoint.policy || SQS::Policy.new
policy.allow(
:principal => :any,
:actions => [:send_message],
:resources => [endpoint]
).where(:source_arn).is(arn)
endpoint.policy = policy
end
{ :protocol => 'sqs', :endpoint => endpoint.arn }
when endpoint =~ /^arn:/
#################################################
THIS IS WHAT FILTERS IT, I get this error
#################################################
raise ArgumentError, "expected a queue ARN" unless
endpoint =~ /^arn:aws(.*?):sqs:/
{ :protocol => "sqs", :endpoint => endpoint }
when endpoint.kind_of?(URI)
{ :protocol => endpoint.scheme,
:endpoint => endpoint.to_s }
when endpoint =~ /^(https?):/
{ :protocol => $1, :endpoint => endpoint }
when endpoint.include?("@")
{ :protocol => opts[:json] ? "email-json" : "email",
:endpoint => endpoint }
when endpoint.gsub(/\D/,'') =~ /\d{11,15}/
{ :protocol => "sms", :endpoint => endpoint.gsub(/\D/,'') }
else
raise ArgumentError, "could not determine protocol for '#{endpoint}'"
end
end
所以...看起来application
协议选项是故意过滤的,或者某人没有写出非常好的测试:)
有没有办法使用AWS SDK订阅从应用程序到主题的端点?我在这里错过了一些大事吗?请帮忙!