@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubscriptionArn() == null) ? 0 : getSubscriptionArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SubscribeResult == false) return false; SubscribeResult other = (SubscribeResult) obj; if (other.getSubscriptionArn() == null ^ this.getSubscriptionArn() == null) return false; if (other.getSubscriptionArn() != null && other.getSubscriptionArn().equals(this.getSubscriptionArn()) == 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 (getSubscriptionArn() != null) sb.append("SubscriptionArn: ").append(getSubscriptionArn()); sb.append("}"); return sb.toString(); }
String subscriptionARN = subscribeResult.getSubscriptionArn(); if ( logger.isTraceEnabled() ) { logger.trace(
return subscribeResult.getSubscriptionArn();
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubscriptionArn() == null) ? 0 : getSubscriptionArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SubscribeResult == false) return false; SubscribeResult other = (SubscribeResult) obj; if (other.getSubscriptionArn() == null ^ this.getSubscriptionArn() == null) return false; if (other.getSubscriptionArn() != null && other.getSubscriptionArn().equals(this.getSubscriptionArn()) == 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 (getSubscriptionArn() != null) sb.append("SubscriptionArn: " + getSubscriptionArn()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubscriptionArn() == null) ? 0 : getSubscriptionArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SubscribeResult == false) return false; SubscribeResult other = (SubscribeResult) obj; if (other.getSubscriptionArn() == null ^ this.getSubscriptionArn() == null) return false; if (other.getSubscriptionArn() != null && other.getSubscriptionArn().equals(this.getSubscriptionArn()) == 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 (getSubscriptionArn() != null) sb.append("SubscriptionArn: " + getSubscriptionArn()); sb.append("}"); return sb.toString(); }
.withProtocol("sqs") .withTopicArn(snsTopicArn)); return subscribeResult.getSubscriptionArn();
/** * Returns the subscription arn resulting from subscribing the queueARN to the topicARN */ public static String subscribeToTopic(AmazonSNS amazonSNS, ARN topicARN, ARN queueARN) { return amazonSNS.subscribe(topicARN.getArn(), "sqs", queueARN.getArn()).getSubscriptionArn(); }
snsSubscriptionARN = subscribeResult.getSubscriptionArn(); logger.info("Subscribed for messages from SNS control channel:" + snsTopicARN + " ----> SQS: "+sqsQueueARN); logger.info("Subscription ARN: " + snsSubscriptionARN);
@Override public String subscribeSnsToQueue(String snsTopic, String queueName) { try { String queueUrl = sqs.getQueueUrl(queueName).getQueueUrl(); LOG.info("Subscribing SNS topic {} to the queue: {}", snsTopic, queueUrl); String queueArn = sqs.getQueueAttributes(queueUrl, ImmutableList.of("QueueArn")).getAttributes().get("QueueArn"); Policy policy = new Policy().withStatements( new Statement(Statement.Effect.Allow) .withActions(SQSActions.SendMessage) .withPrincipals(Principal.All) .withResources(new Resource(queueArn)) .withConditions(ConditionFactory.newSourceArnCondition(snsTopic))); sqs.setQueueAttributes(new SetQueueAttributesRequest() .withQueueUrl(queueUrl) .addAttributesEntry(QueueAttributeName.Policy.toString(), policy.toJson()) ); String snsSubscriptionArn = sns.subscribe(snsTopic, "sqs", queueArn).getSubscriptionArn(); LOG.info("Subscribed SNS to dedicated SQS queue. subscriptionArn: {}", snsSubscriptionArn); return snsSubscriptionArn; } catch (AmazonClientException e) { LOG.info("Failed to subscribe to subscribe SNS to SQS queue", e); throw new RuntimeException(e); } }
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; }
/** * For retrieving vault inventory. For initializing SNS for determining when * job completed. Does nothing if member snsTopicName is null. Sets members * snsTopicARN and snsSubscriptionARN. */ void setupSNS() { // If no snsTopicName setup then simply return if (snsTopicName == null) return; CreateTopicRequest request = new CreateTopicRequest() .withName(snsTopicName); CreateTopicResult result = snsClient.createTopic(request); snsTopicARN = result.getTopicArn(); SubscribeRequest request2 = new SubscribeRequest() .withTopicArn(snsTopicARN).withEndpoint(sqsQueueARN) .withProtocol("sqs"); SubscribeResult result2 = snsClient.subscribe(request2); snsSubscriptionARN = result2.getSubscriptionArn(); }
@Override public String subscribe(NevadoTopic topic, NevadoQueue topicEndpoint) throws JMSException { String subscriptionArn; try { SQSQueue queue = getSQSQueue((NevadoDestination) topicEndpoint); String sqsArn = queue.getQueueARN(); String snsArn = getTopicARN(topic); queue.setPolicy(getPolicy(snsArn, sqsArn)); subscriptionArn = _amazonSNS.subscribe(new SubscribeRequest().withTopicArn(getTopicARN(topic)) .withProtocol("sqs").withEndpoint(sqsArn)).getSubscriptionArn(); } catch (AmazonClientException e) { throw handleAWSException("Unable to subscripe to topic " + topic, e); } return subscriptionArn; }
.withProtocol("sqs") .withTopicArn(snsTopicArn)); return subscribeResult.getSubscriptionArn();