/** * Loops until an attribute is set, throwing after a timeout. */ private String retrieveQueueAttribute(String attributeName) throws Exception { for (int ii = 0 ; ii < 60 ; ii++) { try { GetQueueAttributesRequest attribsRequest = new GetQueueAttributesRequest() .withQueueUrl(queueUrl) .withAttributeNames(attributeName); GetQueueAttributesResult attribsResponse = localSQSclient.getQueueAttributes(attribsRequest); Map<String,String> attribs = attribsResponse.getAttributes(); if (! StringUtil.isEmpty(attribs.get(attributeName))) return attribs.get(attributeName); } catch (ResourceNotFoundException ex) { // ignored; queue isn't ready } Thread.sleep(1000); } throw new IllegalStateException("unable to retrieve attribute: " + attributeName); }
@Override public boolean removeMetricFilter(MetricFilter metricFilter) { log.info(String.format("Removing metric filter [%s] from log group [%s]", metricFilter.getMetricName(), metricFilter.getLogGroupName())); DeleteMetricFilterRequest request = new DeleteMetricFilterRequest() .withLogGroupName(metricFilter.getLogGroupName()) .withFilterName(metricFilter.getMetricName()); try { client.deleteMetricFilter(request); return true; } catch (ResourceNotFoundException e) { log.warn(String.format("Did not find metric filter [%s] in log group [%s]", metricFilter.getMetricName(), metricFilter.getLogGroupName())); } return false; }