Class JmsProducer<T>

java.lang.Object
io.micronaut.jms.templates.JmsProducer<T>
Type Parameters:
T - the message type

public class JmsProducer<T> extends Object
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 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 destinations
      connectionPool - The connection pool, used for each send when there is no session pool
      serializer - The serializer of message bodies
      sessionTransacted - Whether the session is transacted, and committed after each send
      sessionAcknowledgeMode - The acknowledge mode of the session
      sessionPool - The pool of sessions to send with, or null to 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 a Message from the body and sends it to the destination with the headers.
      Parameters:
      destination - the queue or topic name
      body - the body
      timeToLive - time to live parameter in milliseconds
      headers - 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 name
      body - the message body
      deliveryMode - the delivery mode
      priority - the priority, from 0 (lowest) to 9
      timeToLive - the time to live in milliseconds, or 0 for unlimited
      headers - 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 given message to the destination with the given headers.
      Parameters:
      destination - the queue or topic name
      message - the message
      timeToLive - time to live parameter in milliseconds
      headers - optional headers
    • send

      public void send(@NonNull jakarta.jms.Destination destination, @NonNull jakarta.jms.Message message, @NonNull long timeToLive, MessageHeader... headers)
      Sends the given message to the destination with the given headers.
      Parameters:
      destination - the queue or topic name
      message - the message
      timeToLive - time to live parameter in milliseconds
      headers - optional headers
    • addObservers

      public void addObservers(Collection<? extends JMSMessageObserver> observers)
      Parameters:
      observers - The observers of the messages that this producer sends. They are called in Ordered.getOrder() order before the connection of each send is taken.
      Since:
      5.2.0
    • toString

      public String toString()
      Overrides:
      toString in class Object