Class Messaging

java.lang.Object
com.codename1.backend.messaging.Messaging

public final class Messaging extends Object

Opens the MessageTransport a configuration names, and finds the one of the calling thread's server.

Setting Default
cn1.messaging.url see below memory:, db:, redis://..., amqp://..., kafka://..., sqs://..., pubsub://...
cn1.messaging.lease 60000 milliseconds before a message a consumer took and never settled is delivered again
cn1.messaging.timeout 5000 milliseconds a broker connection or reply may take
cn1.messaging.db.poll 500 milliseconds between polls of an empty db: queue

The retry settings are RetryPolicy's. Without cn1.messaging.url, Spring Boot's spring.rabbitmq.host (or .addresses) selects AMQP and spring.kafka.bootstrap-servers Kafka; otherwise a server with a data source queues in its database and one without queues in memory.

A broker transport is compiled into an application only when its configuration names it: the build registers that one transport's factory with register(String, Messaging.TransportFactory), so the protocols an application does not use add nothing to its size.

  • Method Details

    • register

      public static void register(String scheme, Messaging.TransportFactory factory)
      Makes scheme (redis, amqp, kafka, ...) open through factory. Called by the generated wiring, never by application code.
    • bindDataSource

      public static void bindDataSource(DataSource dataSource) throws IOException
      Gives the calling thread's server's transport its data source: the db: queue and the outbox live there. Called by the generated wiring before any bean can send.
      Throws:
      IOException
    • current

      public static MessageTransport current() throws IOException
      The transport of the calling thread's server: opened from its configuration the first time it is asked for, closed when the server stops.
      Throws:
      IOException
    • group

      public static String group(Config config, String declared) throws IOException
      The consumer group a listener declared, or -- when it declared none -- the application's name (spring.application.name, then cn1.application.name), or default.
      Throws:
      IOException
    • url

      public static String url(Config config) throws IOException
      The URL config names, or null when it names none.
      Throws:
      IOException
    • open

      public static MessageTransport open(Config config, DataSource dataSource) throws IOException

      Opens the transport config names; the caller closes it.

      • dataSource: the server's, or null; where db: queues and where an outbox is kept
      Throws:
      IOException