Class EventBusMessage

java.lang.Object
com.iohao.net.framework.communication.eventbus.EventBusMessage

public final class EventBusMessage extends Object
Event message carrying the event source data, topic, routing info, and fire type flags for the EventBus system.
Since:
21
Author:
渔民小镇
date:
2023-12-24
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    byte[]
    Serialized event source data for cross-process transmission.
    Remote server messages from other processes that have matching subscribers.
    The deserialized event source object (local only, not serialized).
    int
    Bitmask of fire types that have been applied to this message.
    int
    The target server ID this message is destined for.
    int
    The server ID of the EventBus that originally published this event.
    long
    Thread index used for executor selection in thread-safe strategies.
    The event topic, typically the fully qualified class name of the event source.
    Trace ID for distributed tracing and debugging.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFireType(int fireType)
    Adds the type of subscriber that has already been triggered
    boolean
    containsFireType(int fireType)
    Checks if the type of subscriber that has already been triggered exists
    boolean
    Check if no fire type flags have been set.
    ofClone(int serverId)
    Create a shallow clone of this message targeting a different server ID.
    void
    setEventSource(Object eventSource)
    Set the event source and auto-derive the topic from its class name.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serverId

      public int serverId
      The target server ID this message is destined for.
    • threadIndex

      public long threadIndex
      Thread index used for executor selection in thread-safe strategies.
    • traceId

      public String traceId
      Trace ID for distributed tracing and debugging.
    • topic

      public String topic
      The event topic, typically the fully qualified class name of the event source.
    • data

      public byte[] data
      Serialized event source data for cross-process transmission.
    • sourceServerId

      public transient int sourceServerId
      The server ID of the EventBus that originally published this event.
    • eventSource

      public transient Object eventSource
      The deserialized event source object (local only, not serialized).
    • eventServerMessages

      public transient Collection<EventServerMessage> eventServerMessages
      Remote server messages from other processes that have matching subscribers.
    • fireType

      public transient int fireType
      Bitmask of fire types that have been applied to this message.
  • Constructor Details

    • EventBusMessage

      public EventBusMessage()
  • Method Details

    • setEventSource

      public void setEventSource(Object eventSource)
      Set the event source and auto-derive the topic from its class name.
      Parameters:
      eventSource - the event source object
    • containsFireType

      public boolean containsFireType(int fireType)
      Checks if the type of subscriber that has already been triggered exists
      Parameters:
      fireType - EventBusFireType
      Returns:
      true if it exists
      See Also:
    • addFireType

      public void addFireType(int fireType)
      Adds the type of subscriber that has already been triggered
      Parameters:
      fireType - EventBusFireType
      See Also:
    • emptyFireType

      public boolean emptyFireType()
      Check if no fire type flags have been set.
      Returns:
      true if no fire type has been applied
    • ofClone

      public EventBusMessage ofClone(int serverId)
      Create a shallow clone of this message targeting a different server ID.
      Parameters:
      serverId - the target server ID for the cloned message
      Returns:
      a new EventBusMessage with the same data but a different server ID