sns icon indicating copy to clipboard operation
sns copied to clipboard

Subscriptions with SQS protocol don't work in accordance with AWS API spec.

Open mvmn opened this issue 7 years ago • 11 comments

When making subscription from SNS to SQS (protocol='sqs', endpoint=queue ARN), the error occurs:

ERROR a.c.i.Registry$RegistryLogStrategy - Actor[akka://sns/user/$a#1061847866] failed to activate
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: arn://aws:sqs:elasticmq:000000000000:testqueue due to: No component found with scheme: arn
	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:594) ~[sns-0.1.3.jar:0.1.3]
	at akka.camel.internal.ProducerRegistrar$$anonfun$receive$3.applyOrElse(CamelSupervisor.scala:164) ~[sns-0.1.3.jar:0.1.3]
...

Also it's not clear how one can set SQS endpoint URL - e.g. to localhost when using elasticMQ.

Can you elaborate on elasticMQ integration?

mvmn avatar Mar 20 '17 16:03 mvmn

@mvmn, check example in tests: https://github.com/s12v/sns/blob/master/features/sqs.feature#L12

s12v avatar Mar 20 '17 16:03 s12v

Thanks.

You seem to be using a URL as endpoint though, but, according to AWS documentation, for protocol "sqs" the endpoint should be queue ARN, not a URL.

See here: For the sqs protocol, the endpoint is the ARN of an Amazon SQS queue

mvmn avatar Mar 20 '17 16:03 mvmn

@mvmn, yes, I can't use ARN, because it's not a real SNS/SQS... format should match http://camel.apache.org/aws-sqs.html

s12v avatar Mar 20 '17 16:03 s12v

Well, if you'd have a URL to elasticMQ configured, all you'd need is queue name I suppose. And queue name can be taken from ARN - it's just a last part of ARN, all after last colon.

This is documented also:

Amazon Simple Queue Service (Amazon SQS)

Syntax:
arn:aws:sqs:region:account-id:queuename

mvmn avatar Mar 20 '17 16:03 mvmn

@mvmn, but I don't have elasticMQ URL anywhere, except the endpoint string Let's say, I give it ARN - how would it figure out it's localhost?

s12v avatar Mar 20 '17 16:03 s12v

I mean you could have a configuration property (or, say, a command-line argument) for your app that would contain SQS URL (+possibly also accessKey+secretKey), and then use that to convert ARN into aws-sqs://<queue-name>?amazonSQSEndpoint=http://<SQS host:port>&accessKey=<Access key>&secretKey=<Secret key>.

Then one could run elasticMQ on known host:port (say, localhost:9324 - which is the default for elasticMQ), and use your app with it using proper AWS SDK calls.

mvmn avatar Mar 20 '17 16:03 mvmn

@mvmn, could you please provide a complete use-case for this? How do you use this and where is SQS ARN coming from?

s12v avatar Mar 20 '17 18:03 s12v

SQS ARN is coming from ElasticMQ.

I'm running ElasticMQ and your SNS emulator on my local dev machine, where I develop an app that uses SNS and SQS. Since I don't want to use the real thing during development, I try to replace it with emulators (again, ElasticMQ for SQS, and your emulator for SNS).

The app I'm developing creates SQS queue in ElasticMQ (using Amazon Java SDK), then topic in SNS emulator, and then tries to create subscription in SNS emulator for that SQS queue - using valid Amazon API call (done via Java SDK), which requires me to submit topic ARN, protocol, and endpoint parameters.

According to API description, for SQS protocol the endpoint parameter must be queue ARN (see aforementioned quotes from Amazon documentation).

But you seem to expect a URL that's not even valid in SQS, but is some Camel-specific URL.

mvmn avatar Mar 20 '17 19:03 mvmn

@mvmn, ok, makes sense. I'll try to do it when I have some time. Or maybe you are interested in submitting a PR? That would be awesome.

s12v avatar Mar 20 '17 19:03 s12v

Unfortunately, I'm only good with Java, but never did any Scala. But I'll try things out and if I'll manage to cope with Scala - will do a pull request.

And thank you for your time and effort developing this thing.

mvmn avatar Mar 20 '17 19:03 mvmn

FYI - I gave it a shot here: https://github.com/s12v/sns/pull/54

hzshlomi avatar Feb 11 '19 19:02 hzshlomi