Creating a Stream

Use the following steps to create your Kinesis stream.

Create the Kinesis Streams Client

Before you can work with Kinesis streams you must instantiate a client object. The
following Java code creates the Kinesis Streams client and sets the endpoint information
for
the client. This overload of setEndpoint also includes the service name
and region. Set serviceName to kinesis.

Create the Stream

Now that you have created your Kinesis Streams client, you can create a stream to
work with,
which you can accomplish with the Kinesis Streams console, or programmatically. To
create a
stream programmatically, instantiate a CreateStreamRequest object and
specify a name for the stream and the number of shards for the stream to use.

The stream name identifies the stream. The name is scoped to the AWS account used
by the application. It is also scoped by region. That is, two streams in two
different AWS accounts can have the same name, and two streams in the same AWS
account but in two different regions can have the same name, but not two streams on
the same account and in the same region.

The throughput of the stream is a function of the number of shards; more shards
are required for greater provisioned throughput. More shards also increase the cost
that AWS charges for the stream. For more information, about calculating an
appropriate number of shards for your application, see Determining the Initial Size of an
Kinesis Stream.

After the createStreamRequest object is configured, create a stream
by calling the createStream method on the client. After calling
createStream, wait for the stream to reach the ACTIVE
state before performing any operations on the stream. To check the state of the
stream, call the describeStream method. However,
describeStream throws an exception if the stream does not exist.
Therefore, enclose the describeStream call in a try/catch
block.