Class NakadiClient
-
Method Summary
Modifier and TypeMethodDescriptionstatic NakadiClientBuilderReturns a new Builder that will make use of the givenRequestFactory.voiddeleteSubscription(String subscriptionId) Delete subscription based on subscription ID.getPartitions(String eventName) Resolves a list of partitions for the given eventName.<T> voidWrites the given events to the endpoint provided by the eventName.stream(Subscription subscription) Deprecated.subscription(String applicationName, String eventName) Build a subscription for a single event type.subscription(String applicationName, Set<String> eventNames) Build a subscription for multiple event types.
-
Method Details
-
builder
public static NakadiClientBuilder builder(URI baseUri, org.zalando.fahrschein.http.api.RequestFactory requestFactory) Returns a new Builder that will make use of the givenRequestFactory.- Parameters:
baseUri- that we will send requests torequestFactory- that we use for the execution of our HTTP Requests.- Returns:
- A builder to initialize the client. Can be further modified later.
-
getPartitions
Resolves a list of partitions for the given eventName.- Parameters:
eventName- that we want to resolve the partitions for.- Returns:
List<Partition>ornullin- Throws:
IOException- in case of network issues.
-
publish
public <T> void publish(String eventName, List<T> events) throws EventPublishingException, IOException Writes the given events to the endpoint provided by the eventName.In case of a partial success (or also in cases like validation errors, which are complete failures), Fahrschein will throw an
EventPublishingExceptionwith theBatchItemResponses (as returned from Nakadi) for the failed items in the responses property. These objects have the eid of the failed event, a publishingStatus (failed/aborted/submitted - but successful items are filtered out), the step where it failed and a detail string. If the application sets the eids itself (i.e. doesn't let Nakadi do it) and keeps track of them, this allows it to resend only the failed items later. It also allows differentiating between validation errors, which likely don't need to be retried, as they are unlikely to succeed the next time, unless the event type definition is changed, and publishing errors which should be retried with some back-off.Recommendation: Implement a retry-with-backoff handler for
EventPublishingExceptions, which, depending on your ordering consistency requirements, either retries the full batch, or retries the failed events based on the event-ids.- Type Parameters:
T- Type of the Event- Parameters:
eventName- where the event should be written toevents- that should be written- Throws:
IOException- in case we fail to reach NakadiEventPublishingException- In case Nakadi returns an Erroneous response
-
subscribe
@Deprecated public Subscription subscribe(String applicationName, String eventName, String consumerGroup) throws IOException Deprecated.Use theSubscriptionBuilderandsubscription(String, String)instead.Create a subscription for a single event type.- Throws:
IOException
-
subscription
public SubscriptionBuilder subscription(String applicationName, String eventName) throws IOException Build a subscription for a single event type.- Throws:
IOException
-
subscription
public SubscriptionBuilder subscription(String applicationName, Set<String> eventNames) throws IOException Build a subscription for multiple event types.- Throws:
IOException
-
deleteSubscription
Delete subscription based on subscription ID.- Throws:
IOException
-
stream
-
stream
-
SubscriptionBuilderandsubscription(String, String)instead.