Producer
Overview
Module
- package:
org.eclipse.dirigible.sdk.messaging - source: messaging/Producer.java
Sends a message into the embedded ActiveMQ broker. sendToQueue(String, String) delivers to a queue (point-to-point — one listener receives the message), sendToTopic(String, String) delivers to a topic (pub/sub — all active subscribers receive the message).
Both methods are non-blocking past the broker's acknowledgement; the broker handles persistence and at-least-once delivery semantics. Pair with a @Listener-annotated class on the receiving side, or with Consumer.receiveFromQueue(String, long) when you want to pull messages synchronously.
Key Features:
- Queue and Topic Support: Two static methods cover the two JMS-style delivery semantics — point-to-point queues and publish-subscribe topics.
- Embedded Broker: Talks to the ActiveMQ broker that ships in-process with every Dirigible runtime — no broker URL, no client configuration.
- Cross-language Interoperability: Every component running on the platform — in any supported language — targets the same embedded broker, so producers and consumers interoperate transparently.
Example Usage:
import org.eclipse.dirigible.sdk.messaging.Producer;
// Point-to-point: a single listener picks up the message.
Producer.sendToQueue("orders.created", "{\"orderId\":42}");
// Publish-subscribe: every active subscriber receives the message.
Producer.sendToTopic("metrics.heartbeat", "{\"ts\":1700000000}");Methods
sendToQueue()
Publishes a message to the named queue. The first listener available on the queue receives it.
javapublic static void sendToQueue(String queue, String message);
Parameter Type Description queueStringLogical name of the queue destination. messageStringMessage payload — typically a JSON-encoded string. Returns
- Type:
void- Description: Returns once the broker has acknowledged receipt. Delivery to the listener happens asynchronously.
sendToTopic()
Publishes a message to the named topic. Every currently subscribed listener receives a copy.
javapublic static void sendToTopic(String topic, String message);
Parameter Type Description topicStringLogical name of the topic destination. messageStringMessage payload — typically a JSON-encoded string. Returns
- Type:
void- Description: Returns once the broker has acknowledged receipt. Each active subscriber receives the message asynchronously.