Class PulsarConnectionFactory

java.lang.Object
com.datastax.oss.pulsar.jms.PulsarConnectionFactory
All Implemented Interfaces:
Serializable, AutoCloseable, javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory

public class PulsarConnectionFactory extends Object implements javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, AutoCloseable, Serializable
See Also:
  • Constructor Details

    • PulsarConnectionFactory

      public PulsarConnectionFactory() throws javax.jms.JMSException
      Throws:
      javax.jms.JMSException
    • PulsarConnectionFactory

      public PulsarConnectionFactory(Map<String,Object> properties)
    • PulsarConnectionFactory

      public PulsarConnectionFactory(String configuration) throws javax.jms.JMSException
      Throws:
      javax.jms.JMSException
  • Method Details

    • getJsonConfiguration

      public String getJsonConfiguration()
      Utility method for configuration based on JSON
      Returns:
      JSON encoded configuration
    • setJsonConfiguration

      public void setJsonConfiguration(String json)
      Apply configuration from a JSON encoded string
      Parameters:
      json - the JSON
    • getConfiguration

      public Map<String,Object> getConfiguration()
    • setConfiguration

      public void setConfiguration(Map<String,Object> configuration)
    • 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

      public String getSystemNamespace()
    • createConnection

      public PulsarConnection createConnection() throws javax.jms.JMSException
      Creates a connection with the default user identity. The connection is created in stopped mode. No messages will be delivered until the Connection.start method is explicitly called.
      Specified by:
      createConnection in interface javax.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 the Connection.start method is explicitly called.
      Specified by:
      createConnection in interface javax.jms.ConnectionFactory
      Parameters:
      userName - the caller's user name
      password - 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_ACKNOWLEDGE For 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's commit or rollback methods.

      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_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.
      Specified by:
      createContext in interface javax.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_ACKNOWLEDGE
      • ConnectionFactory.createContext(int)
      • ConnectionFactory.createContext(String, String)
      • ConnectionFactory.createContext(String, String, int)
      • JMSContext.createContext(int)
    • createContext

      public javax.jms.JMSContext createContext(String userName, String password)
      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_ACKNOWLEDGE For 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's commit or rollback methods.

      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_ACKNOWLEDGE For a definition of the meaning of this acknowledgement mode see the link below.
      Specified by:
      createContext in interface javax.jms.ConnectionFactory
      Parameters:
      userName - the caller's user name
      password - 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_ACKNOWLEDGE
      • ConnectionFactory.createContext()
      • ConnectionFactory.createContext(int)
      • ConnectionFactory.createContext(String, String, int)
      • JMSContext.createContext(int)
    • createContext

      public javax.jms.JMSContext createContext(String userName, String password, int sessionMode)
      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 sessionMode argument 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 the sessionMode argument 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 sessionMode is set to JMSContext.SESSION_TRANSACTED then the session will use a local transaction which may subsequently be committed or rolled back by calling the JMSContext's commit or rollback methods.
      • If sessionMode is set to any of JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value of sessionMode. 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 sessionMode is 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 the JMSContext's commit or rollback methods. Since the argument is ignored, developers are recommended to use createContext(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 acknowledgeMode must be set to either of JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value of acknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The values JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used.
      Specified by:
      createContext in interface javax.jms.ConnectionFactory
      Parameters:
      userName - the caller's user name
      password - the caller's password
      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_ACKNOWLEDGE and JMSContext.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_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
      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_TRANSACTED
      • JMSContext.CLIENT_ACKNOWLEDGE
      • JMSContext.AUTO_ACKNOWLEDGE
      • JMSContext.DUPS_OK_ACKNOWLEDGE
      • ConnectionFactory.createContext()
      • ConnectionFactory.createContext(int)
      • ConnectionFactory.createContext(String, String)
      • JMSContext.createContext(int)
    • 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 sessionMode argument 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 the sessionMode argument 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 sessionMode is set to JMSContext.SESSION_TRANSACTED then the session will use a local transaction which may subsequently be committed or rolled back by calling the JMSContext's commit or rollback methods.
      • If sessionMode is set to any of JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value of sessionMode. 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 sessionMode is 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 the JMSContext's commit or rollback methods. Since the argument is ignored, developers are recommended to use createContext() instead of this method.

      In the Java EE web or EJB container, when there is no active JTA transaction in progress:

      • The argument acknowledgeMode must be set to either of JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by this session will be acknowledged automatically according to the value of acknowledgeMode. For a definition of the meaning of these acknowledgement modes see the links below. The values JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used.
      Specified by:
      createContext in interface javax.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_ACKNOWLEDGE and JMSContext.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_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE. In this case the values JMSContext.TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE are not permitted.
      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_TRANSACTED
      • JMSContext.CLIENT_ACKNOWLEDGE
      • JMSContext.AUTO_ACKNOWLEDGE
      • JMSContext.DUPS_OK_ACKNOWLEDGE
      • ConnectionFactory.createContext()
      • ConnectionFactory.createContext(String, String)
      • ConnectionFactory.createContext(String, String, int)
      • JMSContext.createContext(int)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • 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

      public void ensureQueueSubscription(PulsarDestination destination) throws javax.jms.JMSException
      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

      public void registerClientId(String clientID) throws javax.jms.InvalidClientIDException
      Throws:
      javax.jms.InvalidClientIDException
    • unregisterConnection

      public void unregisterConnection(PulsarConnection connection)
    • createQueueConnection

      public javax.jms.QueueConnection createQueueConnection() throws javax.jms.JMSException
      Specified by:
      createQueueConnection in interface javax.jms.QueueConnectionFactory
      Throws:
      javax.jms.JMSException
    • createQueueConnection

      public javax.jms.QueueConnection createQueueConnection(String s, String s1) throws javax.jms.JMSException
      Specified by:
      createQueueConnection in interface javax.jms.QueueConnectionFactory
      Throws:
      javax.jms.JMSException
    • createTopicConnection

      public javax.jms.TopicConnection createTopicConnection() throws javax.jms.JMSException
      Specified by:
      createTopicConnection in interface javax.jms.TopicConnectionFactory
      Throws:
      javax.jms.JMSException
    • createTopicConnection

      public javax.jms.TopicConnection createTopicConnection(String s, String s1) throws javax.jms.JMSException
      Specified by:
      createTopicConnection in interface javax.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)
    • getTopicSharedSubscriptionType

      public org.apache.pulsar.client.api.SubscriptionType getTopicSharedSubscriptionType()
    • applySystemNamespace

      public String applySystemNamespace(String destination)
    • isAcknowledgeRejectedMessages

      public boolean isAcknowledgeRejectedMessages()
    • isAllowTemporaryTopicWithoutAdmin

      public boolean isAllowTemporaryTopicWithoutAdmin()
    • isClosed

      public boolean isClosed()
    • getAdmin

      public JMSAdmin getAdmin()
      Access to the high level Admin JMS API
      Returns:
      the handle to the Admin API.
    • getSessionListenersThreads

      public int getSessionListenersThreads()
    • getSessionListenersThreadPool

      public ScheduledExecutorService getSessionListenersThreadPool()
    • isMaxMessagesLimitsParallelism

      public boolean isMaxMessagesLimitsParallelism()
    • getConnectionConsumerStopTimeout

      public int getConnectionConsumerStopTimeout()