Class SpringAsyncServiceBase

java.lang.Object
de.iip_ecosphere.platform.services.environment.spring.SpringAsyncServiceBase
Direct Known Subclasses:
TestSpringBroker.MyServiceBase

@Component public class SpringAsyncServiceBase extends Object
Basic Spring Service functions for asynchronous forward/backward data flows via the transport layer.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Records information about an installed callback.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<T>
    createReceptionCallback(String channel, Consumer<T> consumer, Class<T> cls)
    Creates a reception callback.
    <T> de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<T>
    createReceptionCallback(String channel, Consumer<T> consumer, Class<T> cls, String routingKey)
    Creates a reception callback.
    void
    Called at end of lifecycle to get rid of callbacks.
    void
    Detach all callbacks.
    protected void
    Ensures the setup data.
    static String
    getAppInstIdSuffix(de.iip_ecosphere.platform.services.environment.Service service, String separator)
    Composes a channel suffix id for a service possibly including the application instance id.
    protected void
    send(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind)
    Sends a message of a certain kind and cares fore queuing.
    static void
    send(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind, String... routingKeys)
    Sends a message of a certain kind and cares fore queuing.
    void
    sendTraceRecord(de.iip_ecosphere.platform.transport.status.TraceRecord record)
    Sends a trace record.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SpringAsyncServiceBase

      public SpringAsyncServiceBase()
  • Method Details

    • createReceptionCallback

      protected <T> de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<T> createReceptionCallback(String channel, Consumer<T> consumer, Class<T> cls)
      Creates a reception callback.
      Type Parameters:
      T - the type of data handled by the callback
      Parameters:
      channel - the channel to listen to
      consumer - the consumer function of the service
      cls - the type of data handled by the callback
      Returns:
      the callback or null if the callback cannot be created/registered with Transport
    • ensureSetup

      protected void ensureSetup()
      Ensures the setup data.
    • createReceptionCallback

      public <T> de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<T> createReceptionCallback(String channel, Consumer<T> consumer, Class<T> cls, String routingKey)
      Creates a reception callback. [public for testing]
      Type Parameters:
      T - the type of data handled by the callback
      Parameters:
      channel - the channel to listen to
      consumer - the consumer function of the service
      cls - the type of data handled by the callback
      routingKey - if null, empty or in Transport.addGlobalRoutingKey(String) then use the global transport instance, else the local transport instance from Transport; may use both transport instances
      Returns:
      the callback or null if the callback cannot be created/registered with Transport
    • send

      protected void send(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind)
      Sends a message of a certain kind and cares fore queuing.
      Parameters:
      sender - the sender including the message
      kind - the kind of the message for logging
    • send

      public static void send(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind, String... routingKeys)
      Sends a message of a certain kind and cares fore queuing.
      Parameters:
      sender - the sender including the message
      kind - the kind of the message for logging
      routingKeys - if null, empty or in Transport.addGlobalRoutingKey(String) then use the global transport instance, else the local transport instance from Transport; may use both transport instances
      See Also:
      • Transport.addGlobalRoutingKey(String)
    • sendTraceRecord

      public void sendTraceRecord(de.iip_ecosphere.platform.transport.status.TraceRecord record)
      Sends a trace record. Caches messages if no connector is available.
      Parameters:
      record - the record to be sent
    • detach

      public void detach()
      Detach all callbacks.
    • destroy

      @PreDestroy public void destroy()
      Called at end of lifecycle to get rid of callbacks.
    • getAppInstIdSuffix

      public static String getAppInstIdSuffix(de.iip_ecosphere.platform.services.environment.Service service, String separator)
      Composes a channel suffix id for a service possibly including the application instance id.
      Parameters:
      service - the service instance
      separator - the separator string to insert between the ids
      Returns:
      the id suffix, may be empty