Class MessageUtils

java.lang.Object
com.broadleafcommerce.common.messaging.MessageUtils

public final class MessageUtils extends Object
Utility methods useful for creating and working with messages, such as compression and decompression of large payloads.
  • Field Details

  • Method Details

    • decodeAndUncompress

      @NonNull public static List<String> decodeAndUncompress(@Nullable String stringListPayload)
    • compressAndEncode

      @Nullable public static String compressAndEncode(@Nullable List<String> stringList)
    • isLeader

      public static boolean isLeader(Object leader)
      Determines whether the CamelClusterMember representation is the current cluster leader. This method is capable of accepting either Optional<CamelClusterMember> instance, or a CamelClusterMember instance. The former is expected when the Spring Boot version is less than or equal to 3.2. The latter is expected when the Spring Boot version is greater than 3.2.
      Parameters:
      leader - The CamelClusterMember representation to inspect
      Returns:
      Whether the member is the leader
      See Also:
    • createLeadershipListener

      public static org.apache.camel.cluster.CamelClusterEventListener.Leadership createLeadershipListener(Consumer<Boolean> leaderConsumer)
      Create a listener with a different shape depending on the detected Spring Boot version. Spring Boot versions less than or equal to 3.2 will have CamelClusterEventListener.Leadership shape defined in camel 4.5.0. Spring Boot greater than 3.2 will get the shape defined in camel 4.7.0. This complexity is hidden from the implementation. Instead, all that is required is a Consumer that accepts a boolean indicating if the current instance is the leader. The consumer can then perform whatever work is necessary in reaction to the leadership change.
      Parameters:
      leaderConsumer - Consumer that receives a boolean denoting if this instance is currently the leader.
      Returns:
      The instantiated leadership changed listener