Class MessageTransport
java.lang.Object
com.codename1.backend.messaging.MessageTransport
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
PollingTransport
A broker connection: what sends messages and runs subscriptions. One per
server, opened by Messaging.current() from the configuration; application
code sends through MessageTemplate and receives through @MessageListener
methods rather than calling this directly.
Delivery is at least once. A handler that returns acknowledges its message;
one that throws has it delivered again after a backoff, and after
cn1.messaging.retry.max-attempts deliveries it goes to the destination's
dead-letter destination, <destination>.dlq, with the failure in its
Message.ERROR header.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Stops every subscription and closes the connection.abstract StringgetName()The scheme this transport was opened for:memory,db,redis,amqp,kafka.booleanWhether the broker answers, for the health endpoint.booleanWhether a send is part of the calling thread's database transaction by itself, so it needs no outbox.abstract voidSendsmessage.abstract Subscriptionsubscribe(String destination, String group, int concurrency, MessageHandler handler) Startsconcurrencyconsumers ofdestinationingroup.
-
Constructor Details
-
MessageTransport
public MessageTransport()
-
-
Method Details
-
getName
The scheme this transport was opened for:memory,db,redis,amqp,kafka. -
send
Sendsmessage. With a database transport inside a transaction the message is written in that transaction and is seen only if it commits.- Throws:
IOException
-
subscribe
public abstract Subscription subscribe(String destination, String group, int concurrency, MessageHandler handler) throws IOException Starts
concurrencyconsumers ofdestinationingroup.group: subscriptions of one group share the messages between them, and each group sees every message -- on a transport with groups (Redis Streams, Kafka, AMQP through one queue per group). Onmemory:anddb:a destination is a queue and every subscription competes for it.
- Throws:
IOException
-
isTransactional
public boolean isTransactional()Whether a send is part of the calling thread's database transaction by itself, so it needs no outbox. -
isHealthy
public boolean isHealthy()Whether the broker answers, for the health endpoint. Never throws. -
close
public abstract void close()Stops every subscription and closes the connection. Never throws.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-