Class CachingPublisherFactory
java.lang.Object
com.google.cloud.spring.pubsub.support.CachingPublisherFactory
- All Implemented Interfaces:
PublisherFactory
The caching implementation of the
PublisherFactory
.
Creates Publisher
s for topics once using delegate, caches and reuses them.
-
Constructor Summary
ConstructorDescriptionCachingPublisherFactory
(PublisherFactory delegate) Constructs a cachingPublisherFactory
using the delegate. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.cloud.pubsub.v1.Publisher
createPublisher
(String topic) Creates aPublisher
for a given topic.Returns the delegate.void
shutdown()
Shutdown all cachedPublisher
gracefully.
-
Constructor Details
-
CachingPublisherFactory
Constructs a cachingPublisherFactory
using the delegate.- Parameters:
delegate
- aPublisherFactory
that needs to be cached.
-
-
Method Details
-
createPublisher
Description copied from interface:PublisherFactory
Creates aPublisher
for a given topic.- Specified by:
createPublisher
in interfacePublisherFactory
- Parameters:
topic
- destination topic- Returns:
- fully configured publisher
-
getDelegate
Returns the delegate.- Returns:
- the delegate.
-
shutdown
@PreDestroy public void shutdown()Shutdown all cachedPublisher
gracefully.
-