Class HttpClientStatusEventBus

java.lang.Object
com.predic8.membrane.core.transport.http.HttpClientStatusEventBus

public class HttpClientStatusEventBus extends Object
Event bus for outcomes of the HttpClient.

Because the HttpClient is smart (does internal auto-retry and destination switching), just looking at the result is not always enough. To be informed about what's going on with each individual destination, this event bus can be used.

How to use: HttpClientStatusEventBus.getService().registerListener(new HttpClientStatusEventListener() {});

The HttpClient then calls methods in here, including reportResponse(java.lang.String, int), which goes through to your event listener as HttpClientStatusEventListener.onResponse(long, java.lang.String, int).

  • Field Details

  • Constructor Details

    • HttpClientStatusEventBus

      public HttpClientStatusEventBus()
  • Method Details

    • registerListener

      public void registerListener(HttpClientStatusEventListener listener)
      Adds a listener to be informed about events. The listener is added at the end of the list, thus being called after already registered ones.
      Throws:
      IllegalStateException - if the method detects that the listener is registered already. Except for a tiny small time frame because the operations are not atomic, it will be detected. If not, you end up having it registered twice.
    • reportResponse

      public void reportResponse(String destination, int responseCode)
    • reportException

      public void reportException(String destination, Exception exception)
      Parameters:
      destination -