/** * Simplified method form for invoking the Subscribe operation with an AsyncHandler. * * @see #subscribeAsync(SubscribeRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<SubscribeResult> subscribeAsync(String topicArn, String protocol, String endpoint, com.amazonaws.handlers.AsyncHandler<SubscribeRequest, SubscribeResult> asyncHandler) { return subscribeAsync(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint), asyncHandler); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); hashCode = prime * hashCode + ((getProtocol() == null) ? 0 : getProtocol().hashCode()); hashCode = prime * hashCode + ((getEndpoint() == null) ? 0 : getEndpoint().hashCode()); hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); hashCode = prime * hashCode + ((getReturnSubscriptionArn() == null) ? 0 : getReturnSubscriptionArn().hashCode()); return hashCode; }
@Override public Subscription subscribe(String endpoint, String protocol, ResultCapture<SubscribeResult> extractor) { SubscribeRequest request = new SubscribeRequest() .withEndpoint(endpoint) .withProtocol(protocol); return subscribe(request, extractor); }
SubscribeRequest subscribeRequest = new SubscribeRequest(); subscribeRequest.setTopicArn(topicArn); subscribeRequest.setProtocol(protocol); subscribeRequest.setEndpoint(endpoint); return subscribe(subscribeRequest);
SubscribeRequest primarySubscribeRequest = new SubscribeRequest( primaryTopicArn, "sqs", primaryQueueArn ); sns.subscribe( primarySubscribeRequest ); SubscribeRequest subscribeRequest = new SubscribeRequest( topicARN, "sqs", queueARN );
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); hashCode = prime * hashCode + ((getProtocol() == null) ? 0 : getProtocol().hashCode()); hashCode = prime * hashCode + ((getEndpoint() == null) ? 0 : getEndpoint().hashCode()); return hashCode; }
@Override public Subscription subscribe(String endpoint, String protocol, ResultCapture<SubscribeResult> extractor) { SubscribeRequest request = new SubscribeRequest() .withEndpoint(endpoint) .withProtocol(protocol); return subscribe(request, extractor); }
SubscribeRequest subscribeRequest = new SubscribeRequest(); subscribeRequest.setTopicArn(topicArn); subscribeRequest.setProtocol(protocol); subscribeRequest.setEndpoint(endpoint); return subscribe(subscribeRequest);
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 boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SubscribeRequest == false) return false; SubscribeRequest other = (SubscribeRequest) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; if (other.getProtocol() == null ^ this.getProtocol() == null) return false; if (other.getProtocol() != null && other.getProtocol().equals(this.getProtocol()) == false) return false; if (other.getEndpoint() == null ^ this.getEndpoint() == null) return false; if (other.getEndpoint() != null && other.getEndpoint().equals(this.getEndpoint()) == false) return false; return true; } }
/** * Simplified method form for invoking the Subscribe operation with an AsyncHandler. * * @see #subscribeAsync(SubscribeRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<SubscribeResult> subscribeAsync(String topicArn, String protocol, String endpoint, com.amazonaws.handlers.AsyncHandler<SubscribeRequest, SubscribeResult> asyncHandler) { return subscribeAsync(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint), asyncHandler); }
String subscriptionId = snsClient.subscribe(new SubscribeRequest() .withEndpoint(endpointId) .withProtocol("application") .withTopicArn(topicId) ).getSubscriptionArn();
/** * 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() + ","); if (getProtocol() != null) sb.append("Protocol: " + getProtocol() + ","); if (getEndpoint() != null) sb.append("Endpoint: " + getEndpoint()); sb.append("}"); return sb.toString(); }
return false; SubscribeRequest other = (SubscribeRequest) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; if (other.getProtocol() == null ^ this.getProtocol() == null) return false; if (other.getProtocol() != null && other.getProtocol().equals(this.getProtocol()) == false) return false; if (other.getEndpoint() == null ^ this.getEndpoint() == null) return false; if (other.getEndpoint() != null && other.getEndpoint().equals(this.getEndpoint()) == false) return false; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; if (other.getReturnSubscriptionArn() == null ^ this.getReturnSubscriptionArn() == null) return false; if (other.getReturnSubscriptionArn() != null && other.getReturnSubscriptionArn().equals(this.getReturnSubscriptionArn()) == false) return false; return true;
/** * Simplified method form for invoking the Subscribe operation. * * @see #subscribeAsync(SubscribeRequest) */ @Override public java.util.concurrent.Future<SubscribeResult> subscribeAsync(String topicArn, String protocol, String endpoint) { return subscribeAsync(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint)); }
SubscribeRequest subscribeRequest = new SubscribeRequest(topicArn, protocol.toLowerCase(), endPoint); sns.subscribe(subscribeRequest);
public Request<SubscribeRequest> marshall(SubscribeRequest subscribeRequest) { if (subscribeRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(SubscribeRequest)"); } Request<SubscribeRequest> request = new DefaultRequest<SubscribeRequest>(subscribeRequest, "AmazonSNS"); request.addParameter("Action", "Subscribe"); request.addParameter("Version", "2010-03-31"); String prefix; if (subscribeRequest.getTopicArn() != null) { prefix = "TopicArn"; String topicArn = subscribeRequest.getTopicArn(); request.addParameter(prefix, StringUtils.fromString(topicArn)); } if (subscribeRequest.getProtocol() != null) { prefix = "Protocol"; String protocol = subscribeRequest.getProtocol(); request.addParameter(prefix, StringUtils.fromString(protocol)); } if (subscribeRequest.getEndpoint() != null) { prefix = "Endpoint"; String endpoint = subscribeRequest.getEndpoint(); request.addParameter(prefix, StringUtils.fromString(endpoint)); } return request; } }
/** * 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()).append(","); if (getProtocol() != null) sb.append("Protocol: ").append(getProtocol()).append(","); if (getEndpoint() != null) sb.append("Endpoint: ").append(getEndpoint()).append(","); if (getAttributes() != null) sb.append("Attributes: ").append(getAttributes()).append(","); if (getReturnSubscriptionArn() != null) sb.append("ReturnSubscriptionArn: ").append(getReturnSubscriptionArn()); sb.append("}"); return sb.toString(); }
/** * Simplified method form for invoking the Subscribe operation. * * @see #subscribeAsync(SubscribeRequest) */ @Override public java.util.concurrent.Future<SubscribeResult> subscribeAsync(String topicArn, String protocol, String endpoint) { return subscribeAsync(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint)); }
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)); }