Class Broker

  • All Implemented Interfaces:
    com.softwareag.entirex.aci.BrokerImplFactory

    public final class Broker
    extends java.lang.Object
    implements com.softwareag.entirex.aci.BrokerImplFactory
    Represents a session instance of a Broker and handles the connection to EntireX Broker (TCP/IP or SSL/TLS), Broker SSL Agent, Broker HTTP(S) Agent or Direct RPC in Integration Server (TCP/IP or SSL/TLS).
    Connection-related information include:
    • the Broker address ("BrokerID") (for a definition see getBrokerID());
    • the user ID;
    • the token (optional for conversational communication, mandatory for UnitofWork communication).
    User ID and token can be changed after instantiating an object of this class with the reconnect() method.
    If a security object (either BrokerSecurity or EntireXSecurity) is available, this class also handles invocations to the security object.
    Instances of this class can be used safely in multi-threaded applications. However, all Broker calls going through the same instance of a Broker object will be serialized. Parallel Broker calls are supported when using multiple Broker objects.
    Since:
    6.1.1
    • Constructor Summary

      Constructors 
      Constructor Description
      Broker​(java.lang.String brokerID, java.lang.String userID)
      Creates a Broker object for the specified Broker address and user ID.
      Broker​(java.lang.String brokerID, java.lang.String userID, int poolSize)
      Creates a Broker object for the specified Broker address, user ID and socket pool size.
      Broker​(java.lang.String brokerID, java.lang.String userID, java.lang.String token)
      Creates a Broker object for the specified Broker address, user ID and token.
      Broker​(java.lang.String brokerID1, java.lang.String userID, java.lang.String token, int poolSize)
      Creates a Broker object for the specified Broker address, user ID, token and socket pool size.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void autoLogon​(java.lang.String password)
      Provides a password to this instance of the Broker object to be used in subsequent calls.
      void disconnect()
      Disconnects this Broker instance from the EntireX Broker.
      java.lang.String getApplicationName()
      Gets the name of the application.
      java.lang.String getBrokerID()
      Returns the Broker ID which was specified in the constructor of this class.
      int getCompressionLevel()
      Returns the compression level.
      java.lang.String getConnInfo()
      Returns connection information.
      byte[] getSecurityToken()
      Returns the current value of the security token.
      static ThreadRunner getThreadRunner()
      Gets the ThreadRunner object.
      java.lang.String getToken()
      Returns the token specified in the constructor of this class.
      static int getTrace()
      Returns the current trace level.
      static int getTransportTimeout()
      Gets the socket timeout value in seconds.
      java.lang.String getUniqueID()
      Returns a String object, which is unique for this instance of the Broker object.
      java.lang.String getUserID()
      Returns the current value of the user ID.
      static java.lang.String getVersion()
      Returns version information of the EntireX Java ACI package.
      boolean hasUserSecurity()
      Check if a user security object is used
      boolean isCommandLogging()
      Gets the state of the command logging.
      java.lang.String kernelversion()
      Retrieves the version of the EntireX Broker.
      void logoff()
      Logs off the application from EntireX Broker.
      void logon()
      Logs the application on to EntireX Broker, either as client or server.
      void logon​(java.lang.String password)
      Logs the application on to EntireX Broker with a password, either as client or server.
      void logon​(java.lang.String password, java.lang.String newpassword)
      Logs the application on to EntireX Broker with a password and new password, either as client or server.
      void reconnect​(java.lang.String userID)
      Reconnects this Broker object to the Broker address specified in the constructor and set the user ID.
      void reconnect​(java.lang.String userID, java.lang.String token)
      Reconnects this Broker object to the Broker address specified in the constructor and set user ID and token.
      void setApplicationName​(java.lang.String name)
      Sets the name of the application.
      void setCommandLogging​(boolean value)
      Switch command logging on and off.
      void setCompressionLevel​(int level)
      Sets the compression level.
      void setCompressionLevel​(java.lang.String level)
      Sets the compression level.
      void setSecurity​(BrokerSecurity securityObject)
      Specifies a security object, enables BrokerSecurity.
      void setSecurity​(BrokerSecurity securityObject, boolean doEncrypt)
      Deprecated.
      void setSecurity​(BrokerSecurity securityObject, int encryptionLevel)
      Deprecated.
      void setSecurity​(BrokerSecurity securityObject, int encryptionLevel, boolean autoMode)
      Deprecated.
      void setSecurityToken​(byte[] s)
      Sets the security token to the argument.
      static void setThreadRunner​(ThreadRunner t)
      Sets the ThreadRunner object, which wraps the method to start a new thread.
      static void setTrace​(int level)
      Sets the trace level.
      static void setTrace​(int level, java.io.PrintWriter pw)
      Sets the trace level.
      static void setTransportTimeout​(int timeout)
      Sets the socket timeout value in seconds.
      java.lang.String toString()
      Overrides the toString() method of the class Object.
      void useEntireXSecurity()
      Enables EntireX Security for this Broker instance.
      void useEntireXSecurity​(boolean autoMode)
      Enables EntireX Security for this Broker instance.
      void useEntireXSecurity​(int encryptionLevel)
      Deprecated.
      void useEntireXSecurity​(int encryptionLevel, boolean autoMode)
      Deprecated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.softwareag.entirex.aci.BrokerImplFactory

        createBrokerImpl
    • Field Detail

      • ENCRYPTION_LEVEL_NONE

        public static final int ENCRYPTION_LEVEL_NONE
        Specifies that the message data will not be encrypted.
        Since:
        EntireX 6.1.1
        See Also:
        Constant Field Values
      • ENCRYPTION_LEVEL_BROKER

        @Deprecated
        public static final int ENCRYPTION_LEVEL_BROKER
        Deprecated.
        Use SSL/TLS instead of EntireX encryption/decryption mechanism.

        Specifies that the message data for send and receive calls will be encrypted. Message data will be encrypted between the current application and the Broker. Encryption from the Broker to the partner application depends on the settings of the Broker and the partner application.
        See Also:
        Constant Field Values
      • ENCRYPTION_LEVEL_TARGET

        @Deprecated
        public static final int ENCRYPTION_LEVEL_TARGET
        Deprecated.
        Use SSL/TLS instead of EntireX encryption/decryption mechanism.

        Specifies that the message data for send and receive calls will be encrypted. Data will be encrypted between the current application and the Broker, as well as between the Broker and the partner application of this communication. It is guaranteed that the message is encrypted from the client to the server and vice versa.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Broker

        public Broker​(java.lang.String brokerID,
                      java.lang.String userID)
        Creates a Broker object for the specified Broker address and user ID.
        Parameters:
        brokerID - The BrokerID, for a definition see getBrokerID()
        userID - Authentication for the Broker instance.
        Throws:
        java.lang.IllegalArgumentException - if the broker ID or user ID is invalid.
      • Broker

        public Broker​(java.lang.String brokerID,
                      java.lang.String userID,
                      int poolSize)
        Creates a Broker object for the specified Broker address, user ID and socket pool size.
        Parameters:
        brokerID - The BrokerID, for a definition see getBrokerID()
        userID - Authentication for the Broker instance.
        poolSize - Maximum socket pool size, if 0 socket pooling is disabled.
        Throws:
        java.lang.IllegalArgumentException - if the broker ID or user ID is invalid.
      • Broker

        public Broker​(java.lang.String brokerID,
                      java.lang.String userID,
                      java.lang.String token)
        Creates a Broker object for the specified Broker address, user ID and token.
        Parameters:
        brokerID - The BrokerID, for a definition see getBrokerID()
        userID - Authentication for the Broker instance.
        token - Token for the Broker instance. Mandatory when using units of work.
        Throws:
        java.lang.IllegalArgumentException - if the broker ID or user ID is invalid.
        See Also:
        getToken()
      • Broker

        public Broker​(java.lang.String brokerID1,
                      java.lang.String userID,
                      java.lang.String token,
                      int poolSize)
        Creates a Broker object for the specified Broker address, user ID, token and socket pool size.
        Parameters:
        brokerID1 - The BrokerID, for a definition see getBrokerID()
        userID - Authentication for the Broker instance.
        token - Token for the Broker instance. Mandatory when using units of work.
        poolSize - Maximum socket pool size, if 0 socket pooling is disabled.
        Throws:
        java.lang.IllegalArgumentException - if the broker ID or user ID is invalid.
        See Also:
        getToken()
    • Method Detail

      • getVersion

        public static java.lang.String getVersion()
        Returns version information of the EntireX Java ACI package.
        Returns:
        Version information of Java ACI package as string.
      • getConnInfo

        public java.lang.String getConnInfo()
        Returns connection information. For TCP/IP or SSL connections the information contains host and port of the socket in use and details on the pool of sockets. This includes the socket pool size, 'Waits', the number of events waiting for a free socket, and 'MaxSockets', the accumulated number of sockets used during the lifetime of the application. For HTTP and HTTPS connections, this information is not available. This is for information purposes only.
        Returns:
        Connection information for this Broker object as string.
      • setTrace

        public static void setTrace​(int level,
                                    java.io.PrintWriter pw)
        Sets the trace level. If set to 0, then no trace output will be produced. Trace level 1 will trace all Broker calls and other major actions. Trace level 2 will dump the send and receive buffer. Trace level 3 will dump the buffers sent to the Broker and received from the Broker. Trace output will be written to the specified PrintWriter object.
        Parameters:
        level - Trace level.
        pw - instance of PrintWriter object which will receive the trace output.
        Since:
        EntireX 5.2.1
      • getTrace

        public static int getTrace()
        Returns the current trace level.
        Returns:
        Trace level as Int.
      • setTrace

        public static void setTrace​(int level)
        Sets the trace level. If set to 0, then no trace output will be produced. Trace level 1 will trace all Broker calls and other major actions. Trace level 2 will dump the send and receive buffer. Trace level 3 will dump the buffers sent to the Broker and received from the Broker. Can be initialized using the entirex.trace system property. Trace output will be written to standard output (java.lang.System.out) or the specified PrintWriter object.
        Parameters:
        level - Trace level.
        See Also:
        setTrace(int, java.io.PrintWriter)
      • getTransportTimeout

        public static int getTransportTimeout()
                                       throws BrokerException
        Gets the socket timeout value in seconds. Reads the system property entirex.timeout. The system property is read once. The system property wins over use of setTransportTimeout.
        Returns:
        the socket timeout value in seconds.
        Throws:
        BrokerException - if the property entirex.timeout is not a number or negative.
        Since:
        7.2.1.1
        See Also:
        setTransportTimeout(int)
      • setTransportTimeout

        public static void setTransportTimeout​(int timeout)
                                        throws BrokerException
        Sets the socket timeout value in seconds. Used for the transport of messages over TCP/IP. Not used with HTTP. This timeout value is used for new sockets. It does not change the timeout for sockets in use. The system property entirex.timeout may be used to configure the timeout value.
        Parameters:
        timeout - the socket timeout value in seconds.
        Throws:
        BrokerException - if the timeout value is negative.
        Since:
        7.2.1.1
        See Also:
        getTransportTimeout()
      • getThreadRunner

        public static ThreadRunner getThreadRunner()
        Gets the ThreadRunner object. The ThreadRunner object wraps the start method of the thread. This is used in application server to use the method of the application server to start a new thread.
        Returns:
        the ThreadRunner object
      • setThreadRunner

        public static void setThreadRunner​(ThreadRunner t)
        Sets the ThreadRunner object, which wraps the method to start a new thread.
        Parameters:
        t - the ThreadRunner object.
      • getSecurityToken

        public byte[] getSecurityToken()
        Returns the current value of the security token.
        Note that the logoff() method resets the security token to null after the call has been made.
        Returns:
        Security Token as byte array or null.
      • setSecurityToken

        public void setSecurityToken​(byte[] s)
        Sets the security token to the argument.
        Note that the logon() methods reset the security token to null before the call is done and the logoff() method resets the security token after the call has been made.
        Parameters:
        s - new Security Token as byte array.
      • getToken

        public java.lang.String getToken()
        Returns the token specified in the constructor of this class.
        Working with UnitofWorks requires a token. Using a token an application can reconnect to a Conversation or UnitofWork which was created by a different process.
        When working without a token, the EntireX Broker identifies an (client or server) application by the user ID and an internal unique identifier. This internal identifier is unique to each object instance of this Broker class.
        When a token is specified, the EntireX Broker identifies an application by the user ID and token. When working with tokens, ensure that all applications which communicate with the same EntireX Broker in parallel either use different user IDs or different tokens.
        Returns:
        Token as String or null.
      • hasUserSecurity

        public boolean hasUserSecurity()
        Check if a user security object is used
        Returns:
        true if usr security object is used
      • getBrokerID

        public java.lang.String getBrokerID()
        Returns the Broker ID which was specified in the constructor of this class.

        The Broker ID may have the following syntax depending on the used transport method:

        If the Broker ID starts with tcpip:// or if no protocol is specified TCP/IP will be used as the transport method. The Broker ID has the format HostnamePortnumber or tcpip://HostnamePortnumber.
        HostnamePortnumber can be either hostname, hostname:portnumber or :portnumber. The hostname is either an IP hostname or a numeric IP address, the default is localhost. The port number must be numeric, default for TCP/IP is 1971, default for SSL/TLS is 1958.

        If the Broker ID starts with ssl://, SSL/TLS will be used. The Broker ID has the format ssl://HostnamePortnumber?sslParams. sslParams need to specify trust_store=file, where file is the path name of a Java Keystore file which contains the list of trusted certificate authorities. Specify verify_server=no, if you do not want to check that the certificate of the SSL server is issued for the specified hostname.
        If the SSL server requests a client certificate, key_store=file and key_passwd=pwd have to be specified. Again file is the path name of a Java Keystore file which contains the private key and pwd is the password which is needed to access the private key entry in the Keystore. Note that the & character must not appear in the password.
        To enable specific TLS protocols, specify them as a comma-separated list in the parameter tls_protocols. All other supported protocols are then disabled. For example, if the value of this parameter is TLSv1.2, then the protocol TLSv1.2 is enabled and all other protocols are disabled.
        To enable specific cipher suites, specify them as a comma-separated list in the parameter cipher_suites. All other supported cipher suites are then disabled.
        To use a different type or provider for the trust store or the key store, specify them with the parameters trust_store_type, trust_store_provider, key_store_type or key_store_provider.
        If the parameter ignore_rfc_2818=yes is specified only the Common Name field is used for the hostname verification. Otherwise if the server certificate contains a subjectAltName extension of type dNSName, this name is used as the identity.

        If the Broker ID starts with http:// or https:// HTTP/HTTPS, tunneling via Broker HTTP(S) Agent will be used. The Broker ID has the format http://urlOfAgent?agentParams or https://urlOfAgent?agentParams. Note that the ?agentParams part is optional. The Broker HTTP(S) Agent accepts the parameters broker and log which overwrite the corresponding values in its configuration. If the parameter checkheaders=no is specified, the HTTP headers returned by the web server are not checked.

        For TCP/IP and SSL/TLS there are two parameters to control socket pooling. They are specified as part of the Broker ID. The parameter poolsize specifies the maximum number of socket connections which are kept in the socket pool. The default value for the poolsize parameter is 32. Set the poolsize parameter to 0 to disable the socket pooling. The poolsize parameter can also be set in the Broker constructor, see Broker(String,String,int) or Broker(String,String,String,int). Automatic closing of socket connections is controlled by the parameter pooltimeout. If a socket connection has not been used for the specified the number of seconds, it will be closed automatically. The default for this parameter is 300 seconds.

        Returns:
        Broker ID as string.
      • toString

        public java.lang.String toString()
        Overrides the toString() method of the class Object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        BrokerID as a String.
      • getUserID

        public java.lang.String getUserID()
        Returns the current value of the user ID.
        Returns:
        user ID as String.
      • useEntireXSecurity

        public void useEntireXSecurity​(boolean autoMode)
        Enables EntireX Security for this Broker instance.
        Parameters:
        autoMode - if true, let the Broker object figure out whether the Broker uses security. If the Broker uses security, set the EntireXSecurity object.
        Since:
        7.2.1
        See Also:
        logon(java.lang.String), autoLogon(java.lang.String)
      • disconnect

        public void disconnect()
        Disconnects this Broker instance from the EntireX Broker. This method allows the EntireX Java runtime to close or reuse the network resources allocated for this Broker instance. You can use this method after logoff. If disconnect is not used, the network resources are freed if the Broker object is destroyed or the socket pooling frees the unused sockets.
        You should call this method whenever your Java application continues to run after communication with this Broker instance has been terminated (i.e. in a multi-threading application).
        Reusing this Broker object will establish a new connection to the EntireX Broker.
        Since:
        EntireX 5.2.1
      • kernelversion

        public java.lang.String kernelversion()
                                       throws BrokerException
        Retrieves the version of the EntireX Broker.
        Returns:
        the Broker version and platform (if supported by Broker)
        Throws:
        BrokerException - if the Broker call fails.
      • getCompressionLevel

        public int getCompressionLevel()
        Returns the compression level.
        Returns:
        the compression level.
        Since:
        EntireX 7.1.1.0
      • setCompressionLevel

        public void setCompressionLevel​(int level)
        Sets the compression level. Valid compression levels are -1 (default compression), 0 (no compression), 1 (best speed) up to 9 (best compression).
        Parameters:
        level - the compression level.
        Since:
        EntireX 7.1.1.0
      • setCompressionLevel

        public void setCompressionLevel​(java.lang.String level)
        Sets the compression level. If the string starts with 'Y', compression is turned on with level 6. If the string starts with 'N', compression is turned off (Level 0). If the string denotes an integer between 0 and 9, compression is set to this level. In addition, you may use the strings 'BEST_COMPRESSION' (level 9), 'BEST_SPEED' (1), 'DEFAULT_COMPRESSION' (6), 'DEFLATED' (8), 'NO_COMPRESSION' (0). You may use the constants defined in class java.util.zip.Deflater.
        Parameters:
        level - the compression level.
        Since:
        EntireX 7.1.1.0
      • logon

        public void logon()
                   throws BrokerException
        Logs the application on to EntireX Broker, either as client or server.
        Throws:
        BrokerException - if the Broker call fails.
      • logon

        public void logon​(java.lang.String password)
                   throws BrokerException
        Logs the application on to EntireX Broker with a password, either as client or server.
        If EntireX Broker is running in a secured environment and a security object has been set, the logon() method performs the authentication process.
        Parameters:
        password - Password used for authentication together with the user ID.
        Throws:
        BrokerException - if the Broker call fails.
      • logon

        public void logon​(java.lang.String password,
                          java.lang.String newpassword)
                   throws BrokerException
        Logs the application on to EntireX Broker with a password and new password, either as client or server.
        If EntireX Broker is running in a secured environment and a security object has been set, the logon() method performs the authentication process.
        Parameters:
        password - Password used for authentication together with the user ID.
        newpassword - The new password is transmitted to the Broker security exit to allow a password change.
        Throws:
        BrokerException - if the Broker call fails.
      • autoLogon

        public void autoLogon​(java.lang.String password)
        Provides a password to this instance of the Broker object to be used in subsequent calls. Use this method only when EntireXSecurity is enabled. If autoLogon is used, no logon to the Broker will be done and the password will be sent with every subsequent Broker call. If logon is used, a logon to the Broker will be done and the password will be sent only with the logon call.
        You should use autoLogon whenever there is a high probability that a sequence of Broker calls is interrupted by a client non-activity timeout. In the case of a client timeout the 0008 0146 or 0002 0134 is avoided when autoLogon has been called.
        Parameters:
        password - Password used for authentication together with the user ID.
        Since:
        5.3.1.2
      • logoff

        public void logoff()
                    throws BrokerException
        Logs off the application from EntireX Broker. The logoff() method should be called after the last interaction with the Broker. EntireX Broker will release all resources used by the application.
        Throws:
        BrokerException - a Broker Exception
      • reconnect

        public void reconnect​(java.lang.String userID)
        Reconnects this Broker object to the Broker address specified in the constructor and set the user ID. If this changes the user ID, call logon afterwards.
        Parameters:
        userID - Authentication for the Broker instance.
        Throws:
        java.lang.IllegalArgumentException - if the user ID is invalid.
        Since:
        EntireX 5.2.1
      • reconnect

        public void reconnect​(java.lang.String userID,
                              java.lang.String token)
        Reconnects this Broker object to the Broker address specified in the constructor and set user ID and token. If this changes the user ID, call logon afterwards.
        Parameters:
        userID - Authentication for the Broker instance.
        token - Token for the Broker instance.
        Throws:
        java.lang.IllegalArgumentException - if the user ID is invalid.
        Since:
        EntireX 5.2.1
      • getUniqueID

        public java.lang.String getUniqueID()
                                     throws java.lang.IllegalStateException
        Returns a String object, which is unique for this instance of the Broker object. A value can be returned only when at least one Broker call has been made using this Broker instance. Otherwise an IllegalStateException is thrown.

        Calling this method for the same Broker instance always returns the same value.

        Returns:
        uniqueID the unique string
        Throws:
        java.lang.IllegalStateException - if uniqueID cannot be obtained.
        Since:
        EntireX 7.1.1.0
      • getApplicationName

        public java.lang.String getApplicationName()
        Gets the name of the application.
        Returns:
        the name of the application.
      • setApplicationName

        public void setApplicationName​(java.lang.String name)
        Sets the name of the application. If the name is longer than 64 characters, the name is truncated to 64 characters.
        Parameters:
        name - the name of the application.
        Throws:
        java.lang.IllegalArgumentException - if the name is null or empty.
      • isCommandLogging

        public boolean isCommandLogging()
        Gets the state of the command logging.
        Returns:
        true if command logging is on. false otherwise.
      • setCommandLogging

        public void setCommandLogging​(boolean value)
        Switch command logging on and off. The value is used for all following calls of this Broker object.
        Parameters:
        value - true to turn command logging on, false to turn it off.