public final class JmsSourceBuilder extends Object
Sources.jmsQueueBuilder(com.hazelcast.function.SupplierEx<? extends javax.jms.ConnectionFactory>)
or Sources.jmsTopicBuilder(com.hazelcast.function.SupplierEx<? extends javax.jms.ConnectionFactory>)
.Modifier and Type | Method and Description |
---|---|
StreamSource<javax.jms.Message> |
build()
Convenience for
build(FunctionEx) . |
<T> StreamSource<T> |
build(FunctionEx<? super javax.jms.Message,? extends T> projectionFn)
Creates and returns the JMS
StreamSource with the supplied
components and the projection function projectionFn . |
JmsSourceBuilder |
connectionFn(FunctionEx<? super javax.jms.ConnectionFactory,? extends javax.jms.Connection> connectionFn)
Sets the function which creates the connection using the connection
factory.
|
JmsSourceBuilder |
connectionParams(String username,
String password)
Sets the connection parameters.
|
JmsSourceBuilder |
consumerFn(FunctionEx<? super javax.jms.Session,? extends javax.jms.MessageConsumer> consumerFn)
Sets the function which creates the message consumer from session.
|
JmsSourceBuilder |
destinationName(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 javax.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 whether
createSharedConsumer() or createSharedDurableConsumer() was used to create it in the consumerFn(FunctionEx) . |
@Nonnull public JmsSourceBuilder connectionParams(@Nullable String username, @Nullable String password)
connectionFn(FunctionEx)
is
set, these parameters are ignored.@Nonnull public JmsSourceBuilder connectionFn(@Nullable FunctionEx<? super javax.jms.ConnectionFactory,? extends javax.jms.Connection> connectionFn)
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 with
connectionParams(java.lang.String, java.lang.String)
are used.
The given function must be stateless.
@Nonnull public JmsSourceBuilder destinationName(@Nullable String destinationName)
consumerFn(FunctionEx)
is provided, this parameter is ignored.@Nonnull public JmsSourceBuilder consumerFn(@Nullable FunctionEx<? super javax.jms.Session,? extends javax.jms.MessageConsumer> consumerFn)
If not provided, Session#createConsumer(destinationName)
is used
to create the consumer. See destinationName(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.
@Nonnull public JmsSourceBuilder messageIdFn(@Nonnull FunctionEx<? super javax.jms.Message,?> messageIdFn)
Make sure the function returns non-null for every message, or the job
will fail. The returned object should also implement equals()
and hashCode()
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.
@Nonnull public JmsSourceBuilder maxGuarantee(@Nonnull ProcessingGuarantee guarantee)
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.
@Nonnull public JmsSourceBuilder sharedConsumer(boolean isSharedConsumer)
createSharedConsumer()
or createSharedDurableConsumer()
was used to create it in the consumerFn(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
.
@Nonnull public <T> StreamSource<T> build(@Nonnull FunctionEx<? super javax.jms.Message,? extends T> projectionFn)
StreamSource
with the supplied
components and the projection function projectionFn
.
The given function must be stateless.
T
- the type of the items the source emitsprojectionFn
- the function which creates output object from each
message@Nonnull public StreamSource<javax.jms.Message> build()
build(FunctionEx)
.Copyright © 2021 Hazelcast, Inc.. All rights reserved.