use of com.amazonaws.services.kinesis.model.GetRecordsResult in project storm by apache.
the class KinesisConnection method fetchRecords.
GetRecordsResult fetchRecords(String shardIterator) {
GetRecordsRequest getRecordsRequest = new GetRecordsRequest();
getRecordsRequest.setShardIterator(shardIterator);
getRecordsRequest.setLimit(kinesisConnectionInfo.getRecordsLimit());
GetRecordsResult getRecordsResult = kinesisClient.getRecords(getRecordsRequest);
return getRecordsResult;
}
use of com.amazonaws.services.kinesis.model.GetRecordsResult in project camel by apache.
the class KinesisConsumerTest method exchangePropertiesAreSet.
@Test
public void exchangePropertiesAreSet() throws Exception {
String partitionKey = "partitionKey";
String sequenceNumber = "1";
when(kinesisClient.getRecords(any(GetRecordsRequest.class))).thenReturn(new GetRecordsResult().withNextShardIterator("nextShardIterator").withRecords(new Record().withSequenceNumber(sequenceNumber).withApproximateArrivalTimestamp(new Date(42)).withPartitionKey(partitionKey)));
undertest.poll();
final ArgumentCaptor<Exchange> exchangeCaptor = ArgumentCaptor.forClass(Exchange.class);
verify(processor).process(exchangeCaptor.capture(), any(AsyncCallback.class));
assertThat(exchangeCaptor.getValue().getIn().getHeader(KinesisConstants.APPROX_ARRIVAL_TIME, long.class), is(42L));
assertThat(exchangeCaptor.getValue().getIn().getHeader(KinesisConstants.PARTITION_KEY, String.class), is(partitionKey));
assertThat(exchangeCaptor.getValue().getIn().getHeader(KinesisConstants.SEQUENCE_NUMBER, String.class), is(sequenceNumber));
}
use of com.amazonaws.services.kinesis.model.GetRecordsResult in project camel by apache.
the class KinesisConsumerTest method setup.
@Before
public void setup() throws Exception {
KinesisEndpoint endpoint = new KinesisEndpoint(null, "streamName", component);
endpoint.setAmazonKinesisClient(kinesisClient);
endpoint.setIteratorType(ShardIteratorType.LATEST);
undertest = new KinesisConsumer(endpoint, processor);
when(kinesisClient.getRecords(any(GetRecordsRequest.class))).thenReturn(new GetRecordsResult().withNextShardIterator("nextShardIterator"));
when(kinesisClient.describeStream(any(DescribeStreamRequest.class))).thenReturn(new DescribeStreamResult().withStreamDescription(new StreamDescription().withShards(new Shard().withShardId("shardId"))));
when(kinesisClient.getShardIterator(any(GetShardIteratorRequest.class))).thenReturn(new GetShardIteratorResult().withShardIterator("shardIterator"));
}
use of com.amazonaws.services.kinesis.model.GetRecordsResult in project camel by apache.
the class KinesisConsumerTest method recordsAreSentToTheProcessor.
@Test
public void recordsAreSentToTheProcessor() throws Exception {
when(kinesisClient.getRecords(any(GetRecordsRequest.class))).thenReturn(new GetRecordsResult().withNextShardIterator("nextShardIterator").withRecords(new Record().withSequenceNumber("1"), new Record().withSequenceNumber("2")));
int messageCount = undertest.poll();
assertThat(messageCount, is(2));
final ArgumentCaptor<Exchange> exchangeCaptor = ArgumentCaptor.forClass(Exchange.class);
verify(processor, times(2)).process(exchangeCaptor.capture(), any(AsyncCallback.class));
assertThat(exchangeCaptor.getAllValues().get(0).getIn().getBody(Record.class).getSequenceNumber(), is("1"));
assertThat(exchangeCaptor.getAllValues().get(1).getIn().getBody(Record.class).getSequenceNumber(), is("2"));
}
Aggregations