Class PulsarConnectionFactory
- All Implemented Interfaces:
Serializable,AutoCloseable,javax.jms.ConnectionFactory,javax.jms.QueueConnectionFactory,javax.jms.TopicConnectionFactory
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPulsarConnectionFactory(String configuration) PulsarConnectionFactory(Map<String, Object> properties) -
Method Summary
Modifier and TypeMethodDescriptionapplySystemNamespace(String destination) protected org.apache.pulsar.client.api.PulsarClientbuildPulsarClient(org.apache.pulsar.client.api.ClientBuilder builder) voidclose()Creates a connection with the default user identity.createConnection(String userName, String password) Creates a connection with the specified user identity.org.apache.pulsar.client.impl.ConsumerBase<?>createConsumer(PulsarDestination destination, String consumerName, org.apache.pulsar.client.api.SubscriptionMode subscriptionMode, org.apache.pulsar.client.api.SubscriptionType subscriptionType, String messageSelector, boolean noLocal, PulsarSession session) javax.jms.JMSContextCreates a JMSContext with the default user identity and an unspecified sessionMode.javax.jms.JMSContextcreateContext(int sessionMode) Creates a JMSContext with the default user identity and the specified session mode.javax.jms.JMSContextcreateContext(String userName, String password) Creates a JMSContext with the specified user identity and an unspecified sessionMode.javax.jms.JMSContextcreateContext(String userName, String password, int sessionMode) Creates a JMSContext with the specified user identity and the specified session mode.javax.jms.QueueConnectionjavax.jms.QueueConnectioncreateQueueConnection(String s, String s1) List<org.apache.pulsar.client.api.Reader<?>>createReadersForBrowser(PulsarQueue destination, com.datastax.oss.pulsar.jms.ConsumerConfiguration overrideConsumerConfiguration) javax.jms.TopicConnectionjavax.jms.TopicConnectioncreateTopicConnection(String s, String s1) booleandeleteSubscription(PulsarDestination destination, String name) downloadServerSideFilter(String fullQualifiedTopicName, String subscriptionName, org.apache.pulsar.client.api.SubscriptionMode subscriptionMode) voidensureQueueSubscription(PulsarDestination destination) getAdmin()Access to the high level Admin JMS APIintorg.apache.pulsar.client.api.SubscriptionTypegetExclusiveSubscriptionTypeForSimpleConsumers(javax.jms.Destination destination) Utility method for configuration based on JSONorg.apache.pulsar.client.admin.PulsarAdminorg.apache.pulsar.client.api.PulsarClientgetPulsarTopicName(javax.jms.Destination defaultDestination) getQueueSubscriptionName(PulsarDestination destination) intorg.apache.pulsar.client.api.SubscriptionTypelongbooleanbooleanbooleanisClosed()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidregisterClientId(String clientID) voidremoveConsumer(org.apache.pulsar.client.api.Consumer<?> consumer) voidremoveReader(org.apache.pulsar.client.api.Reader<?> reader) voidsetConfiguration(Map<String, Object> configuration) voidsetJsonConfiguration(String json) Apply configuration from a JSON encoded stringstatic PulsarDestinationtoPulsarDestination(javax.jms.Destination destination) voidunregisterConnection(PulsarConnection connection)
-
Constructor Details
-
PulsarConnectionFactory
public PulsarConnectionFactory() throws javax.jms.JMSException- Throws:
javax.jms.JMSException
-
PulsarConnectionFactory
-
PulsarConnectionFactory
- Throws:
javax.jms.JMSException
-
-
Method Details
-
getJsonConfiguration
Utility method for configuration based on JSON- Returns:
- JSON encoded configuration
-
setJsonConfiguration
Apply configuration from a JSON encoded string- Parameters:
json- the JSON
-
getConfiguration
-
setConfiguration
-
buildPulsarClient
protected org.apache.pulsar.client.api.PulsarClient buildPulsarClient(org.apache.pulsar.client.api.ClientBuilder builder) throws org.apache.pulsar.client.api.PulsarClientException - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
isEnableClientSideEmulation
public boolean isEnableClientSideEmulation() -
isTransactionsStickyPartitions
public boolean isTransactionsStickyPartitions() -
isUseServerSideFiltering
public boolean isUseServerSideFiltering() -
isEnableJMSPriority
public boolean isEnableJMSPriority() -
isPriorityUseLinearMapping
public boolean isPriorityUseLinearMapping() -
isEnableTransaction
public boolean isEnableTransaction() -
isEmulateTransactions
public boolean isEmulateTransactions() -
getPulsarClient
public org.apache.pulsar.client.api.PulsarClient getPulsarClient() -
getPulsarAdmin
public org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdmin() throws javax.jms.IllegalStateException- Throws:
javax.jms.IllegalStateException
-
getSystemNamespace
-
createConnection
Creates a connection with the default user identity. The connection is created in stopped mode. No messages will be delivered until theConnection.startmethod is explicitly called.- Specified by:
createConnectionin interfacejavax.jms.ConnectionFactory- Returns:
- a newly created connection
- Throws:
javax.jms.JMSException- if the JMS provider fails to create the connection due to some internal error.javax.jms.JMSSecurityException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 1.1
-
createConnection
public PulsarConnection createConnection(String userName, String password) throws javax.jms.JMSException Creates a connection with the specified user identity. The connection is created in stopped mode. No messages will be delivered until theConnection.startmethod is explicitly called.- Specified by:
createConnectionin interfacejavax.jms.ConnectionFactory- Parameters:
userName- the caller's user namepassword- the caller's password- Returns:
- a newly created connection
- Throws:
javax.jms.JMSException- if the JMS provider fails to create the connection due to some internal error.javax.jms.JMSSecurityException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 1.1
-
createContext
public javax.jms.JMSContext createContext()Creates a JMSContext with the default user identity and an unspecified sessionMode.A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer is created.
The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
JMSContext.AUTO_ACKNOWLEDGEFor a definition of the meaning of this acknowledgement mode see the link below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
- The session will participate in the JTA transaction and will be committed or rolled back
when that transaction is committed or rolled back, not by calling the
JMSContext'scommitorrollbackmethods.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
JMSContext.AUTO_ACKNOWLEDGEFor a definition of the meaning of this acknowledgement mode see the link below.
- Specified by:
createContextin interfacejavax.jms.ConnectionFactory- Returns:
- a newly created JMSContext
- Throws:
javax.jms.JMSRuntimeException- if the JMS provider fails to create the JMSContext due to some internal error.javax.jms.JMSSecurityRuntimeException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 2.0
- See Also:
-
JMSContext.AUTO_ACKNOWLEDGEConnectionFactory.createContext(int)ConnectionFactory.createContext(String, String)ConnectionFactory.createContext(String, String, int)JMSContext.createContext(int)
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
-
createContext
Creates a JMSContext with the specified user identity and an unspecified sessionMode.A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer.
The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress.
In a Java SE environment or in the Java EE application client container:
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
JMSContext.AUTO_ACKNOWLEDGEFor a definition of the meaning of this acknowledgement mode see the link below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
- The session will participate in the JTA transaction and will be committed or rolled back
when that transaction is committed or rolled back, not by calling the
JMSContext'scommitorrollbackmethods.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
JMSContext.AUTO_ACKNOWLEDGEFor a definition of the meaning of this acknowledgement mode see the link below.
- Specified by:
createContextin interfacejavax.jms.ConnectionFactory- Parameters:
userName- the caller's user namepassword- the caller's password- Returns:
- a newly created JMSContext
- Throws:
javax.jms.JMSRuntimeException- if the JMS provider fails to create the JMSContext due to some internal error.javax.jms.JMSSecurityRuntimeException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 2.0
- See Also:
-
JMSContext.AUTO_ACKNOWLEDGEConnectionFactory.createContext()ConnectionFactory.createContext(int)ConnectionFactory.createContext(String, String, int)JMSContext.createContext(int)
- The session will be non-transacted and received messages will be acknowledged
automatically using an acknowledgement mode of
-
createContext
Creates a JMSContext with the specified user identity and the specified session mode.A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the
sessionModeargument depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the effect of setting thesessionModeargument also depends on whether or not there is an active JTA transaction in progress.In a Java SE environment or in the Java EE application client container:
- If
sessionModeis set toJMSContext.SESSION_TRANSACTEDthen the session will use a local transaction which may subsequently be committed or rolled back by calling theJMSContext'scommitorrollbackmethods. - If
sessionModeis set to any ofJMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEorJMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value ofsessionMode. For a definition of the meaning of these acknowledgement modes see the links below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
- The argument
sessionModeis ignored. The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling theJMSContext'scommitorrollbackmethods. Since the argument is ignored, developers are recommended to usecreateContext(String userName, String password)instead of this method.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
- The argument
acknowledgeModemust be set to either ofJMSContext.AUTO_ACKNOWLEDGEorJMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value ofacknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The valuesJMSContext.SESSION_TRANSACTEDandJMSContext.CLIENT_ACKNOWLEDGEmay not be used.
- Specified by:
createContextin interfacejavax.jms.ConnectionFactory- Parameters:
userName- the caller's user namepassword- the caller's passwordsessionMode- indicates which of four possible session modes will be used.- If this method is called in a Java SE environment or in the Java EE application
client container, the permitted values are
JMSContext.SESSION_TRANSACTED,JMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEandJMSContext.DUPS_OK_ACKNOWLEDGE. - If this method is called in the Java EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
- If this method is called in the Java EE web or EJB container when there is no active
JTA transaction in progress, the permitted values are
JMSContext.AUTO_ACKNOWLEDGEandJMSContext.DUPS_OK_ACKNOWLEDGE. In this case the valuesJMSContext.TRANSACTEDandJMSContext.CLIENT_ACKNOWLEDGEare not permitted.
- If this method is called in a Java SE environment or in the Java EE application
client container, the permitted values are
- Returns:
- a newly created JMSContext
- Throws:
javax.jms.JMSRuntimeException- if the JMS provider fails to create the JMSContext due to some internal error.javax.jms.JMSSecurityRuntimeException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 2.0
- See Also:
-
JMSContext.SESSION_TRANSACTEDJMSContext.CLIENT_ACKNOWLEDGEJMSContext.AUTO_ACKNOWLEDGEJMSContext.DUPS_OK_ACKNOWLEDGEConnectionFactory.createContext()ConnectionFactory.createContext(int)ConnectionFactory.createContext(String, String)JMSContext.createContext(int)
- If
-
createContext
public javax.jms.JMSContext createContext(int sessionMode) Creates a JMSContext with the default user identity and the specified session mode.A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the
sessionModeargument depends on whether this method is called in a Java SE environment, in the Java EE application client container, or in the Java EE web or EJB container. If this method is called in the Java EE web or EJB container then the effect of setting thesessionModeargument also depends on whether or not there is an active JTA transaction in progress.In a Java SE environment or in the Java EE application client container:
- If
sessionModeis set toJMSContext.SESSION_TRANSACTEDthen the session will use a local transaction which may subsequently be committed or rolled back by calling theJMSContext'scommitorrollbackmethods. - If
sessionModeis set to any ofJMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEorJMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value ofsessionMode. For a definition of the meaning of these acknowledgement modes see the links below.
In a Java EE web or EJB container, when there is an active JTA transaction in progress:
- The argument
sessionModeis ignored. The session will participate in the JTA transaction and will be committed or rolled back when that transaction is committed or rolled back, not by calling theJMSContext'scommitorrollbackmethods. Since the argument is ignored, developers are recommended to usecreateContext()instead of this method.
In the Java EE web or EJB container, when there is no active JTA transaction in progress:
- The argument
acknowledgeModemust be set to either ofJMSContext.AUTO_ACKNOWLEDGEorJMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value ofacknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The valuesJMSContext.SESSION_TRANSACTEDandJMSContext.CLIENT_ACKNOWLEDGEmay not be used.
- Specified by:
createContextin interfacejavax.jms.ConnectionFactory- Parameters:
sessionMode- indicates which of four possible session modes will be used.- If this method is called in a Java SE environment or in the Java EE application
client container, the permitted values are
JMSContext.SESSION_TRANSACTED,JMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEandJMSContext.DUPS_OK_ACKNOWLEDGE. - If this method is called in the Java EE web or EJB container when there is an active JTA transaction in progress then this argument is ignored.
- If this method is called in the Java EE web or EJB container when there is no active
JTA transaction in progress, the permitted values are
JMSContext.AUTO_ACKNOWLEDGEandJMSContext.DUPS_OK_ACKNOWLEDGE. In this case the valuesJMSContext.TRANSACTEDandJMSContext.CLIENT_ACKNOWLEDGEare not permitted.
- If this method is called in a Java SE environment or in the Java EE application
client container, the permitted values are
- Returns:
- a newly created JMSContext
- Throws:
javax.jms.JMSRuntimeException- if the JMS provider fails to create the JMSContext due to some internal error.javax.jms.JMSSecurityRuntimeException- if client authentication fails due to an invalid user name or password.- Since:
- JMS 2.0
- See Also:
-
JMSContext.SESSION_TRANSACTEDJMSContext.CLIENT_ACKNOWLEDGEJMSContext.AUTO_ACKNOWLEDGEJMSContext.DUPS_OK_ACKNOWLEDGEConnectionFactory.createContext()ConnectionFactory.createContext(String, String)ConnectionFactory.createContext(String, String, int)JMSContext.createContext(int)
- If
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
toPulsarDestination
public static PulsarDestination toPulsarDestination(javax.jms.Destination destination) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
getPulsarTopicName
public String getPulsarTopicName(javax.jms.Destination defaultDestination) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
ensureQueueSubscription
- Throws:
javax.jms.JMSException
-
createConsumer
public org.apache.pulsar.client.impl.ConsumerBase<?> createConsumer(PulsarDestination destination, String consumerName, org.apache.pulsar.client.api.SubscriptionMode subscriptionMode, org.apache.pulsar.client.api.SubscriptionType subscriptionType, String messageSelector, boolean noLocal, PulsarSession session) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
downloadServerSideFilter
public String downloadServerSideFilter(String fullQualifiedTopicName, String subscriptionName, org.apache.pulsar.client.api.SubscriptionMode subscriptionMode) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
createReadersForBrowser
public List<org.apache.pulsar.client.api.Reader<?>> createReadersForBrowser(PulsarQueue destination, com.datastax.oss.pulsar.jms.ConsumerConfiguration overrideConsumerConfiguration) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
removeConsumer
public void removeConsumer(org.apache.pulsar.client.api.Consumer<?> consumer) -
removeReader
public void removeReader(org.apache.pulsar.client.api.Reader<?> reader) -
deleteSubscription
public boolean deleteSubscription(PulsarDestination destination, String name) throws javax.jms.JMSException - Throws:
javax.jms.JMSException
-
registerClientId
- Throws:
javax.jms.InvalidClientIDException
-
unregisterConnection
-
createQueueConnection
public javax.jms.QueueConnection createQueueConnection() throws javax.jms.JMSException- Specified by:
createQueueConnectionin interfacejavax.jms.QueueConnectionFactory- Throws:
javax.jms.JMSException
-
createQueueConnection
public javax.jms.QueueConnection createQueueConnection(String s, String s1) throws javax.jms.JMSException - Specified by:
createQueueConnectionin interfacejavax.jms.QueueConnectionFactory- Throws:
javax.jms.JMSException
-
createTopicConnection
public javax.jms.TopicConnection createTopicConnection() throws javax.jms.JMSException- Specified by:
createTopicConnectionin interfacejavax.jms.TopicConnectionFactory- Throws:
javax.jms.JMSException
-
createTopicConnection
public javax.jms.TopicConnection createTopicConnection(String s, String s1) throws javax.jms.JMSException - Specified by:
createTopicConnectionin interfacejavax.jms.TopicConnectionFactory- Throws:
javax.jms.JMSException
-
isForceDeleteTemporaryDestinations
public boolean isForceDeleteTemporaryDestinations() -
getQueueSubscriptionName
public String getQueueSubscriptionName(PulsarDestination destination) throws javax.jms.InvalidDestinationException - Throws:
javax.jms.InvalidDestinationException
-
getWaitForServerStartupTimeout
public long getWaitForServerStartupTimeout() -
getExclusiveSubscriptionTypeForSimpleConsumers
public org.apache.pulsar.client.api.SubscriptionType getExclusiveSubscriptionTypeForSimpleConsumers(javax.jms.Destination destination) -
applySystemNamespace
-
isAcknowledgeRejectedMessages
public boolean isAcknowledgeRejectedMessages() -
isAllowTemporaryTopicWithoutAdmin
public boolean isAllowTemporaryTopicWithoutAdmin() -
isClosed
public boolean isClosed() -
getAdmin
Access to the high level Admin JMS API- Returns:
- the handle to the Admin API.
-
getSessionListenersThreads
public int getSessionListenersThreads() -
getSessionListenersThreadPool
-
isMaxMessagesLimitsParallelism
public boolean isMaxMessagesLimitsParallelism() -
getConnectionConsumerStopTimeout
public int getConnectionConsumerStopTimeout()
-