java.lang.Object
de.iip_ecosphere.platform.transport.spring.binder.generic.GenericClient

@Component public class GenericClient extends Object
An generic client for a single binder instance. Typically, different binders subscribe to different topics. The implementation uses queuing/a consumer pattern to cope with threading problems. Partially public for testing.
Author:
Holger Eichelberger, SSE
  • Field Details

    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
    • lastInstance

      private static GenericClient lastInstance
    • connector

      private de.iip_ecosphere.platform.transport.connectors.TransportConnector connector
    • globalInstance

      private boolean globalInstance
    • configuration

      private GenericConfiguration configuration
    • topics

      private Map<String,de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>> topics
  • Constructor Details

    • GenericClient

      public GenericClient()
      Creates and registers an instance.
  • Method Details

    • getLastInstance

      public static GenericClient getLastInstance()
      Returns the last instance created for this class. [testing]
      Returns:
      the last instance
    • getConfiguration

      public GenericConfiguration getConfiguration()
      Returns the actual configuration. [for testing]
      Returns:
      the configuration, may be null
    • createClient

      public void createClient(GenericConfiguration config)
      Creates the client based on a given AMQP client configuration.
      Parameters:
      config - the AMQP configuration to take the connection information from
    • stopClient

      public void stopClient()
      Stops the client.
    • subscribeTo

      boolean subscribeTo(String topic, GenericClient.ArrivedCallback arrivedCallback)
      Subscribes to topic if topic is not blacklisted by GenericConfiguration.isFilteredTopic(String).
      Parameters:
      topic - the topic to unsubscribe from
      arrivedCallback - the callback to be called when a message arrived
      Returns:
      true if done/successful, false else
    • unsubscribeFrom

      boolean unsubscribeFrom(String topic)
      Unsubscribes from topic if topic is not blacklisted by GenericConfiguration.isFilteredTopic(String).
      Parameters:
      topic - the topic to unsubscribe from
      Returns:
      true if done/successful, false else
    • send

      void send(String topic, byte[] payload)
      Sends payload to topic.
      Parameters:
      topic - the topic to send to
      payload - the payload to send