Interface Provider

  • All Known Implementing Classes:
    AmqpProvider, FailoverProvider, ProviderWrapper

    public interface Provider
    Defines the interface that an Implementation of a Specific wire level protocol provider must implement. This Provider interface requires that the implementation methods all operate in an asynchronous manner.
    • Method Detail

      • connect

        void connect​(JmsConnectionInfo connectionInfo)
              throws ProviderException
        Performs the initial low level connection for this provider such as TCP or SSL connection to a remote Broker. If this operation fails then the Provider is considered to be unusable and no further operations should be attempted using this Provider.
        Parameters:
        connectionInfo - The JmsConnectionInfo that contains the properties that define this connection.
        Throws:
        ProviderException - if the remote resource can not be contacted.
      • start

        void start()
            throws ProviderException,
                   java.lang.IllegalStateException
        Starts the Provider. The start method provides a place for the Provider to perform and pre-start configuration checks to ensure that the current state is valid and that all contracts have been met prior to starting.
        Throws:
        ProviderException - if an error occurs during start processing.
        java.lang.IllegalStateException - if the Provider is improperly configured.
      • close

        void close()
        Closes this Provider terminating all connections and canceling any pending operations. The Provider is considered unusable after this call. This call is a blocking call and will not return until the Provider has closed or an error occurs.
      • getRemoteURI

        java.net.URI getRemoteURI()
        Returns the URI used to configure this Provider and specify the remote address of the Broker it connects to.
        Returns:
        the URI used to configure this Provider.
      • getAlternateURIs

        java.util.List<java.net.URI> getAlternateURIs()
        Returns a List of alternate remote peers (possibly found via discovery) to which the caller can attempt a recoonect should this provider connection fail. If there are no known alternates this method returns an empty List.
        Returns:
        a List or alternate remote URIs that could be connected to later.
      • create

        void create​(JmsResource resource,
                    AsyncResult request)
             throws ProviderException
        Create the Provider version of the given JmsResource. For each JMS Resource type the Provider implementation must create it's own internal representation and upon successful creation provide the caller with a response. The Provider should examine the given JmsResource to determine if the given configuration is supported or can be simulated, or is not supported in which case an exception should be thrown. It is possible for a Provider to indicate that it cannot complete a requested create either due to some mis-configuration such as bad login credentials on connection create by throwing a JMSException. If the Provider does not support creating of the indicated resource such as a Temporary Queue etc the provider may throw an UnsupportedOperationException to indicate this.
        Parameters:
        resource - The JmsResouce instance that indicates what is being created.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • start

        void start​(JmsResource resource,
                   AsyncResult request)
            throws ProviderException
        Starts the Provider version of the given JmsResource. For some JMS Resources it is necessary or advantageous to have a started state that must be triggered prior to it's normal use. An example of this would be a MessageConsumer which should not receive any incoming messages until the JMS layer is in a state to handle them. One such time would be after connection recovery. A JMS consumer should normally recover with it's prefetch value set to zero, or an AMQP link credit of zero and only open up the credit window once all Connection resources are restored. The provider is required to implement this method and not throw any error other than an ProviderException if a communication error occurs. The start operation is not required to have any effect on the provider resource but must not throw UnsupportedOperation etc.
        Parameters:
        resource - The JmsResouce instance that indicates what is being started.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • stop

        void stop​(JmsResource resource,
                  AsyncResult request)
           throws ProviderException
        Stops (pauses) the Provider version of the given JmsResource, the resource would then need to be started again via a call to start() For some JMS Resources it is necessary or advantageous to have a stopped state that can be triggered to stop the resource generating new events or messages. An example of this would be a JMS Session which should not receive any incoming messages for any consumers until the JMS layer is in a state to handle them. One such time would be during a transaction rollback. A JMS Session should normally ensure that messages received in a transaction are set to be redelivered prior to any new deliveries on a transaction rollback. The provider is required to implement this method and not throw any error other than an ProviderException if a communication error occurs. The stop operation is not required to have any effect on the provider resource but must not throw UnsupportedOperation etc.
        Parameters:
        resource - The JmsResouce instance that indicates what is being stopped.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • destroy

        void destroy​(JmsResource resource,
                     AsyncResult request)
              throws ProviderException
        Instruct the Provider to dispose of a given JmsResource. The provider is given a JmsResource which it should use to remove any associated resources and inform the remote Broker instance of the removal of this resource. If the Provider cannot destroy the resource due to a non-communication error such as the logged in user not have role access to destroy the given resource it may throw an instance of JMSException to indicate such an error.
        Parameters:
        resource - The JmsResouce that identifies a previously created JmsResource.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • send

        void send​(JmsOutboundMessageDispatch envelope,
                  AsyncResult request)
           throws ProviderException
        Sends the JmsMessage contained in the outbound dispatch envelope.
        Parameters:
        envelope - the message envelope containing the JmsMessage to send.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • acknowledge

        void acknowledge​(JmsSessionId sessionId,
                         ProviderConstants.ACK_TYPE ackType,
                         AsyncResult request)
                  throws ProviderException
        Called to acknowledge all messages that have been delivered in a given session. This method is typically used by a Session that is configured for client acknowledge mode. The acknowledgement should only be applied to Messages that have been marked as delivered and not those still awaiting dispatch.
        Parameters:
        sessionId - the ID of the Session whose delivered messages should be acknowledged.
        ackType - The type of acknowledgement being done.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • acknowledge

        void acknowledge​(JmsInboundMessageDispatch envelope,
                         ProviderConstants.ACK_TYPE ackType,
                         AsyncResult request)
                  throws ProviderException
        Called to acknowledge a JmsMessage has been delivered, consumed, re-delivered...etc. The provider should perform an acknowledgement for the message based on the configured mode of the consumer that it was dispatched to and the capabilities of the protocol.
        Parameters:
        envelope - The message dispatch envelope containing the Message delivery information.
        ackType - The type of acknowledgement being done.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • commit

        void commit​(JmsTransactionInfo transactionInfo,
                    JmsTransactionInfo nextTransactionInfo,
                    AsyncResult request)
             throws ProviderException
        Called to commit an open transaction, and start a new one if a new transaction info object is provided. If this method throws an exception it is either because the commit failed, or the start of the next transaction failed. The caller can investigate the state of the provided next transaction object to determine if a new transaction was created. If the provider is unable to support transactions then it should throw an UnsupportedOperationException to indicate this. The Provider may also throw a JMSException to indicate a transaction was already rolled back etc.
        Parameters:
        transactionInfo - the transaction info that describes the transaction being committed.
        nextTransactionInfo - the transaction info that describes the new transaction that should be created.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • rollback

        void rollback​(JmsTransactionInfo transactionInfo,
                      JmsTransactionInfo nextTransactionInfo,
                      AsyncResult request)
               throws ProviderException
        Called to roll back an open transaction, and start a new one if a new transaction info object is provided. If this method throws an exception it is either because the commit failed, or the start of the next transaction failed. The caller can investigate the state of the provided next transaction object to determine if a new transaction was created.
        Parameters:
        transactionInfo - the transaction info that describes the transaction being rolled back.
        nextTransactionInfo - the transaction info that describes the new transaction that should be created.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • recover

        void recover​(JmsSessionId sessionId,
                     AsyncResult request)
              throws ProviderException
        Called to recover all unacknowledged messages for a Session in client Ack mode.
        Parameters:
        sessionId - the Id of the JmsSession that is recovering unacknowledged messages..
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • unsubscribe

        void unsubscribe​(java.lang.String subscription,
                         AsyncResult request)
                  throws ProviderException
        Remove a durable topic subscription by name. A provider can throw an instance of JMSException to indicate that it cannot perform the un-subscribe operation due to bad security credentials etc.
        Parameters:
        subscription - the name of the durable subscription that is to be removed.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • pull

        void pull​(JmsConsumerId consumerId,
                  long timeout,
                  AsyncResult request)
           throws ProviderException
        Request a remote peer send a Message to this client. A message pull request is usually only needed in the case where the client sets a zero prefetch limit on the consumer. If the consumer has a set prefetch that's greater than zero this method should just return without performing any action. timeout < 0 then it should remain open until a message is received. timeout = 0 then it returns a message or null if none available timeout > 0 then it should remain open for timeout amount of time. The timeout value when positive is given in milliseconds.
        Parameters:
        consumerId - the ID of the Consumer instance that is attempt to pull a message from the remote.
        timeout - the amount of time to tell the remote peer to keep this pull request valid.
        request - The request object that should be signaled when this operation completes.
        Throws:
        ProviderException - if an error occurs or the Provider is already closed.
      • getMessageFactory

        JmsMessageFactory getMessageFactory()
        Gets the Provider specific Message factory for use in the JMS layer when a Session is asked to create a Message type. The Provider should implement it's own internal JmsMessage core to optimize read / write and marshal operations for the connection.
        Returns:
        a JmsMessageFactory instance for use by the JMS layer.
      • newProviderFuture

        ProviderFuture newProviderFuture()
        Gets a ProviderFuture instance from the Provider for use in performing Provider calls that require an asynchronous completion to know when the call to the provider has succeeded or failed.
        Returns:
        a ProviderFuture for use in calling Provider methods that require a completion object.
      • newProviderFuture

        ProviderFuture newProviderFuture​(ProviderSynchronization synchronization)
        Gets a ProviderFuture instance from the Provider for use in performing Provider calls that require an asynchronous completion to know when the call to the provider has succeeded or failed.
        Parameters:
        synchronization - A ProviderSynchronization to assign to the resulting ProviderFuture.
        Returns:
        a ProviderFuture for use in calling Provider methods that require a completion object.
      • setProviderListener

        void setProviderListener​(ProviderListener listener)
        Sets the listener of events from this Provider instance.
        Parameters:
        listener - The listener instance that will receive all event callbacks.
      • getProviderListener

        ProviderListener getProviderListener()
        Gets the currently set ProdiverListener instance.
        Returns:
        the currently set ProviderListener instance.