private static Subscription getOrCreateSubscription(final PubSubAdmin pubSubAdmin,
                                                        final List<Subscription> allSubcriptions,
                                                        final String subscriptionName,
                                                        final Topic topic,
                                                        final Topic deadLetterTopic) {
        return allSubcriptions
            .stream()
            .filter(sub -> sub.getName().contains(subscriptionName))
            .findFirst()
            .orElseGet(() -> {
                val deadLetterPolicy = DeadLetterPolicy
                    .newBuilder()
                    .setDeadLetterTopic(deadLetterTopic.getName())
                    .setMaxDeliveryAttempts(5)
                    .build();
                return pubSubAdmin.createSubscription(Subscription.newBuilder()
                    .setName(subscriptionName)
                    .setTopic(topic.getName())
                    .setDeadLetterPolicy(deadLetterPolicy));
            });
    }
This is {@link CasGoogleCloudPubSubTicketRegistryAutoConfiguration}.

@author Misagh Moayyed
@since 7.0.0
support/cas-server-support-gcp-pubsub-ticket-registry/src/main/java/org/apereo/cas/config/CasGoogleCloudPubSubTicketRegistryAutoConfiguration.java