Class JmsSourceBuilder
- java.lang.Object
-
- com.hazelcast.jet.pipeline.JmsSourceBuilder
-
public final class JmsSourceBuilder extends java.lang.Object
SeeSources.jmsQueueBuilder(com.hazelcast.function.SupplierEx<? extends jakarta.jms.ConnectionFactory>)
orSources.jmsTopicBuilder(com.hazelcast.function.SupplierEx<? extends jakarta.jms.ConnectionFactory>)
.- Since:
- Jet 3.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamSource<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
.JmsSourceBuilder
connectionFn(FunctionEx<? super jakarta.jms.ConnectionFactory,? extends jakarta.jms.Connection> connectionFn)
Sets the function which creates the connection using the connection factory.JmsSourceBuilder
connectionParams(java.lang.String username, java.lang.String password)
Sets the connection parameters.JmsSourceBuilder
consumerFn(FunctionEx<? super jakarta.jms.Session,? extends jakarta.jms.MessageConsumer> consumerFn)
Sets the function which creates the message consumer from session.JmsSourceBuilder
destinationName(java.lang.String destinationName)
Sets the name of the destination (name of the topic or queue).JmsSourceBuilder
maxGuarantee(ProcessingGuarantee guarantee)
Sets the maximum processing guarantee for the source.JmsSourceBuilder
messageIdFn(FunctionEx<? super jakarta.jms.Message,?> messageIdFn)
Configures the function to extract IDs from the messages, if exactly-once guarantee is used.JmsSourceBuilder
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 Detail
-
connectionParams
@Nonnull public JmsSourceBuilder connectionParams(@Nullable java.lang.String username, @Nullable java.lang.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
@Nonnull public JmsSourceBuilder destinationName(@Nullable java.lang.String 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
@Nonnull public JmsSourceBuilder maxGuarantee(@Nonnull ProcessingGuarantee guarantee)
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
-
sharedConsumer
@Nonnull public JmsSourceBuilder 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)
.If the consumer is not shared, only a single processor on a single member will connect to the broker to receive the messages. If you set this parameter to
true
for a non-shared consumer, all messages will be emitted on every member, leading to duplicate processing.A consumer for a queue is always assumed to be shared, regardless of this setting.
The default value is
false
.- 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
@Nonnull public StreamSource<jakarta.jms.Message> build()
Convenience forbuild(FunctionEx)
.
-
-