Jakarta EE

JMSContext

Create a producer and send a text message to a destination. Jakarta EE 11; source-reviewed companion or illustrative file, NOT RUN.

Formal Syntax & Structure

java syntaxjava
context.createProducer().send(queue,eventId)

Working Example

Example Snippetjava
package example.messaging;import jakarta.annotation.Resource;import jakarta.enterprise.context.ApplicationScoped;import jakarta.inject.Inject;import jakarta.jms.*;@ApplicationScopedpublic class NoticeSender {    @Inject @JMSConnectionFactory("java:comp/env/jms/CatalogFactory") JMSContext context;    @Resource(lookup="java:comp/env/jms/CatalogQueue") Queue queue;    public void send(String eventId){context.createProducer().send(queue,eventId);}}
Java Reference