Rupesh029 / typica

Automatically exported from code.google.com/p/typica
Apache License 2.0
0 stars 0 forks source link

If you have 2 queues where one queue name ends with the other queue name, SQSUtils.getMessageQueue may return the wrong queue #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We had two message queues: "ocr_input_queue" and "vividata_ocr_input_queue". 
Attempts to 
retrieve the ocr_input_queue could return either queue.

SQSUtils.getMessageQueue(), line 106, reads as follows: 
            if ( mq.getUrl().toString().endsWith( msgQueueName ) ) {
The "endsWith" check makes it not necessary to pass in the AWS user id that 
appears at the front 
of each queue name. However, it causes the above problem. 

The simplest solution may be to check if the passed in msgQueueName contains a 
forward slash 
and, if not, prepend one on to it. If the decision is made not to change the 
way the function 
behaves, given the extent this may be used already and the possibility of 
breaking someone's 
code, another option would be to implement a new function:
                public static MessageQueue getMessageQueueEntireName(QueueService service, String 
msgQueueName)
that prepends a slash on to msgQueueName, if needed, and then delegates the 
operation to the 
existing getMessageQueue function.

Original issue reported on code.google.com by walsh...@gmail.com on 25 Feb 2010 at 2:49

GoogleCodeExporter commented 9 years ago
I've marked this method as "deprecated".
The rationale is that getMessageQueue makes a call to list all message queues 
for 
the account, which is going to return either some or a lot of data depending on 
how 
many queues are defined for the account. Then, it will either return a queue 
when a 
match is found by name, or create the queue, which is another WS call.
I think the preferred method would be to simply call 
QueueService.getOrCreateMessageQueue(), which is a single WS call which returns 
a 
fixed amount of data (namely the queue URL). It is consistent and less overhead 
than 
the getMessageQueue call, which is mostly there for compatibility with an older 
AWS 
java client.

Original comment by dkavan...@gmail.com on 23 Mar 2010 at 10:00

GoogleCodeExporter commented 9 years ago
Issue 58 has been merged into this issue.

Original comment by dkavan...@gmail.com on 23 Mar 2010 at 11:02