Class ActiveMQConnectionFactory

    • Field Detail

      • DEFAULT_BROKER_BIND_URL

        public static final String DEFAULT_BROKER_BIND_URL
      • DEFAULT_BROKER_URL

        public static final String DEFAULT_BROKER_URL
      • DEFAULT_USER

        public static final String DEFAULT_USER
      • DEFAULT_PASSWORD

        public static final String DEFAULT_PASSWORD
      • DEFAULT_PRODUCER_WINDOW_SIZE

        public static final int DEFAULT_PRODUCER_WINDOW_SIZE
        See Also:
        Constant Field Values
      • brokerURL

        protected URI brokerURL
      • userName

        protected String userName
      • password

        protected String password
      • clientID

        protected String clientID
      • dispatchAsync

        protected boolean dispatchAsync
      • alwaysSessionAsync

        protected boolean alwaysSessionAsync
      • xaAckMode

        protected int xaAckMode
    • Constructor Detail

      • ActiveMQConnectionFactory

        public ActiveMQConnectionFactory()
      • ActiveMQConnectionFactory

        public ActiveMQConnectionFactory​(String brokerURL)
      • ActiveMQConnectionFactory

        public ActiveMQConnectionFactory​(URI brokerURL)
      • ActiveMQConnectionFactory

        public ActiveMQConnectionFactory​(String userName,
                                         String password,
                                         URI brokerURL)
      • ActiveMQConnectionFactory

        public ActiveMQConnectionFactory​(String userName,
                                         String password,
                                         String brokerURL)
    • Method Detail

      • getStats

        public StatsImpl getStats()
        Specified by:
        getStats in interface StatsCapable
        Returns:
        the StatsImpl associated with this ConnectionFactory.
      • createTransport

        protected Transport createTransport()
                                     throws JMSException
        Creates a Transport based on this object's connection settings. Separated from createActiveMQConnection to allow for subclasses to override.
        Returns:
        The newly created Transport.
        Throws:
        JMSException - If unable to create trasnport.
      • getBrokerURL

        public String getBrokerURL()
      • setBrokerURL

        public void setBrokerURL​(String brokerURL)
        Sets the connection URL used to connect to the ActiveMQ broker.
      • getClientID

        public String getClientID()
      • setClientID

        public void setClientID​(String clientID)
        Sets the JMS clientID to use for the created connection. Note that this can only be used by one connection at once so generally its a better idea to set the clientID on a Connection
      • isCopyMessageOnSend

        public boolean isCopyMessageOnSend()
      • setCopyMessageOnSend

        public void setCopyMessageOnSend​(boolean copyMessageOnSend)
        Should a JMS message be copied to a new JMS Message object as part of the send() method in JMS. This is enabled by default to be compliant with the JMS specification. You can disable it if you do not mutate JMS messages after they are sent for a performance boost
      • isDisableTimeStampsByDefault

        public boolean isDisableTimeStampsByDefault()
      • setDisableTimeStampsByDefault

        public void setDisableTimeStampsByDefault​(boolean disableTimeStampsByDefault)
        Sets whether or not timestamps on messages should be disabled or not. If you disable them it adds a small performance boost.
      • isOptimizedMessageDispatch

        public boolean isOptimizedMessageDispatch()
      • setOptimizedMessageDispatch

        public void setOptimizedMessageDispatch​(boolean optimizedMessageDispatch)
        If this flag is set then an larger prefetch limit is used - only applicable for durable topic subscribers.
      • getPassword

        public String getPassword()
      • setPassword

        public void setPassword​(String password)
        Sets the JMS password used for connections created from this factory
      • isUseAsyncSend

        public boolean isUseAsyncSend()
      • setBlobTransferPolicy

        public void setBlobTransferPolicy​(BlobTransferPolicy blobTransferPolicy)
        Sets the policy used to describe how out-of-band BLOBs (Binary Large OBjects) are transferred from producers to brokers to consumers
      • setUseAsyncSend

        public void setUseAsyncSend​(boolean useAsyncSend)
        Forces the use of Async Sends which adds a massive performance boost; but means that the send() method will return immediately whether the message has been sent or not which could lead to message loss.
      • isWatchTopicAdvisories

        public boolean isWatchTopicAdvisories()
      • setWatchTopicAdvisories

        public void setWatchTopicAdvisories​(boolean watchTopicAdvisories)
      • isAlwaysSyncSend

        public boolean isAlwaysSyncSend()
        Returns:
        true if always sync send messages
      • setAlwaysSyncSend

        public void setAlwaysSyncSend​(boolean alwaysSyncSend)
        Set true if always require messages to be sync sent
        Parameters:
        alwaysSyncSend -
      • getUserName

        public String getUserName()
      • setUserName

        public void setUserName​(String userName)
        Sets the JMS userName used by connections created by this factory
      • isUseRetroactiveConsumer

        public boolean isUseRetroactiveConsumer()
      • setUseRetroactiveConsumer

        public void setUseRetroactiveConsumer​(boolean useRetroactiveConsumer)
        Sets whether or not retroactive consumers are enabled. Retroactive consumers allow non-durable topic subscribers to receive old messages that were published before the non-durable subscriber started.
      • isExclusiveConsumer

        public boolean isExclusiveConsumer()
      • setExclusiveConsumer

        public void setExclusiveConsumer​(boolean exclusiveConsumer)
        Enables or disables whether or not queue consumers should be exclusive or not for example to preserve ordering when not using Message Groups
        Parameters:
        exclusiveConsumer -
      • setRedeliveryPolicy

        public void setRedeliveryPolicy​(RedeliveryPolicy redeliveryPolicy)
        Sets the global default redelivery policy to be used when a message is delivered but the session is rolled back
      • setRedeliveryPolicyMap

        public void setRedeliveryPolicyMap​(RedeliveryPolicyMap redeliveryPolicyMap)
        Sets the global redelivery policy mapping to be used when a message is delivered but the session is rolled back
      • getSendTimeout

        public int getSendTimeout()
        Returns:
        the sendTimeout (in milliseconds)
      • setSendTimeout

        public void setSendTimeout​(int sendTimeout)
        Parameters:
        sendTimeout - the sendTimeout to set (in milliseconds)
      • isSendAcksAsync

        public boolean isSendAcksAsync()
        Returns:
        the sendAcksAsync
      • setSendAcksAsync

        public void setSendAcksAsync​(boolean sendAcksAsync)
        Parameters:
        sendAcksAsync - the sendAcksAsync to set
      • isMessagePrioritySupported

        public boolean isMessagePrioritySupported()
        Returns:
        the messagePrioritySupported
      • setMessagePrioritySupported

        public void setMessagePrioritySupported​(boolean messagePrioritySupported)
        Parameters:
        messagePrioritySupported - the messagePrioritySupported to set
      • setTransformer

        public void setTransformer​(MessageTransformer transformer)
        Sets the transformer used to transform messages before they are sent on to the JMS bus or when they are received from the bus but before they are delivered to the JMS client
      • buildFromMap

        public boolean buildFromMap​(Map<String,​Object> properties)
      • isUseCompression

        public boolean isUseCompression()
      • setUseCompression

        public void setUseCompression​(boolean useCompression)
        Enables the use of compression of the message bodies
      • isObjectMessageSerializationDefered

        public boolean isObjectMessageSerializationDefered()
      • setObjectMessageSerializationDefered

        public void setObjectMessageSerializationDefered​(boolean objectMessageSerializationDefered)
        When an object is set on an ObjectMessage, the JMS spec requires the object to be serialized by that set method. Enabling this flag causes the object to not get serialized. The object may subsequently get serialized if the message needs to be sent over a socket or stored to disk.
      • isDispatchAsync

        public boolean isDispatchAsync()
      • setDispatchAsync

        public void setDispatchAsync​(boolean asyncDispatch)
        Enables or disables the default setting of whether or not consumers have their messages dispatched synchronously or asynchronously by the broker. For non-durable topics for example we typically dispatch synchronously by default to minimize context switches which boost performance. However sometimes its better to go slower to ensure that a single blocked consumer socket does not block delivery to other consumers.
        Parameters:
        asyncDispatch - If true then consumers created on this connection will default to having their messages dispatched asynchronously. The default value is true.
      • getCloseTimeout

        public int getCloseTimeout()
        Returns:
        Returns the closeTimeout.
      • setCloseTimeout

        public void setCloseTimeout​(int closeTimeout)
        Sets the timeout before a close is considered complete. Normally a close() on a connection waits for confirmation from the broker; this allows that operation to timeout to save the client hanging if there is no broker
      • isAlwaysSessionAsync

        public boolean isAlwaysSessionAsync()
        Returns:
        Returns the alwaysSessionAsync.
      • setAlwaysSessionAsync

        public void setAlwaysSessionAsync​(boolean alwaysSessionAsync)
        If this flag is not set then a separate thread is not used for dispatching messages for each Session in the Connection. However, a separate thread is always used if there is more than one session, or the session isn't in auto acknowledge or duplicates ok mode. By default this value is set to true and session dispatch happens asynchronously.
      • isOptimizeAcknowledge

        public boolean isOptimizeAcknowledge()
        Returns:
        Returns the optimizeAcknowledge.
      • setOptimizeAcknowledge

        public void setOptimizeAcknowledge​(boolean optimizeAcknowledge)
        Parameters:
        optimizeAcknowledge - The optimizeAcknowledge to set.
      • setOptimizeAcknowledgeTimeOut

        public void setOptimizeAcknowledgeTimeOut​(long optimizeAcknowledgeTimeOut)
        The max time in milliseconds between optimized ack batches
        Parameters:
        optimizeAcknowledgeTimeOut -
      • getOptimizeAcknowledgeTimeOut

        public long getOptimizeAcknowledgeTimeOut()
      • isNestedMapAndListEnabled

        public boolean isNestedMapAndListEnabled()
      • setNestedMapAndListEnabled

        public void setNestedMapAndListEnabled​(boolean structuredMapsEnabled)
        Enables/disables whether or not Message properties and MapMessage entries support Nested Structures of Map and List objects
      • getClientIDPrefix

        public String getClientIDPrefix()
      • setClientIDPrefix

        public void setClientIDPrefix​(String clientIDPrefix)
        Sets the prefix used by autogenerated JMS Client ID values which are used if the JMS client does not explicitly specify on.
        Parameters:
        clientIDPrefix -
      • getClientIdGenerator

        protected IdGenerator getClientIdGenerator()
      • setClientIdGenerator

        protected void setClientIdGenerator​(IdGenerator clientIdGenerator)
      • setConnectionIDPrefix

        public void setConnectionIDPrefix​(String connectionIDPrefix)
        Sets the prefix used by connection id generator
        Parameters:
        connectionIDPrefix -
      • getConnectionIdGenerator

        protected IdGenerator getConnectionIdGenerator()
      • setConnectionIdGenerator

        protected void setConnectionIdGenerator​(IdGenerator connectionIdGenerator)
      • isStatsEnabled

        public boolean isStatsEnabled()
        Returns:
        the statsEnabled
      • setStatsEnabled

        public void setStatsEnabled​(boolean statsEnabled)
        Parameters:
        statsEnabled - the statsEnabled to set
      • getProducerWindowSize

        public int getProducerWindowSize()
      • setProducerWindowSize

        public void setProducerWindowSize​(int producerWindowSize)
      • getWarnAboutUnstartedConnectionTimeout

        public long getWarnAboutUnstartedConnectionTimeout()
      • setWarnAboutUnstartedConnectionTimeout

        public void setWarnAboutUnstartedConnectionTimeout​(long warnAboutUnstartedConnectionTimeout)
        Enables the timeout from a connection creation to when a warning is generated if the connection is not properly started via Connection.start() and a message is received by a consumer. It is a very common gotcha to forget to start the connection so this option makes the default case to create a warning if the user forgets. To disable the warning just set the value to < 0 (say -1).
      • setTransportListener

        public void setTransportListener​(TransportListener transportListener)
        Allows a listener to be configured on the ConnectionFactory so that when this factory is used with frameworks which don't expose the Connection such as Spring JmsTemplate, you can still register a transport listener.
        Parameters:
        transportListener - sets the listener to be registered on all connections created by this factory
      • setExceptionListener

        public void setExceptionListener​(ExceptionListener exceptionListener)
        Allows an ExceptionListener to be configured on the ConnectionFactory so that when this factory is used by frameworks which don't expose the Connection such as Spring JmsTemplate, you can register an exception listener.

        Note: access to this exceptionLinstener will not be serialized if it is associated with more than on connection (as it will be if more than one connection is subsequently created by this connection factory)

        Parameters:
        exceptionListener - sets the exception listener to be registered on all connections created by this factory
      • getAuditDepth

        public int getAuditDepth()
      • setAuditDepth

        public void setAuditDepth​(int auditDepth)
      • getAuditMaximumProducerNumber

        public int getAuditMaximumProducerNumber()
      • setAuditMaximumProducerNumber

        public void setAuditMaximumProducerNumber​(int auditMaximumProducerNumber)
      • setUseDedicatedTaskRunner

        public void setUseDedicatedTaskRunner​(boolean useDedicatedTaskRunner)
      • isUseDedicatedTaskRunner

        public boolean isUseDedicatedTaskRunner()
      • setConsumerFailoverRedeliveryWaitPeriod

        public void setConsumerFailoverRedeliveryWaitPeriod​(long consumerFailoverRedeliveryWaitPeriod)
      • getConsumerFailoverRedeliveryWaitPeriod

        public long getConsumerFailoverRedeliveryWaitPeriod()
      • setClientInternalExceptionListener

        public void setClientInternalExceptionListener​(ClientInternalExceptionListener clientInternalExceptionListener)
        Allows an ClientInternalExceptionListener to be configured on the ConnectionFactory so that when this factory is used by frameworks which don't expose the Connection such as Spring JmsTemplate, you can register an exception listener.

        Note: access to this clientInternalExceptionListener will not be serialized if it is associated with more than on connection (as it will be if more than one connection is subsequently created by this connection factory)

        Parameters:
        clientInternalExceptionListener - sets the exception listener to be registered on all connections created by this factory
      • isCheckForDuplicates

        public boolean isCheckForDuplicates()
        Returns:
        the checkForDuplicates
      • setCheckForDuplicates

        public void setCheckForDuplicates​(boolean checkForDuplicates)
        Parameters:
        checkForDuplicates - the checkForDuplicates to set
      • isTransactedIndividualAck

        public boolean isTransactedIndividualAck()
      • setTransactedIndividualAck

        public void setTransactedIndividualAck​(boolean transactedIndividualAck)
        when true, submit individual transacted acks immediately rather than with transaction completion. This allows the acks to represent delivery status which can be persisted on rollback Used in conjunction with org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter#setRewriteOnRedelivery(boolean) true
      • isNonBlockingRedelivery

        public boolean isNonBlockingRedelivery()
      • setNonBlockingRedelivery

        public void setNonBlockingRedelivery​(boolean nonBlockingRedelivery)
        When true a MessageConsumer will not stop Message delivery before re-delivering Messages from a rolled back transaction. This implies that message order will not be preserved and also will result in the TransactedIndividualAck option to be enabled.
      • getMaxThreadPoolSize

        public int getMaxThreadPoolSize()
      • setMaxThreadPoolSize

        public void setMaxThreadPoolSize​(int maxThreadPoolSize)
      • setSessionTaskRunner

        public void setSessionTaskRunner​(TaskRunnerFactory sessionTaskRunner)
      • getOptimizedAckScheduledAckInterval

        public long getOptimizedAckScheduledAckInterval()
        Gets the configured time interval that is used to force all MessageConsumers that have optimizedAcknowledge enabled to send an ack for any outstanding Message Acks. By default this value is set to zero meaning that the consumers will not do any background Message acknowledgment.
        Returns:
        the scheduledOptimizedAckInterval
      • setOptimizedAckScheduledAckInterval

        public void setOptimizedAckScheduledAckInterval​(long optimizedAckScheduledAckInterval)
        Sets the amount of time between scheduled sends of any outstanding Message Acks for consumers that have been configured with optimizeAcknowledge enabled.
        Parameters:
        optimizedAckScheduledAckInterval - the scheduledOptimizedAckInterval to set
      • isRmIdFromConnectionId

        public boolean isRmIdFromConnectionId()
      • setRmIdFromConnectionId

        public void setRmIdFromConnectionId​(boolean rmIdFromConnectionId)
        uses the connection id as the resource identity for XAResource.isSameRM ensuring join will only occur on a single connection
      • isConsumerExpiryCheckEnabled

        public boolean isConsumerExpiryCheckEnabled()
        Returns:
        true if MessageConsumer instance will check for expired messages before dispatch.
      • setConsumerExpiryCheckEnabled

        public void setConsumerExpiryCheckEnabled​(boolean consumerExpiryCheckEnabled)
        Controls whether message expiration checking is done in each MessageConsumer prior to dispatching a message. Disabling this check can lead to consumption of expired messages.
        Parameters:
        consumerExpiryCheckEnabled - controls whether expiration checking is done prior to dispatch.
      • getTrustedPackages

        public List<String> getTrustedPackages()
      • setTrustedPackages

        public void setTrustedPackages​(List<String> trustedPackages)
      • isTrustAllPackages

        public boolean isTrustAllPackages()
      • setTrustAllPackages

        public void setTrustAllPackages​(boolean trustAllPackages)
      • getConnectResponseTimeout

        public int getConnectResponseTimeout()
      • setConnectResponseTimeout

        public void setConnectResponseTimeout​(int connectResponseTimeout)