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
ConstructorsConstructorDescriptionJmsMessageConsumer(jakarta.jms.MessageConsumer consumer) Creates an instance of aJmsMessageConsumerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()jakarta.jms.MessageConsumes a message in a sync wait.voidvoidconsume(Long maximumWaitTime, org.mule.runtime.api.scheduler.Scheduler scheduler, jakarta.jms.CompletionListener completionListener) Consumes a message in a async wait.jakarta.jms.MessageConsumerconsumer()Returns the value of theconsumerrecord component.final booleanIndicates whether some other object is "equal to" this one.jakarta.jms.MessageConsumerget()final inthashCode()Returns a hash code value for this object.voidlisten(jakarta.jms.MessageListener listener) Sets theMessageConsumermessage listener.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
JmsMessageConsumer
public JmsMessageConsumer(jakarta.jms.MessageConsumer consumer) Creates an instance of aJmsMessageConsumerrecord class.- Parameters:
consumer- the value for theconsumerrecord component
-
-
Method Details
-
listen
public void listen(jakarta.jms.MessageListener listener) throws jakarta.jms.JMSException Sets theMessageConsumermessage 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
Messagereceived 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
-
close
public void close() throws jakarta.jms.JMSException- Specified by:
closein interfaceAutoCloseable- 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 givenCompletionListener.- 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
consumer
public jakarta.jms.MessageConsumer consumer()Returns the value of theconsumerrecord component.- Returns:
- the value of the
consumerrecord component
-