-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redrive Policy Example #124
Comments
Hello,
here's a test which uses a redrive policy:
https://github.com/adamw/elasticmq/blob/master/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/AmazonJavaSdkTestSuite.scala#L944-L960
Maybe it will help?
Adam
… On 4 Jan 2018, at 07:10, harry9111985 ***@***.***> wrote:
Hi adamw,
If you have any samples to create redrivepolicy links using dead queues that would be great . Currently , I am trying to create a redrivepolicy during CreateQueueRequest (Amazon Java SDK) using queue attributes. I do get a debug point on the RedrivePolicy.class in the elasticmq package . But elasticmq doesnt seem to create a link with the DeadLetterQueue.
My java code :
final Map<String, String> deadLetterQueueAttrs = new HashMap<>();
deadLetterQueueAttrs.put("VisibilityTimeout", "600");
final CreateQueueRequest createDeadLetterQueueRequest = new CreateQueueRequest()
.withQueueName(queueName + "-error")
.withAttributes(deadLetterQueueAttrs);
final CreateQueueResult deadLetterQueueResult = amazonSQSAsyncClient.createQueue(createDeadLetterQueueRequest);
final GetQueueAttributesResult deadLetterQueueArnResult = amazonSQSAsyncClient.getQueueAttributes(deadLetterQueueResult.getQueueUrl(), Arrays.asList("QueueArn"));
final Map<String, String> queueAttributes = new HashMap<>();
final StringBuilder redrivePolicyParamBuilder = new StringBuilder()
.append("{\"deadLetterTargetArn\" : \"")
.append(deadLetterQueueArnResult.getAttributes().get("QueueArn"))
.append("\",")
.append("\"maxReceiveCount\": \"1\"}");
queueAttributes.put("RedrivePolicy", redrivePolicyParamBuilder.toString());
queueAttributes.put("VisibilityTimeout","600");
final CreateQueueRequest createQueueRequest = new CreateQueueRequest()
.withQueueName(queueName)
.withAttributes(queueAttributes);
final CreateQueueResult createQueueResult = amazonSQSAsyncClient.createQueue(createQueueRequest);
No errors are thrown but the redrive policy link is not created,
Kindly help.
Regards,
Harish
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
--
Adam Warski
http://www.softwaremill.com
http://twitter.com/#!/adamwarski
|
Hi @adamw , Thanks for your response. I am not sure that piece of code works in Java . I am doing the same thing in Java as mentioned in the above snippet . I get the following CreateRequest in the logs Creating queue QueueData(test-api-log,MillisVisibilityTimeout(600000),PT0S,PT0S,2018-01-04T20:31:29.425+10:00,2018-01-04T20:31:29.425+10:00,Some(DeadLettersQueueData(test-api-log-error,1)),None) But when I get "All" Attributes for the queue I get the following Queue Attributes : {"attributes":{"ReceiveMessageWaitTimeSeconds":"0","ApproximateNumberOfMessagesDelayed":"0","CreatedTimestamp":"1515061889","DelaySeconds":"0","VisibilityTimeout":"600","ApproximateNumberOfMessages":"0","ApproximateNumberOfMessagesNotVisible":"0","LastModifiedTimestamp":"1515061889","QueueArn":"arn:aws:sqs:elasticmq:000000000000:test-api-log"}} Can you spot any errors ? Regards, |
True, it looks the same ... however, I noticed the test doesn't really check the results, so it's incomplete - maybe there's a bug in there.
I'd have to check, but no time right now unfortunately - sorry!.
Adam
… On 4 Jan 2018, at 11:35, harry9111985 ***@***.***> wrote:
Hi Adam,
Thanks for your response. I am not sure that piece of code works in Java . I am doing the same thing in Java as mentioned in the above snippet .
I get the following CreateRequest in the logs
Creating queue QueueData(test-api-log,MillisVisibilityTimeout(600000),PT0S,PT0S,2018-01-04T20:31:29.425+10:00,2018-01-04T20:31:29.425+10:00,Some(DeadLettersQueueData(test-api-log-error,1)),None)
But when I get "All" Attributes for the queue I get the following
Queue Attributes : {"attributes":{"ReceiveMessageWaitTimeSeconds":"0","ApproximateNumberOfMessagesDelayed":"0","CreatedTimestamp":"1515061889","DelaySeconds":"0","VisibilityTimeout":"600","ApproximateNumberOfMessages":"0","ApproximateNumberOfMessagesNotVisible":"0","LastModifiedTimestamp":"1515061889","QueueArn":"arn:aws:sqs:elasticmq:000000000000:test-api-log"}}
Can you spot any errors ?
Regards,
Harish
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
--
Adam Warski
http://www.softwaremill.com
http://twitter.com/#!/adamwarski
|
I just ran into the same issue. If I create a queue with a redrive policy and then query its attributes, the redrive policy is not among them. This differs from AWS. However the good news is that in my own testing, the redrive policy is actually in effect; messages are failing over after the maxReceiveCount number of receives. But it would be nice to query a queue regarding its redrive policy. Thanks. |
When is 0.13.9 set to release? I see the standalone version is up on S3 and linked to from this repository, but there isn't any official release to the maven repos yet. |
@jaxley sorry, my bad - somehow this step slipped :) Should be in central in ~15 minutes! |
Thanks. But there's at least one bug in the code. RedrivePolicy is still listed as an unsupported attribute name.
This code triggers that, so should probably be mirrored in one of the unit tests to make sure it works properly:
|
Hi @adamw ,
If you have any samples to create redrivepolicy links using dead queues that would be great . Currently , I am trying to create a redrivepolicy during CreateQueueRequest (Amazon Java SDK) using queue attributes. I do get a debug point on the RedrivePolicy.class in the elasticmq package . But elasticmq doesnt seem to create a link with the DeadLetterQueue.
My java code :
final Map<String, String> deadLetterQueueAttrs = new HashMap<>();
deadLetterQueueAttrs.put("VisibilityTimeout", "600");
final CreateQueueRequest createDeadLetterQueueRequest = new CreateQueueRequest()
.withQueueName(queueName + "-error")
.withAttributes(deadLetterQueueAttrs);
No errors are thrown but the redrive policy link is not created,
Kindly help.
Regards,
Harish
The text was updated successfully, but these errors were encountered: