Class JmsProducer<T>
java.lang.Object
io.micronaut.jms.templates.JmsProducer<T>
- Type Parameters:
T- the message type
Helper class that sends messages, configuring JMS connections, sessions,
etc. for you.
TODO rename, too similar to JMSProducer
- Since:
- 1.0.0
- Author:
- Elliott Pope
-
Constructor Summary
ConstructorsConstructorDescriptionJmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer) JmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer, boolean sessionTransacted, int sessionAcknowledgeMode) JmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer, boolean sessionTransacted, int sessionAcknowledgeMode, @Nullable ProducerSessionPool sessionPool) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddObservers(Collection<? extends JMSMessageObserver> observers) voidsend(@NonNull jakarta.jms.Destination destination, @NonNull jakarta.jms.Message message, @NonNull long timeToLive, MessageHeader... headers) Sends the givenmessageto thedestinationwith the givenheaders.voidsend(@NonNull String destination, @NonNull T body, @NonNull long timeToLive, MessageHeader... headers) Creates aMessagefrom thebodyand sends it to thedestinationwith theheaders.voidsend(@NonNull String destination, @NonNull T body, @NonNull JMSDeliveryMode deliveryMode, int priority, long timeToLive, MessageHeader... headers) Sends a message, serializing the body, with a delivery mode and priority.voidsend(@NonNull String destination, @NonNull jakarta.jms.Message message, @NonNull long timeToLive, MessageHeader... headers) Sends the givenmessageto thedestinationwith the givenheaders.toString()
-
Constructor Details
-
JmsProducer
public JmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer) -
JmsProducer
public JmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer, boolean sessionTransacted, int sessionAcknowledgeMode) -
JmsProducer
public JmsProducer(JMSDestinationType type, JMSConnectionPool connectionPool, Serializer serializer, boolean sessionTransacted, int sessionAcknowledgeMode, @Nullable ProducerSessionPool sessionPool) - Parameters:
type- The type of the destinationsconnectionPool- The connection pool, used for each send when there is no session poolserializer- The serializer of message bodiessessionTransacted- Whether the session is transacted, and committed after each sendsessionAcknowledgeMode- The acknowledge mode of the sessionsessionPool- The pool of sessions to send with, ornullto open a connection and a session for each send- Since:
- 5.2.0
-
-
Method Details
-
send
public void send(@NonNull String destination, @NonNull T body, @NonNull long timeToLive, MessageHeader... headers) Creates aMessagefrom thebodyand sends it to thedestinationwith theheaders.- Parameters:
destination- the queue or topic namebody- the bodytimeToLive- time to live parameter in millisecondsheaders- optional headers
-
send
public void send(@NonNull String destination, @NonNull T body, @NonNull JMSDeliveryMode deliveryMode, int priority, long timeToLive, MessageHeader... headers) Sends a message, serializing the body, with a delivery mode and priority.- Parameters:
destination- the destination namebody- the message bodydeliveryMode- the delivery modepriority- the priority, from 0 (lowest) to 9timeToLive- the time to live in milliseconds, or 0 for unlimitedheaders- the headers- Since:
- 5.2.0
-
send
public void send(@NonNull String destination, @NonNull jakarta.jms.Message message, @NonNull long timeToLive, MessageHeader... headers) Sends the givenmessageto thedestinationwith the givenheaders.- Parameters:
destination- the queue or topic namemessage- the messagetimeToLive- time to live parameter in millisecondsheaders- optional headers
-
send
public void send(@NonNull jakarta.jms.Destination destination, @NonNull jakarta.jms.Message message, @NonNull long timeToLive, MessageHeader... headers) Sends the givenmessageto thedestinationwith the givenheaders.- Parameters:
destination- the queue or topic namemessage- the messagetimeToLive- time to live parameter in millisecondsheaders- optional headers
-
addObservers
- Parameters:
observers- The observers of the messages that this producer sends. They are called inOrdered.getOrder()order before the connection of each send is taken.- Since:
- 5.2.0
-
toString
-