omq.common.broker

## Class Broker

- java.lang.Object
- - omq.common.broker.Broker

-     public class Broker
      extends java.lang.Object

  A "broker" allows a new connection to a RabbitMQ server. Under this connection it can have binded object and proxies.
  Author:
    Sergi Toda

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Broker(java.util.Properties env)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind(java.lang.String reference, RemoteObject remote)` Binds the reference to the specified remote object.
    `void` | `bind(java.lang.String reference, RemoteObject remote, java.util.Properties env)` Binds the reference to the specified remote object.
    `void` | `closeConnection()` This method close the broker's connection
    `com.rabbitmq.client.Channel` | `getChannel()` Return the broker's channel
    `com.rabbitmq.client.Connection` | `getConnection()`
    `java.util.Properties` | `getEnvironment()`
    `com.rabbitmq.client.Channel` | `getNewChannel()` Creates a new channel using the Broker's connection
    `ResponseListener` | `getResponseListener()`
    `Serializer` | `getSerializer()`
    `<T extends Remote> T` | `lookup(java.lang.String reference, java.lang.Class<T> contract)` Returns the remote object for specified reference.
    `<T extends Remote> T` | `lookupMulti(java.lang.String reference, java.lang.Class<T> contract)` Returns the remote object for specified reference.
    `void` | `stopBroker()` This method stops the broker's connection and all the threads created
    `void` | `tryConnection(java.util.Properties env)` This function is used to send a ping message to see if the connection works
    `void` | `unbind(java.lang.String reference)` Unbinds a remoteObject from its reference and kills all the threads created.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Broker

          public Broker(java.util.Properties env)
                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

  - ### Method Detail

    - #### stopBroker

          public void stopBroker()
                          throws java.lang.Exception

      This method stops the broker's connection and all the threads created
      Throws:
        `java.lang.Exception`

    - #### getConnection

          public com.rabbitmq.client.Connection getConnection()
                                                       throws java.lang.Exception

      Returns:
        Broker's connection
      Throws:
        `java.lang.Exception`

    - #### closeConnection

          public void closeConnection()
                               throws java.io.IOException

      This method close the broker's connection
      Throws:
        `java.io.IOException`

    - #### getChannel

          public com.rabbitmq.client.Channel getChannel()
                                                 throws java.lang.Exception

      Return the broker's channel
      Returns:
        Broker's channel
      Throws:
        `java.lang.Exception`

    - #### getNewChannel

          public com.rabbitmq.client.Channel getNewChannel()
                                                    throws java.io.IOException

      Creates a new channel using the Broker's connection
      Returns:
        newChannel
      Throws:
        `java.io.IOException`

    - #### lookup

          public <T extends Remote> T lookup(java.lang.String reference,
                                    java.lang.Class<T> contract)
                                  throws RemoteException

      Returns the remote object for specified reference.
      Parameters:
        `reference` - - Binding name
        `contract` - - Remote Interface
      Returns:
        newProxy
      Throws:
        `RemoteException`

    - #### lookupMulti

          public <T extends Remote> T lookupMulti(java.lang.String reference,
                                         java.lang.Class<T> contract)
                                       throws RemoteException

      Returns the remote object for specified reference. This function returns an special type of proxy, every method invoked will be multi and asynchronous.
      Parameters:
        `reference` - - Binding name
        `contract` - - Remote Interface
      Returns:
        newProxy
      Throws:
        `RemoteException`

    - #### bind

          public void bind(java.lang.String reference,
                  RemoteObject remote)
                    throws RemoteException,
                           AlreadyBoundException

      Binds the reference to the specified remote object. This function uses the broker's environment
      Parameters:
        `reference` - - Binding name
        `remote` - - RemoteObject to bind
      Throws:
        `RemoteException` - If the remote operation failed
        `AlreadyBoundException` - If name is already bound.

    - #### bind

          public void bind(java.lang.String reference,
                  RemoteObject remote,
                  java.util.Properties env)
                    throws RemoteException,
                           AlreadyBoundException

      Binds the reference to the specified remote object. This function uses the broker's environment
      Parameters:
        `reference` - - Binding name
        `remote` - - RemoteObject to bind
        `env` - - RemoteObject environment. You can set how many threads will be listen to the reference, the multiqueue name and the properties of the object queue and multiqueue
      Throws:
        `RemoteException` - If the remote operation failed
        `AlreadyBoundException` - If name is already bound.

    - #### unbind

          public void unbind(java.lang.String reference)
                      throws RemoteException,
                             java.io.IOException

      Unbinds a remoteObject from its reference and kills all the threads created.
      Parameters:
        `reference` - - Binding name
      Throws:
        `RemoteException` - If the remote operation failed
        `java.io.IOException` - If there are problems while killing the threads

    - #### tryConnection

          public void tryConnection(java.util.Properties env)
                             throws java.lang.Exception

      This function is used to send a ping message to see if the connection works
      Parameters:
        `env` -
      Throws:
        `java.lang.Exception`

    - #### getEnvironment

          public java.util.Properties getEnvironment()

    - #### getResponseListener

          public ResponseListener getResponseListener()

    - #### getSerializer

          public Serializer getSerializer()