org.apache.activemq.artemis.api.core

## Interface BroadcastEndpoint

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

      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 and 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, TimeUnit unit)` Receives the broadcast data with a timeout.

- - ### Method Detail

    - #### openClient

          void openClient()
                   throws 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:
        `Exception`

    - #### openBroadcaster

          void openBroadcaster()
                        throws Exception

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

    - #### close

          void close(boolean isBroadcast)
              throws 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:
        `Exception`

    - #### broadcast

          void broadcast(byte[] data)
                  throws Exception

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

    - #### receiveBroadcast

          byte[] receiveBroadcast()
                           throws Exception

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

    - #### receiveBroadcast

          byte[] receiveBroadcast(long time,
                                  TimeUnit unit)
                           throws 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:
        `Exception`

Copyright © 2017. All rights reserved.