Record Class JmsMessageConsumer

java.lang.Object
java.lang.Record
org.mule.jms.commons.internal.consume.JmsMessageConsumer
All Implemented Interfaces:
AutoCloseable

public record JmsMessageConsumer(jakarta.jms.MessageConsumer consumer) extends Record implements AutoCloseable
Wrapper implementation of a JMS MessageConsumer
Since:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    JmsMessageConsumer(jakarta.jms.MessageConsumer consumer)
    Creates an instance of a JmsMessageConsumer record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    jakarta.jms.Message
    consume(Long maximumWaitTime)
    Consumes a message in a sync wait.
    void
    consume(Long maximumWaitTime, jakarta.jms.CompletionListener completionListener)
     
    void
    consume(Long maximumWaitTime, org.mule.runtime.api.scheduler.Scheduler scheduler, jakarta.jms.CompletionListener completionListener)
    Consumes a message in a async wait.
    jakarta.jms.MessageConsumer
    Returns the value of the consumer record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    jakarta.jms.MessageConsumer
    get()
     
    final int
    Returns a hash code value for this object.
    void
    listen(jakarta.jms.MessageListener listener)
    Sets the MessageConsumer message listener.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JmsMessageConsumer

      public JmsMessageConsumer(jakarta.jms.MessageConsumer consumer)
      Creates an instance of a JmsMessageConsumer record class.
      Parameters:
      consumer - the value for the consumer record component
  • Method Details

    • listen

      public void listen(jakarta.jms.MessageListener listener) throws jakarta.jms.JMSException
      Sets the MessageConsumer message listener.
      Parameters:
      listener - the listener to which the messages are to be delivered.
      Throws:
      jakarta.jms.JMSException - - if the JMS provider fails to receive the next message due to some internal error.
    • consume

      public jakarta.jms.Message consume(Long maximumWaitTime) throws jakarta.jms.JMSException, JmsTimeoutException
      Consumes a message in a sync wait.
      Parameters:
      maximumWaitTime - Time to wait, in milliseconds, until a timeout is raised.
      Returns:
      the next Message received by the message consumer, null if the timeout is 0 (message polling).
      Throws:
      jakarta.jms.JMSException - - if the JMS provider fails to receive the next message due to some internal error.
      JmsTimeoutException - - if no message is received within maximumWaitTime.
    • consume

      public void consume(Long maximumWaitTime, jakarta.jms.CompletionListener completionListener)
    • close

      public void close() throws jakarta.jms.JMSException
      Specified by:
      close in interface AutoCloseable
      Throws:
      jakarta.jms.JMSException
    • get

      public jakarta.jms.MessageConsumer get()
    • consume

      public void consume(Long maximumWaitTime, org.mule.runtime.api.scheduler.Scheduler scheduler, jakarta.jms.CompletionListener completionListener)
      Consumes a message in a async wait. The result of the consumption will be communicated to the given CompletionListener.
      Parameters:
      maximumWaitTime - Time to wait, in milliseconds, until a timeout is raised.
      scheduler - Scheduler to create async tasks.
      completionListener - Result callback that will be called once the message is received or a error is raised.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • consumer

      public jakarta.jms.MessageConsumer consumer()
      Returns the value of the consumer record component.
      Returns:
      the value of the consumer record component