Package org.apache.ignite.plugin.extensions.communication

## Interface MessageFactory

-     public interface MessageFactory

  Message factory for all communication messages registered using `register(short, Supplier)` method call.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Message` | `create​(short type)` | Creates new message instance of provided type.
    `void` | `register​(short directType, Supplier<Message> supplier)` | Register message factory with given direct type.
    `void` | `register​(short directType, Supplier<Message> supplier, MessageSerializer serializer)` | Register message factory with given direct type.
    `MessageSerializer` | `serializer​(short type)` | Returns `MessageSerializer` for provided type.

- - ### Method Detail

    - #### register

          void register​(short directType,
                        Supplier<Message> supplier)
                 throws IgniteException

      Register message factory with given direct type. All messages must be registered during construction of class which implements this interface. Any invocation of this method after initialization is done must throw `IllegalStateException` exception.
      Parameters:
        `directType` - Direct type.
        `supplier` - Message factory.
      Throws:
        `IgniteException` - In case of attempt to register message with direct type which is already registered.
        `IllegalStateException` - On any invocation of this method when class which implements this interface is alredy constructed.

    - #### register

          void register​(short directType,
                        Supplier<Message> supplier,
                        MessageSerializer serializer)
                 throws IgniteException

      Register message factory with given direct type. All messages must be registered during construction of class which implements this interface. Any invocation of this method after initialization is done must throw `IllegalStateException` exception.
      Parameters:
        `directType` - Direct type.
        `supplier` - Message factory.
        `serializer` - Message serializer.
      Throws:
        `IgniteException` - In case of attempt to register message with direct type which is already registered.
        `IllegalStateException` - On any invocation of this method when class which implements this interface is alredy constructed.

    - #### create

          Message create​(short type)

      Creates new message instance of provided type.
      Parameters:
        `type` - Message type.
      Returns:
        Message instance.

    - #### serializer

          MessageSerializer serializer​(short type)

      Returns `MessageSerializer` for provided type.
      Parameters:
        `type` - Message type.
      Returns:
        Message instance.