@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: ").append(getTopicArn()); sb.append("}"); return sb.toString(); }
topicArn = createTopicResult.getTopicArn();
private void setupQueueAndTopic() { String randomSeed = UUID.randomUUID().toString(); String queueName = "glacier-archive-transfer-" + randomSeed; String topicName = "glacier-archive-transfer-" + randomSeed; queueUrl = sqs.createQueue(new CreateQueueRequest(queueName)).getQueueUrl(); topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn(); String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn"); Policy sqsPolicy = new Policy().withStatements( new Statement(Effect.Allow) .withPrincipals(Principal.AllUsers) .withActions(SQSActions.SendMessage) .withResources(new Resource(queueARN)) .withConditions(ConditionFactory.newSourceArnCondition(topicArn))); sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson()))); sns.subscribe(new SubscribeRequest(topicArn, "sqs", queueARN)); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: " + getTopicArn()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: " + getTopicArn()); sb.append("}"); return sb.toString(); }
@Override public String get() { // This will create the topic if it doesn't exist or return the existing topic if it does. CreateTopicResult topic = _amazonSNS.createTopic(topicName); return topic.getTopicArn(); } });
/** * Creates a new sns test topic. * * @param snsClient the Simple Notification Service (SNS) client * @return the Amazon Resource Name (ARN) of the created sns topic */ public static String createTestTopic(final AmazonSNS snsClient) { final String queueName = "jvm-sdk-test-topic-" + UUID.randomUUID(); final CreateTopicResult queueCreationResult = snsClient.createTopic(queueName); return queueCreationResult.getTopicArn(); }
@Override public String resolveDestination(String name) throws DestinationResolutionException { if (this.autoCreate) { return this.amazonSns.createTopic(new CreateTopicRequest(name)).getTopicArn(); } else { String physicalTopicName = name; if (this.resourceIdResolver != null) { physicalTopicName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (physicalTopicName != null && AmazonResourceName.isValidAmazonResourceName(physicalTopicName)) { return physicalTopicName; } String topicArn = getTopicResourceName(null, physicalTopicName); if (topicArn == null) { throw new IllegalArgumentException("No Topic with name: '" + name + "' found. Please use " + "the right topic name or enable auto creation of topics for this DestinationResolver"); } return topicArn; } }
@Override public String resolveDestination(String name) throws DestinationResolutionException { if (this.autoCreate) { return this.amazonSns.createTopic(new CreateTopicRequest(name)).getTopicArn(); } else { String physicalTopicName = name; if (this.resourceIdResolver != null) { physicalTopicName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (physicalTopicName != null && AmazonResourceName.isValidAmazonResourceName(physicalTopicName)) { return physicalTopicName; } String topicArn = getTopicResourceName(null, physicalTopicName); if (topicArn == null) { throw new IllegalArgumentException("No Topic with name: '" + name + "' found. Please use " + "the right topic name or enable auto creation of topics for this DestinationResolver"); } return topicArn; } }
protected String getTopicARN(NevadoTopic topic) throws JMSException { if (topic.getArn() == null) { CreateTopicResult result; try { result = _amazonSNS.createTopic(new CreateTopicRequest(topic.getTopicName())); } catch (AmazonClientException e) { throw handleAWSException("Unable to create/lookup topic: " + topic, e); } topic.setArn(result.getTopicArn()); } return topic.getArn(); }
private QueueConfig setupSNS(QueueConfig config, String snsTopicName) { CreateTopicRequest request = new CreateTopicRequest().withName(snsTopicName); CreateTopicResult result = snsClient.createTopic(request); config.snsTopicARN = result.getTopicArn(); SubscribeRequest request2 = new SubscribeRequest().withTopicArn(config.snsTopicARN).withEndpoint(config.sqsQueueARN) .withProtocol("sqs"); SubscribeResult result2 = snsClient.subscribe(request2); config.snsSubscriptionARN = result2.getSubscriptionArn(); return config; }
private static String ensureTopicExists(AmazonSNS amazonSNS, ARN topicARN, List<String> allAccountIds, ARN queueARN) { topicARN.arn = amazonSNS.createTopic(topicARN.name).getTopicArn(); amazonSNS.setTopicAttributes( new SetTopicAttributesRequest() .withTopicArn(topicARN.arn) .withAttributeName("Policy") .withAttributeValue(buildSNSPolicy(topicARN, allAccountIds).toJson()) ); amazonSNS.subscribe(topicARN.arn, "sqs", queueARN.arn); return topicARN.arn; }
/** * Ensure that the topic exists and has a policy granting all accounts permission to publish messages to it */ private static String ensureTopicExists(AmazonSNS amazonSNS, ARN topicARN, List<String> allAccountIds, ARN queueARN) { topicARN.arn = amazonSNS.createTopic(topicARN.name).getTopicArn(); amazonSNS.setTopicAttributes( new SetTopicAttributesRequest() .withTopicArn(topicARN.arn) .withAttributeName("Policy") .withAttributeValue(buildSNSPolicy(topicARN, allAccountIds).toJson()) ); amazonSNS.subscribe(topicARN.arn, "sqs", queueARN.arn); return topicARN.arn; }
private void setupQueueAndTopic() { String randomSeed = UUID.randomUUID().toString(); String queueName = "glacier-archive-transfer-" + randomSeed; String topicName = "glacier-archive-transfer-" + randomSeed; queueUrl = sqs.createQueue(new CreateQueueRequest(queueName)).getQueueUrl(); topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn(); String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn"); Policy sqsPolicy = new Policy().withStatements( new Statement(Effect.Allow) .withPrincipals(Principal.AllUsers) .withActions(SQSActions.SendMessage) .withResources(new Resource(queueARN)) .withConditions(ConditionFactory.newSourceArnCondition(topicArn))); sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson()))); sns.subscribe(new SubscribeRequest(topicArn, "sqs", queueARN)); }