Class SpringAsyncServiceBase
java.lang.Object
de.iip_ecosphere.platform.services.environment.spring.SpringAsyncServiceBase
- Direct Known Subclasses:
TestSpringBroker.MyServiceBase
Basic Spring Service functions for asynchronous forward/backward data flows via the transport layer.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classRecords information about an installed callback. -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <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.voiddestroy()Called at end of lifecycle to get rid of callbacks.voiddetach()Detach all callbacks.protected voidEnsures the setup data.static StringgetAppInstIdSuffix(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 voidsend(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind) Sends a message of a certainkindand cares fore queuing.static voidsend(de.iip_ecosphere.platform.support.function.IOConsumer<de.iip_ecosphere.platform.transport.connectors.TransportConnector> sender, String kind, String... routingKeys) Sends a message of a certainkindand cares fore queuing.voidsendTraceRecord(de.iip_ecosphere.platform.transport.status.TraceRecord record) Sends a trace record.
-
Field Details
-
callbacks
-
-
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 toconsumer- the consumer function of the servicecls- 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 toconsumer- the consumer function of the servicecls- the type of data handled by the callbackroutingKey- if null, empty or inTransport.addGlobalRoutingKey(String)then use the global transport instance, else the local transport instance fromTransport; 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 certainkindand cares fore queuing.- Parameters:
sender- the sender including the messagekind- 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 certainkindand cares fore queuing.- Parameters:
sender- the sender including the messagekind- the kind of the message for loggingroutingKeys- if null, empty or inTransport.addGlobalRoutingKey(String)then use the global transport instance, else the local transport instance fromTransport; may use both transport instances- See Also:
-
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 instanceseparator- the separator string to insert between the ids- Returns:
- the id suffix, may be empty
-