Interface Emitter<T>

Type Parameters:
T - payload type

@Contract public interface Emitter<T>
Synchronous emitter for a named messaging channel.

Every emission enters the runtime as a MessageBatch. The payload and message methods are singleton-batch conveniences. A method returns only after every required channel output completes successfully. Outputs are invoked sequentially and the first failure is propagated to the caller without invoking remaining outputs. An earlier output may have completed before a later output fails, so retrying can deliver the same message more than once.

A directly created child thread that inherits thread-local state retains the current delivery ancestry until the originating handler returns. Its emissions use nested admission, and emissions back into any channel already on the active delivery path are rejected. Existing executor workers, common-pool tasks, and threads that disable inheritable state cannot retain that ancestry; a handler must not wait for their emission to a channel on its active delivery path.

An emission captures the caller's active Helidon context. The runtime binds that same context while invoking every synchronous processor, route, handler, interceptor, and outgoing connector in the delivery. When the caller has no active context, the runtime creates a fresh context for that delivery.

Java selects the payload, message-envelope, or batch overload from the declared emitter and argument types. When the message overload is selected, a connector-specific Message subtype retains its envelope and native metadata. To emit a Message or MessageBatch object as the payload when a structural overload would otherwise apply, wrap it in an outer message, for example emitter.emit(Message.create(messagePayload)). All overloads reject null; an uncast null literal is ambiguous among the overloads, so null-validation code must use a typed variable or cast.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    emit(Message<? extends T> message)
    Emit a message with metadata.
    void
    emit(MessageBatch<? extends T> batch)
    Emit a batch of messages.
    default void
    emit(T entity)
    Emit a payload-only message.
  • Method Details

    • emit

      default void emit(T entity)
      Emit a payload-only message.

      A successful return means end-to-end delivery to all required outputs completed. A thrown exception means delivery failed or its outcome is indeterminate.

      Parameters:
      entity - non-null payload
      Throws:
      MessagingException - if the target channel does not exist
      NullPointerException - if entity is null
      RuntimeException - if a handler or outgoing connector fails
    • emit

      default void emit(Message<? extends T> message)
      Emit a message with metadata.

      A successful return means end-to-end delivery to all required outputs completed. A thrown exception means delivery failed or its outcome is indeterminate.

      Parameters:
      message - message
      Throws:
      MessagingException - if the target channel does not exist
      NullPointerException - if message is null
      RuntimeException - if a handler or outgoing connector fails
    • emit

      void emit(MessageBatch<? extends T> batch)
      Emit a batch of messages.
      Parameters:
      batch - immutable message batch
      Throws:
      MessagingException - if the target channel does not exist
      NullPointerException - if batch is null
      BatchDeliveryException - if delivery completes partially or its outcome is indeterminate