List of usage examples for com.amazonaws.services.sqs.model SetQueueAttributesRequest setQueueUrl
public void setQueueUrl(String queueUrl)
The URL of the Amazon SQS queue whose attributes are set.
From source file:com.eucalyptus.portal.SimpleQueueClientManager.java
License:Open Source License
public void setQueueAttributes(final String queueName, final Map<String, String> queueAttributes) throws Exception { try {// w ww. j a va 2 s . c o m final SetQueueAttributesRequest req = new SetQueueAttributesRequest(); req.setAttributes(queueAttributes); req.setQueueUrl(getQueueUrl(queueName)); getSimpleQueueClient().setQueueAttributes(req); } catch (final AmazonServiceException ex) { throw new Exception("Failed to set queue attributes due to service error", ex); } catch (final AmazonClientException ex) { throw new Exception("Failed to set queue attributes due to client error", ex); } }
From source file:org.apache.camel.component.aws.sqs.SqsEndpoint.java
License:Apache License
private void updateQueueAttributes(AmazonSQS client) { SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.setQueueUrl(queueUrl); if (getConfiguration().getDefaultVisibilityTimeout() != null) { request.getAttributes().put(QueueAttributeName.VisibilityTimeout.name(), String.valueOf(getConfiguration().getDefaultVisibilityTimeout())); }/*w w w . j a v a2s . co m*/ if (getConfiguration().getMaximumMessageSize() != null) { request.getAttributes().put(QueueAttributeName.MaximumMessageSize.name(), String.valueOf(getConfiguration().getMaximumMessageSize())); } if (getConfiguration().getMessageRetentionPeriod() != null) { request.getAttributes().put(QueueAttributeName.MessageRetentionPeriod.name(), String.valueOf(getConfiguration().getMessageRetentionPeriod())); } if (getConfiguration().getPolicy() != null) { request.getAttributes().put(QueueAttributeName.Policy.name(), String.valueOf(getConfiguration().getPolicy())); } if (getConfiguration().getReceiveMessageWaitTimeSeconds() != null) { request.getAttributes().put(QueueAttributeName.ReceiveMessageWaitTimeSeconds.name(), String.valueOf(getConfiguration().getReceiveMessageWaitTimeSeconds())); } if (!request.getAttributes().isEmpty()) { LOG.trace("Updating queue '{}' with the provided queue attributes...", configuration.getQueueName()); client.setQueueAttributes(request); LOG.trace("Queue '{}' updated and available at {}'", configuration.getQueueName(), queueUrl); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
/** * //from w ww. j av a 2s .c o m * @param applicationId */ public void createSQSQueue(String orgAppName) { log.info("Creating Queue for App : " + orgAppName); CreateQueueRequest createQueueRequest = new CreateQueueRequest(); createQueueRequest.setQueueName(AWSUtil.formQueueName(orgAppName)); try { sqsClient.createQueue(createQueueRequest); //Need to do this to get QueueArn to apply right policy on that GetQueueAttributesRequest attributesRequest = new GetQueueAttributesRequest() .withQueueUrl(AWSUtil.formFullQueueUrl(orgAppName)).withAttributeNames("QueueArn"); GetQueueAttributesResult attributesResult = sqsClient.getQueueAttributes(attributesRequest); String queueArn = attributesResult.getAttributes().get("QueueArn"); SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest(); Map<String, String> queueAttributes = new HashMap<String, String>(); //Increasing the max size of SQS messages. queueAttributes.put("MaximumMessageSize", "65536"); //Apply IP address white list String sqsPolicy = AWSUtil.getSQSIPAddressWhiteListPolicy(queueArn); log.info("For queue " + queueArn + " with policy json " + sqsPolicy); queueAttributes.put("Policy", sqsPolicy); setQueueAttributesRequest.setAttributes(queueAttributes); setQueueAttributesRequest.setQueueUrl(AWSUtil.formFullQueueUrl(orgAppName)); sqsClient.setQueueAttributes(setQueueAttributesRequest); } catch (AmazonServiceException ase) { log.error("Problem creating queue in sqs"); log.error(ase); } catch (AmazonClientException ace) { log.error(ace); } }