Class JmsConnector
java.lang.Object
io.helidon.messaging.connectors.jms.JmsConnector
- All Implemented Interfaces:
Stoppable
,ConnectorFactory
,IncomingConnectorFactory
,OutgoingConnectorFactory
- Direct Known Subclasses:
AqConnectorImpl
,WeblogicConnector
@ApplicationScoped
public class JmsConnector
extends Object
implements IncomingConnectorFactory, OutgoingConnectorFactory, Stoppable
MicroProfile Reactive Messaging JMS connector.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
JMS acknowledge mode.static final String
Wait for the acknowledgement of previous message before pulling next one.static final String
Client identifier for JMS connection.static final String
Microprofile messaging JMS connector name.static final String
Queue or topic name.static final String
True for creating durable consumer (only for topic).static final String
JMS API message selector expression based on a subset of the SQL92.static final String
Select in case factory is injected as a named bean or configured with name.static final String
If true then any messages published to the topic using this session's connection, or any other connection with the same client identifier, will not be added to the durable subscription.static final String
Password used with ConnectionFactory.static final String
Period for executing poll cycles in millis.static final String
Timeout for polling for next message in every poll cycle in millis.static final String
When multiple channels share same session-group-id, they share same JMS session and same JDBC connection as well.static final String
Subscriber name for durable consumer used to identify subscription.static final String
Indicates whether the session will use a local transaction.static final String
Possible values are: queue, topic.static final String
Username used with ConnectionFactory.Fields inherited from interface org.eclipse.microprofile.reactive.messaging.spi.ConnectorFactory
CHANNEL_NAME_ATTRIBUTE, CONNECTOR_ATTRIBUTE, CONNECTOR_PREFIX, INCOMING_PREFIX, OUTGOING_PREFIX
-
Constructor Summary
ModifierConstructorDescriptionprotected
JmsConnector
(Config config, Instance<jakarta.jms.ConnectionFactory> jakartaConnectionFactories) Create new JmsConnector.protected
JmsConnector
(Map<String, jakarta.jms.ConnectionFactory> connectionFactoryMap, ScheduledExecutorService scheduler, ExecutorService executor) Create new JmsConnector. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Provides aJmsConnector.JmsConnectorBuilder
for creating aJmsConnector
instance.static JmsConfigBuilder
Custom config builder for JMS connector.protected CompletionStage
<?> consumeAsync
(Message<?> m, jakarta.jms.Session session, AtomicReference<MessageMapper> mapper, jakarta.jms.MessageProducer producer, Config config) static JmsConnector
create()
Creates a new instance of JmsConnector with empty configuration.protected jakarta.jms.MessageConsumer
createConsumer
(Config config, jakarta.jms.Destination destination, SessionMetadata sessionEntry) protected jakarta.jms.Destination
createDestination
(jakarta.jms.Session session, ConnectionContext ctx) protected JmsMessage
<?> createMessage
(NackHandler nackHandler, jakarta.jms.Message message, Executor executor, SessionMetadata sessionMetadata) Create reactive messaging message from JMS message.protected jakarta.jms.MessageProducer
createProducer
(jakarta.jms.Destination destination, ConnectionContext ctx, SessionMetadata sessionEntry) protected Optional
<? extends jakarta.jms.ConnectionFactory> Find correct ConnectionFactory for channel.PublisherBuilder
<? extends Message<?>> getPublisherBuilder
(Config mpConfig) SubscriberBuilder
<? extends Message<?>, Void> getSubscriberBuilder
(Config mpConfig) protected SessionMetadata
prepareSession
(Config config, jakarta.jms.ConnectionFactory factory) protected BiConsumer
<Message<?>, jakarta.jms.JMSException> sendingErrorHandler
(Config config) Customizable handler for errors during sending.void
stop()
Invoked duringMessaging.stop()
.
-
Field Details
-
CONNECTOR_NAME
Microprofile messaging JMS connector name.- See Also:
-
NAMED_FACTORY_ATTRIBUTE
Select in case factory is injected as a named bean or configured with name.- See Also:
-
USERNAME_ATTRIBUTE
Username used with ConnectionFactory.- See Also:
-
PASSWORD_ATTRIBUTE
Password used with ConnectionFactory.- See Also:
-
CLIENT_ID_ATTRIBUTE
Client identifier for JMS connection.- See Also:
-
DURABLE_ATTRIBUTE
True for creating durable consumer (only for topic).- See Also:
-
SUBSCRIBER_NAME_ATTRIBUTE
Subscriber name for durable consumer used to identify subscription.- See Also:
-
NON_LOCAL_ATTRIBUTE
If true then any messages published to the topic using this session's connection, or any other connection with the same client identifier, will not be added to the durable subscription.- See Also:
-
ACK_MODE_ATTRIBUTE
JMS acknowledge mode.Possible values are:
- AUTO_ACKNOWLEDGE - session automatically acknowledges a client’s receipt of a message,
- CLIENT_ACKNOWLEDGE - receipt of a message is acknowledged only when Message.ack() is called manually,
- DUPS_OK_ACKNOWLEDGE - session lazily acknowledges the delivery of messages.
- See Also:
-
TRANSACTED_ATTRIBUTE
Indicates whether the session will use a local transaction.- See Also:
-
AWAIT_ACK_ATTRIBUTE
Wait for the acknowledgement of previous message before pulling next one.- See Also:
-
MESSAGE_SELECTOR_ATTRIBUTE
JMS API message selector expression based on a subset of the SQL92. Expression can only access headers and properties, not the payload.- See Also:
-
POLL_TIMEOUT_ATTRIBUTE
Timeout for polling for next message in every poll cycle in millis.- See Also:
-
PERIOD_EXECUTIONS_ATTRIBUTE
Period for executing poll cycles in millis.- See Also:
-
TYPE_ATTRIBUTE
Possible values are: queue, topic.- See Also:
-
DESTINATION_ATTRIBUTE
Queue or topic name.- See Also:
-
SESSION_GROUP_ID_ATTRIBUTE
When multiple channels share same session-group-id, they share same JMS session and same JDBC connection as well.- See Also:
-
-
Constructor Details
-
JmsConnector
@Inject protected JmsConnector(Config config, Instance<jakarta.jms.ConnectionFactory> jakartaConnectionFactories) Create new JmsConnector.- Parameters:
config
- root config for thread contextjakartaConnectionFactories
- connection factory beans
-
JmsConnector
protected JmsConnector(Map<String, jakarta.jms.ConnectionFactory> connectionFactoryMap, ScheduledExecutorService scheduler, ExecutorService executor) Create new JmsConnector.- Parameters:
connectionFactoryMap
- custom connection factoriesscheduler
- custom scheduler for pollingexecutor
- custom executor for async tasks
-
-
Method Details
-
builder
Provides aJmsConnector.JmsConnectorBuilder
for creating aJmsConnector
instance.- Returns:
- new Builder instance
-
create
Creates a new instance of JmsConnector with empty configuration.- Returns:
- the new instance
-
configBuilder
Custom config builder for JMS connector.- Returns:
- new JMS specific config builder
-
stop
public void stop()Description copied from interface:Stoppable
Invoked duringMessaging.stop()
. -
createMessage
protected JmsMessage<?> createMessage(NackHandler nackHandler, jakarta.jms.Message message, Executor executor, SessionMetadata sessionMetadata) Create reactive messaging message from JMS message.- Parameters:
nackHandler
- Not acknowledged handlermessage
- JMS messageexecutor
- executor used for async execution of acksessionMetadata
- JMS session metadata- Returns:
- reactive messaging message extended with custom JMS features
-
getFactory
Find correct ConnectionFactory for channel.- Parameters:
ctx
- Channel's context- Returns:
- appropriate connection factory
-
getPublisherBuilder
- Specified by:
getPublisherBuilder
in interfaceIncomingConnectorFactory
-
getSubscriberBuilder
- Specified by:
getSubscriberBuilder
in interfaceOutgoingConnectorFactory
-
consumeAsync
protected CompletionStage<?> consumeAsync(Message<?> m, jakarta.jms.Session session, AtomicReference<MessageMapper> mapper, jakarta.jms.MessageProducer producer, Config config) -
sendingErrorHandler
Customizable handler for errors during sending.- Parameters:
config
- channel's config- Returns:
- consumer of errors
-
prepareSession
protected SessionMetadata prepareSession(Config config, jakarta.jms.ConnectionFactory factory) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
createDestination
protected jakarta.jms.Destination createDestination(jakarta.jms.Session session, ConnectionContext ctx) -
createConsumer
protected jakarta.jms.MessageConsumer createConsumer(Config config, jakarta.jms.Destination destination, SessionMetadata sessionEntry) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
createProducer
protected jakarta.jms.MessageProducer createProducer(jakarta.jms.Destination destination, ConnectionContext ctx, SessionMetadata sessionEntry) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-