-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a26e9dc
commit ef4fc9a
Showing
4 changed files
with
73 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
pubsub/runtime/src/main/java/io/quarkiverse/googlecloudservices/pubsub/PubSubProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.quarkiverse.googlecloudservices.pubsub; | ||
|
||
import com.google.cloud.pubsub.v1.SubscriptionAdminClient; | ||
import com.google.cloud.pubsub.v1.TopicAdminClient; | ||
import jakarta.enterprise.inject.Disposes; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Producer class for PubSub beans. | ||
*/ | ||
public class PubSubProducer { | ||
|
||
@Inject | ||
QuarkusPubSub quarkusPubSub; | ||
|
||
/** | ||
* Makes the subscription admin client available as CDI bean | ||
*/ | ||
@Produces | ||
public SubscriptionAdminClient subscriptionAdminClient() throws IOException { | ||
return SubscriptionAdminClient.create(quarkusPubSub.subscriptionAdminSettings()); | ||
} | ||
|
||
/** | ||
* CDI Dispose method for {@link #subscriptionAdminClient()}. Shouldn't be called directly | ||
*/ | ||
public void shutdownSubscriptionAdminClient(@Disposes SubscriptionAdminClient subscriptionAdminClient) { | ||
subscriptionAdminClient.close(); | ||
} | ||
|
||
/** | ||
* Makes the topic admin client available as a CDI bean | ||
*/ | ||
@Produces | ||
public TopicAdminClient topicAdminClient() throws IOException { | ||
return TopicAdminClient.create(quarkusPubSub.topicAdminSettings()); | ||
} | ||
|
||
/** | ||
* CDI Dispose method for {@link #topicAdminClient()}. Shouldn't be called directly | ||
*/ | ||
public void shutdownTopicAdminClient(@Disposes TopicAdminClient topicAdminClient) { | ||
topicAdminClient.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters