@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSubscriptionArn() == null) ? 0 : getSubscriptionArn().hashCode()); return hashCode; }
public SubscribeResult unmarshall(StaxUnmarshallerContext context) throws Exception { SubscribeResult subscribeResult = new SubscribeResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return subscribeResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("SubscriptionArn", targetDepth)) { subscribeResult.setSubscriptionArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return subscribeResult; } } } }
/** * <p> * The ARN of the subscription if it is confirmed, or the string "pending confirmation" if the subscription requires * confirmation. However, if the API request parameter <code>ReturnSubscriptionArn</code> is true, then the value is * always the subscription ARN, even if the subscription requires confirmation. * </p> * * @param subscriptionArn * The ARN of the subscription if it is confirmed, or the string "pending confirmation" if the subscription * requires confirmation. However, if the API request parameter <code>ReturnSubscriptionArn</code> is true, * then the value is always the subscription ARN, even if the subscription requires confirmation. * @return Returns a reference to this object so that method calls can be chained together. */ public SubscribeResult withSubscriptionArn(String subscriptionArn) { setSubscriptionArn(subscriptionArn); return this; }
@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; }
public SubscribeResult unmarshall(StaxUnmarshallerContext context) throws Exception { SubscribeResult subscribeResult = new SubscribeResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("SubscriptionArn", targetDepth)) { subscribeResult.setSubscriptionArn(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return subscribeResult; }
/** * 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(); }
public SubscribeResult unmarshall(StaxUnmarshallerContext context) throws Exception { SubscribeResult subscribeResult = new SubscribeResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("SubscriptionArn", targetDepth)) { subscribeResult.setSubscriptionArn(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return subscribeResult; }
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; }