com.amazonaws.services.sns.model.PublishRequest Java Examples
The following examples show how to use
com.amazonaws.services.sns.model.PublishRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnsExecutor.java From spring-integration-aws with MIT License | 6 votes |
/** * Executes the outbound Sns Operation. * */ public Object executeOutboundOperation(final Message<?> message) { try { String serializedMessage = messageMarshaller.serialize(message); if (snsTestProxy == null) { PublishRequest request = new PublishRequest(); PublishResult result = client.publish(request.withTopicArn( topicArn).withMessage(serializedMessage)); log.debug("Published message to topic: " + result.getMessageId()); } else { snsTestProxy.dispatchMessage(serializedMessage); } } catch (MessageMarshallerException e) { log.error(e.getMessage(), e); throw new MessagingException(e.getMessage(), e.getCause()); } return message.getPayload(); }
Example #2
Source File: SNSManager.java From AWS-MIMIC-IIItoOMOP with Apache License 2.0 | 6 votes |
public PublishResult publishSuccess(String topicName, String table) { PublishResult result = null; for(Topic topic : sns.listTopics().getTopics()) { if(sns.getTopicAttributes(topic.getTopicArn()).getAttributes().get("DisplayName").equals(topicName)) { PublishRequest publishRequest = new PublishRequest(topic.getTopicArn(), table + " table has been staged in S3"); result = sns.publish(publishRequest); } } return result; }
Example #3
Source File: SNSManager.java From AWS-MIMIC-IIItoOMOP with Apache License 2.0 | 6 votes |
public PublishResult publishFailure(String topicName, String table, String stack) { PublishResult result = null; for(Topic topic : sns.listTopics().getTopics()) { if(sns.getTopicAttributes(topic.getTopicArn()).getAttributes().get("DisplayName").equals(topicName)) { PublishRequest publishRequest = new PublishRequest(topic.getTopicArn(), "[ERROR]: " + table + " table was not able to be staged in S3. \n\n" + stack); result = sns.publish(publishRequest); } } return result; }
Example #4
Source File: SNSWebhookRunner.java From eplmp with Eclipse Public License 1.0 | 6 votes |
@Override public void run(Webhook webhook, String login, String email, String name, String subject, String content) { SNSWebhookApp webhookApp = (SNSWebhookApp) webhook.getWebhookApp(); String topicArn = webhookApp.getTopicArn(); String awsAccount = webhookApp.getAwsAccount(); String awsSecret = webhookApp.getAwsSecret(); String region = webhookApp.getRegion(); //AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccount, awsSecret)); //snsClient.setRegion(Region.getRegion(Regions.fromName(region))); AmazonSNS snsClient = AmazonSNSClient.builder() .withRegion(Regions.fromName(region)) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsAccount, awsSecret))) .build(); try { PublishRequest publishReq = new PublishRequest() .withTopicArn(topicArn) .withMessage(getMessage(login, email, name, subject, content)); snsClient.publish(publishReq); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Cannot send notification to SNS service", e); } finally { LOGGER.log(Level.INFO, "Webhook runner terminated"); } }
Example #5
Source File: TracingHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testSNSPublish() { // Setup test // reference : https://docs.aws.amazon.com/sns/latest/api/API_Publish.html final String publishResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<PublishResponse xmlns=\"http://sns.amazonaws.com/doc/2010-03-31/\">" + "<PublishResult><MessageId>94f20ce6-13c5-43a0-9a9e-ca52d816e90b</MessageId>" + "</PublishResult>" + "</PublishResponse>"; final String topicArn = "testTopicArn"; AmazonSNS sns = AmazonSNSClientBuilder .standard() .withRequestHandlers(new TracingHandler()) .withRegion(Regions.US_EAST_1) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))) .build(); mockHttpClient(sns, publishResponse); // Test logic Segment segment = AWSXRay.beginSegment("test"); sns.publish(new PublishRequest(topicArn, "testMessage")); Assert.assertEquals(1, segment.getSubsegments().size()); Assert.assertEquals("Publish", segment.getSubsegments().get(0).getAws().get("operation")); Assert.assertEquals(topicArn, segment.getSubsegments().get(0).getAws().get("topic_arn")); }
Example #6
Source File: SnsListenerTest.java From circus-train with Apache License 2.0 | 6 votes |
@Test public void failureBeforeTableReplicationStartIsCalled() { SnsListener listener = new SnsListener(client, config, clock); listener.circusTrainStartUp(new String[] {}, sourceCatalog, replicaCatalog); listener.tableReplicationFailure(tableReplication, EVENT_ID, ERROR); verify(client, times(1)).publish(requestCaptor.capture()); PublishRequest request = requestCaptor.getValue(); assertThat(request.getSubject(), is(SUBJECT)); assertThat(request.getTopicArn(), is("failArn")); assertThat(request.getMessage(), is("{\"protocolVersion\":\"" + PROTOCOL_VERSION + "\"" + ",\"type\":\"FAILURE\",\"headers\":" + "{\"pipeline-id\":\"0943879438\"},\"startTime\":\"starttime\",\"endTime\":\"endtime\",\"eventId\":" + "\"EVENT_ID\",\"sourceCatalog\":\"sourceCatalogName\",\"replicaCatalog\":\"replicaCatalogName\"," + "\"sourceTable\":\"srcDb.srcTable\",\"replicaTable\":\"replicaDb.replicaTable\",\"replicaTableLocation\":\"s3://bucket/path\",\"replicaMetastoreUris\":\"thrift://host:9083\",\"bytesReplicated\":0,\"errorMessage\":\"error message\"}")); }
Example #7
Source File: SnsListenerTest.java From circus-train with Apache License 2.0 | 6 votes |
@Test public void start() { SnsListener listener = new SnsListener(client, config, clock); listener.circusTrainStartUp(new String[] {}, sourceCatalog, replicaCatalog); listener.tableReplicationStart(tableReplication, EVENT_ID); verify(client).publish(requestCaptor.capture()); PublishRequest request = requestCaptor.getValue(); assertThat(request.getSubject(), is(SUBJECT)); assertThat(request.getTopicArn(), is("startArn")); assertThat(request.getMessage(), is("{\"protocolVersion\":\"" + PROTOCOL_VERSION + "\"" + ",\"type\":\"START\",\"headers\":{\"pipeline-id\":\"0943879438\"}," + "\"startTime\":\"starttime\",\"eventId\":\"EVENT_ID\",\"sourceCatalog\":\"sourceCatalogName\"," + "\"replicaCatalog\":\"replicaCatalogName\",\"sourceTable\":\"srcDb.srcTable\",\"replicaTable\":" + "\"replicaDb.replicaTable\",\"replicaTableLocation\":\"s3://bucket/path\",\"replicaMetastoreUris\":\"thrift://host:9083\"}")); }
Example #8
Source File: SnsIOTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testDataWritesToSNS() { final PublishRequest request1 = createSampleMessage("my_first_message"); final PublishRequest request2 = createSampleMessage("my_second_message"); final TupleTag<PublishResult> results = new TupleTag<>(); final AmazonSNS amazonSnsSuccess = getAmazonSnsMockSuccess(); final PCollectionTuple snsWrites = p.apply(Create.of(request1, request2)) .apply( SnsIO.write() .withTopicName(topicName) .withRetryConfiguration( SnsIO.RetryConfiguration.create( 5, org.joda.time.Duration.standardMinutes(1))) .withAWSClientsProvider(new Provider(amazonSnsSuccess)) .withResultOutputTag(results)); final PCollection<Long> publishedResultsSize = snsWrites.get(results).apply(Count.globally()); PAssert.that(publishedResultsSize).containsInAnyOrder(ImmutableList.of(2L)); p.run().waitUntilFinish(); }
Example #9
Source File: SnsIOTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testRetries() throws Throwable { thrown.expectMessage("Error writing to SNS"); final PublishRequest request1 = createSampleMessage("my message that will not be published"); final TupleTag<PublishResult> results = new TupleTag<>(); final AmazonSNS amazonSnsErrors = getAmazonSnsMockErrors(); p.apply(Create.of(request1)) .apply( SnsIO.write() .withTopicName(topicName) .withRetryConfiguration( SnsIO.RetryConfiguration.create(4, org.joda.time.Duration.standardSeconds(10))) .withAWSClientsProvider(new Provider(amazonSnsErrors)) .withResultOutputTag(results)); try { p.run(); } catch (final Pipeline.PipelineExecutionException e) { // check 3 retries were initiated by inspecting the log before passing on the exception expectedLogs.verifyWarn(String.format(SnsIO.Write.SnsWriterFn.RETRY_ATTEMPT_LOG, 1)); expectedLogs.verifyWarn(String.format(SnsIO.Write.SnsWriterFn.RETRY_ATTEMPT_LOG, 2)); expectedLogs.verifyWarn(String.format(SnsIO.Write.SnsWriterFn.RETRY_ATTEMPT_LOG, 3)); throw e.getCause(); } fail("Pipeline is expected to fail because we were unable to write to SNS."); }
Example #10
Source File: SnsIOTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testCustomCoder() throws Exception { final PublishRequest request1 = createSampleMessage("my_first_message"); final TupleTag<PublishResult> results = new TupleTag<>(); final AmazonSNS amazonSnsSuccess = getAmazonSnsMockSuccess(); final MockCoder mockCoder = new MockCoder(); final PCollectionTuple snsWrites = p.apply(Create.of(request1)) .apply( SnsIO.write() .withTopicName(topicName) .withAWSClientsProvider(new Provider(amazonSnsSuccess)) .withResultOutputTag(results) .withCoder(mockCoder)); final PCollection<Long> publishedResultsSize = snsWrites .get(results) .apply(MapElements.into(TypeDescriptors.strings()).via(result -> result.getMessageId())) .apply(Count.globally()); PAssert.that(publishedResultsSize).containsInAnyOrder(ImmutableList.of(1L)); p.run().waitUntilFinish(); assertThat(mockCoder.captured).isNotNull(); }
Example #11
Source File: SNSNotifyAction.java From davos with MIT License | 6 votes |
@Override public void execute(PostDownloadExecution execution) { AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretAccessKey); AmazonSNS sns = snsClientBuilder.withRegion(region) .withCredentials(new AWSStaticCredentialsProvider(credentials)).build(); LOGGER.debug("SNS: Topic Arn : {}", arn); LOGGER.debug("SNS: Topic Region : {}", region); LOGGER.debug("SNS: Topic Access Key : {}", accessKey); LOGGER.debug("SNS: Topic Secret Access Key : {}", secretAccessKey); PublishRequest request = new PublishRequest(); request.setTopicArn(arn); request.setMessageStructure("json"); request.setMessage(formatJsonMessage(execution.fileName)); request.setSubject("A new file has been downloaded"); LOGGER.info("Publishing message to SNS"); PublishResult result = sns.publish(request); LOGGER.info("Publish successful!"); LOGGER.debug("{}", result.getMessageId()); }
Example #12
Source File: SNSPublisher.java From kork with Apache License 2.0 | 6 votes |
public Optional<PublishResult> publishMessage(String message) { if (!isEnabled.get()) { log.warn("Publishing is disabled for topic {}, dropping message {}", topicARN, message); return Optional.empty(); } try { PublishRequest publishRequest = new PublishRequest(topicARN.getArn(), message); PublishResult publishResponse = retrySupport.retry( () -> amazonSNS.publish(publishRequest), 5, Duration.ofMillis(200), false); log.debug( "Published message {} with id {} to topic {}", message, publishResponse.getMessageId(), topicARN); getSuccessCounter().increment(); return Optional.of(publishResponse); } catch (Exception e) { log.error("failed to publish message {} to topic {}", message, topicARN, e); getErrorCounter(e).increment(); return Optional.empty(); } }
Example #13
Source File: SnsTopicResourceTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldPublish_withSubjectAndMessage() { // Given final String subject = randomString(); final String message = randomString(); // When snsTopicResource.publish(subject, message); // Then final ArgumentCaptor<PublishRequest> captor = ArgumentCaptor.forClass(PublishRequest.class); verify(mockAmazonSnsClient).publish(captor.capture()); final PublishRequest publishRequest = captor.getValue(); assertEquals(topicArn, publishRequest.getTopicArn()); assertEquals(subject, publishRequest.getSubject()); assertEquals(message, publishRequest.getMessage()); assertEquals(subject, publishRequest.getMessageAttributes().get("subject").getStringValue()); assertEquals("String", publishRequest.getMessageAttributes().get("subject").getDataType()); }
Example #14
Source File: PushSnsService.java From oxAuth with MIT License | 6 votes |
public PublishResult sendPushMessage(AmazonSNS snsClient, PushPlatform platform, String targetArn, String message, Map<String, MessageAttributeValue> messageAttributes) throws IOException { Map<String, String> messageMap = new HashMap<String, String>(); messageMap.put(platform.name(), message); message = ServerUtil.asJson(messageMap); PublishRequest publishRequest = new PublishRequest(); publishRequest.setMessageStructure("json"); if (messageAttributes != null) { publishRequest.setMessageAttributes(messageAttributes); } publishRequest.setTargetArn(targetArn); publishRequest.setMessage(message); PublishResult publishResult = snsClient.publish(publishRequest); return publishResult; }
Example #15
Source File: NotificationMessagingTemplateTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void send_validTextMessage_usesTopicChannel() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate( amazonSns); String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test"; when(amazonSns.listTopics(new ListTopicsRequest(null))) .thenReturn(new ListTopicsResult() .withTopics(new Topic().withTopicArn(physicalTopicName))); notificationMessagingTemplate.setDefaultDestinationName(physicalTopicName); // Act notificationMessagingTemplate .send(MessageBuilder.withPayload("Message content").build()); // Assert verify(amazonSns) .publish(new PublishRequest(physicalTopicName, "Message content", null) .withMessageAttributes(isNotNull())); }
Example #16
Source File: NotificationMessagingTemplateTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void send_validTextMessageWithCustomDestinationResolver_usesTopicChannel() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate( amazonSns, (DestinationResolver<String>) name -> name.toUpperCase(Locale.ENGLISH), null); // Act notificationMessagingTemplate.send("test", MessageBuilder.withPayload("Message content").build()); // Assert verify(amazonSns).publish(new PublishRequest("TEST", "Message content", null) .withMessageAttributes(isNotNull())); }
Example #17
Source File: NotificationMessagingTemplateTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void convertAndSend_withDestinationPayloadAndSubject_shouldSetSubject() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate( amazonSns); String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test"; when(amazonSns.listTopics(new ListTopicsRequest(null))) .thenReturn(new ListTopicsResult() .withTopics(new Topic().withTopicArn(physicalTopicName))); // Act notificationMessagingTemplate.sendNotification(physicalTopicName, "My message", "My subject"); // Assert verify(amazonSns) .publish(new PublishRequest(physicalTopicName, "My message", "My subject") .withMessageAttributes(isNotNull())); }
Example #18
Source File: NotificationMessagingTemplateTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void convertAndSend_withPayloadAndSubject_shouldSetSubject() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate( amazonSns); String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test"; when(amazonSns.listTopics(new ListTopicsRequest(null))) .thenReturn(new ListTopicsResult() .withTopics(new Topic().withTopicArn(physicalTopicName))); notificationMessagingTemplate.setDefaultDestinationName(physicalTopicName); // Act notificationMessagingTemplate.sendNotification("My message", "My subject"); // Assert verify(amazonSns) .publish(new PublishRequest(physicalTopicName, "My message", "My subject") .withMessageAttributes(isNotNull())); }
Example #19
Source File: TopicMessageChannelTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void sendMessage_validTextMessageAndSubject_returnsTrue() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); Message<String> stringMessage = MessageBuilder.withPayload("Message content") .setHeader(TopicMessageChannel.NOTIFICATION_SUBJECT_HEADER, "Subject") .build(); MessageChannel messageChannel = new TopicMessageChannel(amazonSns, "topicArn"); // Act boolean sent = messageChannel.send(stringMessage); // Assert verify(amazonSns, only()) .publish(new PublishRequest("topicArn", "Message content", "Subject") .withMessageAttributes(isNotNull())); assertThat(sent).isTrue(); }
Example #20
Source File: SnsTopicResourceTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldThrowException_onAmazonClientExceptionFromPublish() { // Given final String subject = randomString(); final String message = randomString(); when(mockAmazonSnsClient.publish(any(PublishRequest.class))).thenThrow(AmazonClientException.class); // When AmazonClientException thrownException = null; try { snsTopicResource.publish(subject, message); } catch (final AmazonClientException e) { thrownException = e; } // Then assertNotNull(thrownException); }
Example #21
Source File: TopicMessageChannelTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void sendMessage_validTextMessageWithoutSubject_returnsTrue() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); Message<String> stringMessage = MessageBuilder.withPayload("Message content") .build(); MessageChannel messageChannel = new TopicMessageChannel(amazonSns, "topicArn"); // Act boolean sent = messageChannel.send(stringMessage); // Assert verify(amazonSns, only()) .publish(new PublishRequest("topicArn", "Message content", null) .withMessageAttributes(isNotNull())); assertThat(sent).isTrue(); }
Example #22
Source File: TopicMessageChannelTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void sendMessage_validTextMessageAndTimeout_timeoutIsIgnored() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); Message<String> stringMessage = MessageBuilder.withPayload("Message content") .build(); MessageChannel messageChannel = new TopicMessageChannel(amazonSns, "topicArn"); // Act boolean sent = messageChannel.send(stringMessage, 10); // Assert verify(amazonSns, only()) .publish(new PublishRequest("topicArn", "Message content", null) .withMessageAttributes(isNotNull())); assertThat(sent).isTrue(); }
Example #23
Source File: TopicMessageChannelTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void sendMessage_withUuidAsId_shouldConvertUuidToString() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); TopicMessageChannel messageChannel = new TopicMessageChannel(amazonSns, "http://testQueue"); Message<String> message = MessageBuilder.withPayload("Hello").build(); UUID uuid = (UUID) message.getHeaders().get(MessageHeaders.ID); ArgumentCaptor<PublishRequest> sendMessageRequestArgumentCaptor = ArgumentCaptor .forClass(PublishRequest.class); when(amazonSns.publish(sendMessageRequestArgumentCaptor.capture())) .thenReturn(new PublishResult()); // Act boolean sent = messageChannel.send(message); // Assert assertThat(sent).isTrue(); assertThat(sendMessageRequestArgumentCaptor.getValue().getMessageAttributes() .get(MessageHeaders.ID).getStringValue()).isEqualTo(uuid.toString()); }
Example #24
Source File: PlatformEndpointIntegrationTest.java From aws-sdk-java-resources with Apache License 2.0 | 6 votes |
@Test @Ignore public void testActions() { // setAttribtues String userData = UUID.randomUUID().toString(); endpoint.setAttributes(new SetEndpointAttributesRequest() .addAttributesEntry("CustomUserData", userData) ); refreshEndpoint(); Assert.assertEquals(userData, endpoint.getAttributes().get("CustomUserData")); // publish endpoint.publish(new PublishRequest() .withSubject("subject") .withMessage("message") ); }
Example #25
Source File: SnsWebhookManager.java From Singularity with Apache License 2.0 | 6 votes |
<T> CompletableFuture<Void> publish(WebhookType type, T content) { try { return CompletableFuture.runAsync( () -> { try { PublishRequest publishRequest = new PublishRequest( getOrCreateSnsTopic(type), objectMapper.writeValueAsString(content) ); PublishResult result = snsClient.publish(publishRequest); LOG.trace("Sent update {} with messageId {}", content, result.getMessageId()); } catch (IOException ioe) { throw new RuntimeException(ioe); } }, publishExecutor ); } catch (Throwable t) { CompletableFuture<Void> f = new CompletableFuture<>(); f.completeExceptionally(t); return f; } }
Example #26
Source File: SnsMessageBroker.java From xyz-hub with Apache License 2.0 | 6 votes |
@Override public void sendRawMessage(String message) { if (SNS_CLIENT == null) { logger.warn("The AdminMessage can not be sent as the MessageBroker is not ready. Message was: {}", message); return; } if (message.length() > MAX_MESSAGE_SIZE) { throw new RuntimeException("AdminMessage is larger than the MAX_MESSAGE_SIZE. Can not send it."); } //Send using SNS client SNS_CLIENT.publishAsync(TOPIC_ARN, message, new AsyncHandler<PublishRequest, PublishResult>() { @Override public void onError(Exception exception) { logger.error("Error sending message: {}", message, exception); } @Override public void onSuccess(PublishRequest request, PublishResult publishResult) { logger.debug("Message has been sent with following content: {}", message); } }); }
Example #27
Source File: TopicMessageChannelTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void sendMessage_withBinaryMessageHeader_shouldBeSentAsBinaryMessageAttribute() throws Exception { // Arrange AmazonSNS amazonSns = mock(AmazonSNS.class); ArgumentCaptor<PublishRequest> publishRequestArgumentCaptor = ArgumentCaptor .forClass(PublishRequest.class); when(amazonSns.publish(publishRequestArgumentCaptor.capture())) .thenReturn(new PublishResult()); ByteBuffer headerValue = ByteBuffer.wrap("My binary data!".getBytes()); String headerName = "MyHeader"; Message<String> message = MessageBuilder.withPayload("Hello") .setHeader(headerName, headerValue).build(); MessageChannel messageChannel = new TopicMessageChannel(amazonSns, "topicArn"); // Act boolean sent = messageChannel.send(message); // Assert assertThat(sent).isTrue(); assertThat(publishRequestArgumentCaptor.getValue().getMessageAttributes() .get(headerName).getBinaryValue()).isEqualTo(headerValue); assertThat(publishRequestArgumentCaptor.getValue().getMessageAttributes() .get(headerName).getDataType()) .isEqualTo(MessageAttributeDataTypes.BINARY); }
Example #28
Source File: PlatformEndpointImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public PublishResult publish(PublishRequest request, ResultCapture<PublishResult> extractor) { ActionResult result = resource.performAction("Publish", request, extractor); if (result == null) return null; return (PublishResult) result.getData(); }
Example #29
Source File: SnsListenerTest.java From circus-train with Apache License 2.0 | 5 votes |
@Test public void successPartitionedTable() { SnsListener listener = new SnsListener(client, config, clock); listener.circusTrainStartUp(new String[] {}, sourceCatalog, replicaCatalog); listener.tableReplicationStart(tableReplication, EVENT_ID); EventPartitions alteredPartitions = new EventPartitions(partitionKeyTypes); alteredPartitions.add(PARTITION_0); listener.partitionsToAlter(alteredPartitions); EventPartitions createdPartitions = new EventPartitions(partitionKeyTypes); createdPartitions.add(PARTITION_1); listener.partitionsToCreate(createdPartitions); listener.copierEnd(metrics); listener.tableReplicationSuccess(tableReplication, EVENT_ID); verify(client, times(2)).publish(requestCaptor.capture()); PublishRequest request = requestCaptor.getAllValues().get(1); assertThat(request.getSubject(), is(SUBJECT)); assertThat(request.getTopicArn(), is("successArn")); assertThat(request.getMessage(), is("{\"protocolVersion\":\"" + PROTOCOL_VERSION + "\"" + ",\"type\":\"SUCCESS\",\"headers\":{\"pipeline-id\":\"0943879438\"}," + "\"startTime\":\"starttime\",\"endTime\":\"endtime\",\"eventId\":\"EVENT_ID\",\"sourceCatalog\"" + ":\"sourceCatalogName\",\"replicaCatalog\":\"replicaCatalogName\",\"sourceTable\":" + "\"srcDb.srcTable\",\"replicaTable\":\"replicaDb.replicaTable\"," + "\"replicaTableLocation\":\"" + REPLICA_TABLE_LOCATION + "\",\"replicaMetastoreUris\":\"" + REPLICA_METASTORE_URIS + "\",\"partitionKeys\":{\"local_date\":\"string\",\"local_hour\":\"int\"}," + "\"modifiedPartitions\":" + "[[\"2014-01-01\",\"0\"],[\"2014-01-01\",\"1\"]],\"bytesReplicated\":40}")); }
Example #30
Source File: TopicImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public PublishResult publish(PublishRequest request, ResultCapture<PublishResult> extractor) { ActionResult result = resource.performAction("Publish", request, extractor); if (result == null) return null; return (PublishResult) result.getData(); }