Package org.apache.activemq.artemis.api.core

## Interface BroadcastEndpoint

- All Known Implementing Classes:
    `JGroupsBroadcastEndpoint`, `JGroupsChannelBroadcastEndpoint`, `JGroupsFileBroadcastEndpoint`

      public interface BroadcastEndpoint

  BroadcastEndpint is used in BroadcastGroups and DiscoveryGroups for topology updates.

  A BroadcastEndpoint can perform one of the two following tasks:

  - when being used in BroadcastGroups, it broadcasts connector informations
  - when being used in DiscoveryGroups, it receives broadcasts

  The two tasks are mutual exclusive, meaning a BroadcastEndpoint can either be a broadcaster or a receiver, but not both.

  It is an abstraction of various concrete broadcasting mechanisms. Different implementations of this interface may use different broadcasting techniques like UDP multicasting or JGroups channels.

  See Also:
    `JGroupsBroadcastEndpoint`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `broadcast​(byte[] data)` | Broadcasting data to the cluster.
    `void` | `close​(boolean isBroadcast)` | Close the endpoint.
    `void` | `openBroadcaster()` | This method initializes a BroadcastEndpint as a broadcaster.
    `void` | `openClient()` | This method initializes a BroadcastEndpoint as a receiving end for broadcasts.
    `byte[]` | `receiveBroadcast()` | Receives the broadcast data.
    `byte[]` | `receiveBroadcast​(long time, java.util.concurrent.TimeUnit unit)` | Receives the broadcast data with a timeout.

- - ### Method Detail

    - #### openClient

          void openClient()
                   throws java.lang.Exception

      This method initializes a BroadcastEndpoint as a receiving end for broadcasts. After that data can be received using one of its receiveBroadcast() methods.
      Throws:
        `java.lang.Exception`

    - #### openBroadcaster

          void openBroadcaster()
                        throws java.lang.Exception

      This method initializes a BroadcastEndpint as a broadcaster. After that data can be sent via its broadcast() method.
      Throws:
        `java.lang.Exception`

    - #### close

          void close​(boolean isBroadcast)
              throws java.lang.Exception

      Close the endpoint. Any related resources should be cleaned up in this method.
      Parameters:
        `isBroadcast` - : indicates whether this endpoint serves as a broadcast or not.
      Throws:
        `java.lang.Exception`

    - #### broadcast

          void broadcast​(byte[] data)
                  throws java.lang.Exception

      Broadcasting data to the cluster.
      Parameters:
        `data` - : a byte array containing the data.
      Throws:
        `java.lang.Exception`

    - #### receiveBroadcast

          byte[] receiveBroadcast()
                           throws java.lang.Exception

      Receives the broadcast data. It blocks until data is available.
      Returns:
        the received data as byte array.
      Throws:
        `java.lang.Exception`

    - #### receiveBroadcast

          byte[] receiveBroadcast​(long time,
                                  java.util.concurrent.TimeUnit unit)
                           throws java.lang.Exception

      Receives the broadcast data with a timeout. It blocks until either the data is available or the timeout is reached, whichever comes first.
      Parameters:
        `time` - : how long the method should wait for the data to arrive.
        `unit` - : unit of the time.
      Returns:
        a byte array if data is arrived within the timeout, or null if no data is available after the timeout.
      Throws:
        `java.lang.Exception`