Class BrokerClusterPublisher


  • public class BrokerClusterPublisher
    extends java.lang.Object
    • Method Detail

      • disconnect

        public void disconnect()
                        throws BrokerException
        Disconnect BrokerClusterPublisher. Deletes the local client object, but leaves the client state on the broker for future reconnects.

        Note that destroy-on-disconnect clients will destroy themselves when disconnect happens, so disconnect is identical to destroy in behavior for such clients. May throw any communications exception, but the local client object is marked as disconnected even if an exception is thrown.

        Throws:
        BrokerInvalidClientException - If the client has been destroyed or disconnected.
        BrokerClusterPublisherException - If no client is found on the cluster pool or all the clients have been already destroyed or disconnected.
        BrokerException
      • destroy

        public void destroy()
                     throws BrokerException
        Destroy BrokerClusterPublisher. Destroys all the clients created on the territory brokers as part of the cluster operations. May throw any communications exception, but the local client object is marked as disconnected even if an exception is thrown.
        Throws:
        BrokerInvalidClientException - If any of the cluster client has been already destroyed or disconnected.
        BrokerClusterPublisherException - If no client is found on the cluster pool or all the clients have been already destroyed or disconnected.
        BrokerException
      • registerSelectionCallback

        public void registerSelectionCallback​(BrokerCPSelectionCallback obj,
                                              java.lang.Object client_data)
                                       throws BrokerException
        Register a cluster publisher selection callback for this client. Calling this on a client which already has an existing callback will replace that callback. 'obj' may be null to clear the callback. 'client_data' may be null. The callback method will be invoded whenever a cluster client needs to be selected from the cluster client pool in order to execute a publish operation. It will be called with an event or an array event to be published along with a BrokerInfo[] array containing a list of territory brokers to which cluster client connection exists at present.
        Throws:
        BrokerInvalidClientException - If the client has been destroyed or disconnected.
        BrokerNullParameterException - If obj is null.
        BrokerException
      • registerConnectionCallback

        public void registerConnectionCallback​(BrokerCPConnectionCallback obj,
                                               java.lang.Object client_data)
                                        throws BrokerException
        Register a connection callback for the cluster publisher. Calling this on a client which already has an existing callback will replace that callback. 'obj' may be null to clear the callback. 'client_data' may be null. The callback method will be called with connect_state set to CONNECT_STATE_DISCONNECTED if the client is disconnected. It will be called with CONNECT_STATE_CONNECTED when the client connection is first established. It will again be called with CONNECT_STATE_RECONNECTED when the cluster client reestablishes client connection
        Throws:
        BrokerInvalidClientException - If the client has been destroyed or disconnected.
        BrokerNullParameterException - If obj is null.
        BrokerException
      • excludeBroker

        public void excludeBroker​(java.lang.String brokerName)
                           throws BrokerException
        Exclude specified broker for cluster operations. This call just takes a broker name string as an argument. If the specified broker is found in the current cluster publisher's broker pool, it will be removed from the pool. The specified broker will not be considered for future cluster operations. If the broker is not found in the cluster publisher's broker pool, an exception will be thrown.
        Throws:
        BrokerInvalidClientException - If the client has been destroyed or disconnected.
        BrokerClusterPublisherException - If the specified broker is not part of the cluster publisher operation or the last single broker client connection found on the client pool.
        BrokerInvalidPortException - If the specified port is invalid
        BrokerException
      • includeBroker

        public void includeBroker​(java.lang.String brokerName)
                           throws BrokerException
        Include specified broker for cluster operations. This call just takes a broker name string as an argument. If the specified broker is found in the current cluster publisher's broker pool, it will be removed from the pool. The specified broker will be considered for future cluster operations. If the broker is not found or not in the territory or already present in the cluster pool, appropriate exception will be thrown.
        Throws:
        BrokerInvalidClientException - If the client has been destroyed or disconnected.
        BrokerClusterPublisherException - If the specified broker was not previously excluded from the client pool or the it is currently present in the client pool.
        BrokerInvalidPortException - If the specified port is invalid
        BrokerException
      • getClientGroup

        public java.lang.String getClientGroup()
        Get the client group name.
      • getClientId

        public java.lang.String getClientId()
        Get the application client identifier.
      • getMonitorClientId

        public java.lang.String getMonitorClientId()
        Get the cluster monitor client's identifier.
      • isConnected

        public boolean isConnected()
        Check if connected. This is a passive check, meaning it only tells if the BrokerClusterPublisher has been explicitly destryed or disconnected, or if an error occurred on a previous call which indicated that the connection was closed. No active test of the connection is made. Returns true if the connection is valid and is still connected, or false if not.
      • getApplicationName

        public java.lang.String getApplicationName()
        Get the application name.
      • getLastUsed

        public java.lang.String getLastUsed()
        Get the broker name on which the last cluster operation was executed.
      • toString

        public java.lang.String toString()
        Returns a string with the client information in a form suitable for human viewing.
        Overrides:
        toString in class java.lang.Object
      • getClusterPublisherInfo

        public BrokerEvent getClusterPublisherInfo()
                                            throws BrokerException
        Get the cluster publisher info. Info is set into a BrokerEvent as fields. The available values are:
        • client_id -- (unicode string) Client id
        • client_group -- (unicode string) Client Group
        • app_name -- (unicode string) Application Name
        • connection_callback -- (boolean) true, if a connection callback is registered; otherwise false.
        • selection_callback -- (boolean) true, if a selection callback is registered; otherwise false.
        • monitor_client -- (unicode string) Client id of the monitor client
        • brokers -- (structure array) An array of structures describing brokers used as part of cluster operations.
        • brokers[].broker_host -- (unicode string) Broker host name.
        • brokers[].broker_name -- (unicode string) Broker name.
        • brokers[].description -- (unicode string) Broker description.
        • brokers[].territory_name -- (unicode string) Broker's territory name.
        • exclude_brokers -- (unicode string array) An array of strings listing the broker names that are excluded from the cluster operations.
        Throws:
        BrokerException
      • getClusterPublisherStats

        public BrokerEvent getClusterPublisherStats()
                                             throws BrokerException
        Get the cluster publisher statistics. Statistics are set into a BrokerEvent as fields. The available values are:
        • now -- (date) Current time on the broker host.
        • numClients -- (int) Number of clients employed in cluster operations.
        • numExcludedBrokers -- (int) Number of brokers excluded from the cluster operations.
        • numEventsPublished -- (int) Number of events published using this publisher.
        • lastEventPublishTime -- (date) Time when last event was published by a member. Forever (zero date and time) if no events ever published.
        • numEventsDelivered -- (int) Number of events delivered using this cluster publisher.
        • lastEventDeliverTime -- (date) Time when last event was delivered using this cluter client. Forever (zero date and time) if no events ever delivered.
        • numEventsReceived -- (int) Number of events received as part of publish/deliverRequestAndWait operations on this cluster publisher.
        • lastEventReceiveTime -- (date) Time when last event was received on this cluter client. Forever (zero date and time) if no events ever received.
        • lastActivityOn -- (unicode string) Client id of the client on which the last operation was executed.
        Throws:
        BrokerException