Class JmsSourceBuilder
Sources.jmsQueueBuilder(com.hazelcast.function.SupplierEx<? extends jakarta.jms.ConnectionFactory>)
or Sources.jmsTopicBuilder(com.hazelcast.function.SupplierEx<? extends jakarta.jms.ConnectionFactory>)
.- Since:
- Jet 3.0
-
Method Summary
Modifier and TypeMethodDescriptionStreamSource<jakarta.jms.Message>
build()
Convenience forbuild(FunctionEx)
.<T> StreamSource<T>
build
(FunctionEx<? super jakarta.jms.Message, ? extends T> projectionFn) Creates and returns the JMSStreamSource
with the supplied components and the projection functionprojectionFn
.connectionFn
(FunctionEx<? super jakarta.jms.ConnectionFactory, ? extends jakarta.jms.Connection> connectionFn) Sets the function which creates the connection using the connection factory.connectionParams
(String username, String password) Sets the connection parameters.consumerFn
(FunctionEx<? super jakarta.jms.Session, ? extends jakarta.jms.MessageConsumer> consumerFn) Sets the function which creates the message consumer from session.destinationName
(String destinationName) Sets the name of the destination (name of the topic or queue).maxGuarantee
(ProcessingGuarantee guarantee) Sets the maximum processing guarantee for the source.messageIdFn
(FunctionEx<? super jakarta.jms.Message, ?> messageIdFn) Configures the function to extract IDs from the messages, if exactly-once guarantee is used.sharedConsumer
(boolean isSharedConsumer) Specifies whether the MessageConsumer of the JMS topic is shared, that is whethercreateSharedConsumer()
orcreateSharedDurableConsumer()
was used to create it in theconsumerFn(FunctionEx)
.
-
Method Details
-
connectionParams
@Nonnull public JmsSourceBuilder connectionParams(@Nullable String username, @Nullable String password) Sets the connection parameters. IfconnectionFn(FunctionEx)
is set, these parameters are ignored.- Returns:
- this instance for fluent API
-
connectionFn
@Nonnull public JmsSourceBuilder connectionFn(@Nullable FunctionEx<? super jakarta.jms.ConnectionFactory, ? extends jakarta.jms.Connection> connectionFn) Sets the function which creates the connection using the connection factory.If not provided, this function is used:
connectionFn = factory -> username != null || password != null ? factory.createConnection(usernameLocal, passwordLocal) : factory.createConnection()
The user name and password set withconnectionParams(java.lang.String, java.lang.String)
are used.The given function must be stateless.
- Returns:
- this instance for fluent API
-
destinationName
Sets the name of the destination (name of the topic or queue). IfconsumerFn(FunctionEx)
is provided, this parameter is ignored.- Returns:
- this instance for fluent API
-
consumerFn
@Nonnull public JmsSourceBuilder consumerFn(@Nullable FunctionEx<? super jakarta.jms.Session, ? extends jakarta.jms.MessageConsumer> consumerFn) Sets the function which creates the message consumer from session.If not provided,
Session#createConsumer(destinationName)
is used to create the consumer. SeedestinationName(String)
.If you're consuming a topic and you create a shared consumer, make sure to also call
sharedConsumer(true)
.The given function must be stateless.
- Returns:
- this instance for fluent API
-
messageIdFn
@Nonnull public JmsSourceBuilder messageIdFn(@Nonnull FunctionEx<? super jakarta.jms.Message, ?> messageIdFn) Configures the function to extract IDs from the messages, if exactly-once guarantee is used. If a lower guarantee is used, this function is not used.Make sure the function returns non-null for every message, or the job will fail. The returned object should also implement
equals()
andhashCode()
methods. If you don't have a unique message ID, reduce the guarantee to at-least-once.The default is to use
Message.getJMSMessageID()
.The given function must be stateless.
- Returns:
- this instance for fluent API
-
maxGuarantee
Sets the maximum processing guarantee for the source. You can use it to reduce the guarantee of this source compared to the job's guarantee. If you configure a stronger guarantee than the job has, the job's guarantee will be used. Use it if you want to avoid the overhead of acknowledging the messages or storing IDs of seen messages, if you can tolerate duplicated or missed messages.If the processing guarantee is NONE, the processor will consume the messages in
Session.DUPS_OK_ACKNOWLEDGE
mode. If the processing guarantee is other than NONE, the processor will acknowledge messages in transactions in the 2nd phase of the snapshot, that is after all downstream stages fully processed the messages. Additionally, if the processing guarantee is EXACTLY_ONCE, the processor will store message IDs of the unacknowledged messages to the snapshot and should the job fail after the snapshot was successful, but before Jet managed to acknowledge the messages. The stored IDs will be used to filter out the re-delivered messages.If you use a non-durable consumer with a topic, the guarantee will not work since the broker doesn't store the messages at all. You can also set the max-guarantee to NONE in this case - the acknowledge operation is ignored anyway. If you didn't specify your own
consumerFn(FunctionEx)
, a non-durable consumer is created for a topic by default.The default is
ProcessingGuarantee.EXACTLY_ONCE
, which means that the source's guarantee will match the job's guarantee.- Returns:
- this instance for fluent API
-
build
@Nonnull public <T> StreamSource<T> build(@Nonnull FunctionEx<? super jakarta.jms.Message, ? extends T> projectionFn) Creates and returns the JMSStreamSource
with the supplied components and the projection functionprojectionFn
.The given function must be stateless.
- Type Parameters:
T
- the type of the items the source emits- Parameters:
projectionFn
- the function which creates output object from each message
-
build
Convenience forbuild(FunctionEx)
.
-