---
title: Configure the Java SDK event dispatcher
slug: feature-experimentation/docs/configure-event-dispatcher-java
docTags: 
createdAt: 2026-08-05T20:39:54.000Z
---

The Optimizely Feature Experimentation SDKs make HTTP requests for every [decision event or conversion event](docId\:SzVcfUMHk3IKycnEjgjbq) that gets triggered. Each SDK has a built-in **event dispatcher** for handling these events, but you should overriding it based on the specifics of your environment.

The Java SDK has an out-of-the-box asynchronous dispatcher. You should customizing the event dispatcher you use in production to ensure that you queue and send events in a manner that scales to the volumes handled by your application. Customizing the event dispatcher lets you take advantage of features like batching, which makes it easier to handle large event volumes efficiently or to implement retry logic when a request fails. You can build your dispatcher from scratch or start with the provided dispatcher.

The examples show that to customize the event dispatcher, initialize the Optimizely client (or manager) with an event dispatcher instance.

```java
import com.optimizely.ab.Optimizely;
import com.optimizely.ab.event.AsyncEventHandler;
import com.optimizely.ab.event.EventHandler;

/**
 * Creates an async event handler with a max buffer of
 *  20,000 events and a single dispatcher thread
 */
EventHandler eventHandler = new AsyncEventHandler(20000, 1);

// Create an Optimizely client with the default event dispatcher.
// build() does not throw on an invalid datafile; parse errors go to the error handler.
Optimizely optimizelyClient = Optimizely.builder(datafile,
                                                 eventHandler).build();
```

The event dispatcher should implement a `dispatchEvent` method, which takes a single `LogEvent` argument created by the SDK. In this method, you should send a `POST` request to `LogEvent.getEndpointUrl()` using `LogEvent.getBody()` as the body of the request and `{content-type: 'application/json'}` in the headers.

:::hint{type="warning"}
**Important**
If you are using a custom event dispatcher, do not modify the event payload returned from Optimizely. Modifying this payload will alter your results.
:::

Optimizely provides an asynchronous event dispatcher, [optimizely-sdk-httpclient](https://mvnrepository.com/artifact/com.optimizely.ab/core-httpclient-impl), that requires `org.apache.httpcomponents:httpclient:4.5.2` and is parameterized by in-memory queue size and number of dispatch worker threads.

To use your own event dispatcher, implement the `dispatchEvent` method in the [EventHandler](https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/event/EventHandler.java) interface. `dispatchEvent` takes in a [LogEvent](https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/event/LogEvent.java) object containing all of the information needed to dispatch an event to the Optimizely backend. Events should be sent to `LogEvent.getEndpointUrl` as a `POST` request with `LogEvent.getBody` as the payload and `content-type: "application/json"` as the header.
