java - AWS.SimpleQueueService.NonExistentQueue Exception thrown when Accessing Existing SQS queue -


i relatively new aws sqs services. have written code wrap amazon sqs api.

i able perform basic functionality created queues, despite (in fact have been using code ever no problem, , creating junit tests formality), failing junit test because of error makes little sense me.

i have created queue names serenaqfortest using aws management console. when @ aws console can see queue have created listed. have set permissions on queue open everyone. coding in java.

when try interact queue, amazonserviceexception error code aws.simplequeueservice.nonexistentqueueerror.

here code.

in junit class:

/**  * prefix queues used run junit tests.  */ private static final string testq = "serenafortest";  /**  * ensures queue exists.  */ @test public void testexists() {     system.out.println("junit test exists.");     cloudsqs cloudsqs = new cloudsqs();     // queue exist , can see through aws management console in sqs     asserttrue(cloudsqs.exists(testq));     // queue not exist.     asserttrue(cloudsqs.exists("thisqdoesnotexist") == false); } 

and exists() defined follows:

/**  * determines if queue exists or not.  *   * @param qname  *            , name of queue determine existence of.  * @return boolean, true if queue exists; false otherwise.  */ public boolean exists(final string qname) {     boolean retval = false;     try {         // create request url of qname         getqueueurlrequest getqueueurlrequest = new getqueueurlrequest(qname);          string addy = sqs.getqueueurl(getqueueurlrequest).getqueueurl();         system.out.println(qname + " url : " + addy);         if (addy != null) {             // queues on sqs             listqueuesresult queues = sqs.listqueues();             // each url,             (string url : queues.getqueueurls()) {                 // system.out.println("comparing " + addy + " , " + url);                 if (url.equalsignorecase(addy)) {                     system.out.println("queue exists.");                     retval = true;                     break;                 }             }         } else {             system.out.println("queue " + qname + " not exist.");         }     } catch (amazonserviceexception ase) {         system.err.println("err: amazonserviceexception. error code: " + ase.geterrorcode());     } catch (amazonclientexception ace) {         system.err.println("err: amazonclientexception.");         ace.printstacktrace();     } catch (exception e) {         system.err.println("err: regular old error.");         e.printstacktrace();     }     return retval; } 

console output:


junit test exists. serenafortest url : https://sqs.us-west-2.amazonaws.com/079023477467/serenafortest queue exists. err: amazonserviceexception. error code: aws.simplequeueservice.nonexistentqueue

here stacktrace:

amazonserviceexception: status code: 400, aws service: amazonsqs, aws request id: a2809a40-223f-5c4d-b369-d0c3301a8e4e, aws error code: aws.simplequeueservice.nonexistentqueue, aws error message: specified queue not exist wsdl version. @ com.amazonaws.http.amazonhttpclient.handleerrorresponse(amazonhttpclient.java:644) @ com.amazonaws.http.amazonhttpclient.executehelper(amazonhttpclient.java:338) @ com.amazonaws.http.amazonhttpclient.execute(amazonhttpclient.java:190) @ com.amazonaws.services.sqs.amazonsqsclient.invoke(amazonsqsclient.java:875) @ com.amazonaws.services.sqs.amazonsqsclient.getqueueurl(amazonsqsclient.java:364) @ com.tutelatechnologies.sqliteconverter.cloud.cloudsqs.exists(cloudsqs.java:301) @ com.tutelatechnologies.sqliteconverter.cloud.cloudsqstest.testexists(cloudsqstest.java:169) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:45) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:15) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:42) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:20) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:28) @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:30) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:263) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:68) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:47) @ org.junit.runners.parentrunner$3.run(parentrunner.java:231) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:60) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:229) @ org.junit.runners.parentrunner.access$000(parentrunner.java:50) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:222) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:28) @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:30) @ org.junit.runners.parentrunner.run(parentrunner.java:300) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:50) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197)

from can see function able grab queue url , match found. still throws exception.

any 1 have ideas why happening? call exists() every time need throw on or take off of queue failing of junit tests same reasons.

thanks in advance!!!

stumbled on same problem. solution pretty simple after reading java docs more :) set client.setendpoint(...) when creating sqsclient

sqsclient = new amazonsqsclient( credentials ); sqsclient.setendpoint("sqs.eu-west-1.amazonaws.com"); 

endpoint values found @ aws link


Comments

  1. Thanks for providing your information, Keep share and update with us. AWS Online Training

    ReplyDelete

Post a Comment

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -