Reputation: 194
I am trying to build a simple test spring boot app to consume messages from both GCP pubsub and RabbitMq using spring cloud stream. I am facing issue when trying use spring.cloud.stream.binders
I am using below dependencies
implementation 'org.springframework.cloud:spring-cloud-stream:3.0.0.RELEASE'
implementation 'org.springframework.cloud:spring-cloud-stream-binder-rabbit:3.0.0.RELEASE'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter:1.2.8.RELEASE'
implementation 'org.springframework.cloud:spring-cloud-gcp-autoconfigure:1.2.8.RELEASE'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter-pubsub:1.2.8.RELEASE'
implementation 'org.springframework.cloud:spring-cloud-gcp-pubsub-stream-binder:1.2.8.RELEASE'
Below yml config causes application to fails. The gcp pub sub fails stating that it could not find PubSubAdmin bean
.
spring:
cloud:
gcp:
pubsub:
enabled: true
project-id: projectId
credentials:
location: file:/Users/user/.config/gcloud/application_credentials.json
stream:
bindings:
rabbit1: # The input binding name
destination: rabbit-test-queue
group: rabbit-test-queue # Consumer group for the input channel
binder: rabbit
consumer:
bind-queue: false
declare-exchange: false
queue-name-group-only: true
pubsub1:
destination: topic # Specifies the topic name.
group: subscription # Defines the consumer group.
binder: pubsub
binders:
# Define RabbitMQ binder
rabbit:
type: rabbit
default-candidate: true
environment:
spring:
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
# Define the GCP Pub/Sub binder
pubsub:
type: pubsub # Reference your actual custom binder class
default-candidate: false
environment:
spring:
cloud:
gcp:
pubsub:
project-id: projectID
credentials:
location: file:/Users/user/.config/gcloud/application_credentials.json
binder:
auto-create-subscriptions: false
auto-create-topics: false
I can make this work if I do not specify binders under stream but instead use specific provider config
Below yml config works
spring:
cloud:
gcp:
pubsub:
enabled: true
project-id: projectId
credentials:
location: file:/Users/user/.config/gcloud/application_credentials.json
stream:
rabbit:
bindings:
rabbit1:
consumer:
bind-queue: false
declare-exchange: false
queue-name-group-only: true
gcp:
pubsub:
default:
consumer:
auto-create-resources: false
bindings:
input1:
consumer:
subscription-name: subscription
auto-create-resources: false
binder:
auto-create-subscriptions: false
auto-create-topics: false
bindings:
input1:
destination: topic # Specifies the topic name.
group: subscription # Defines the consumer group.
binder: pubsub
rabbit1: # The input binding name
destination: rabbit-test-queue
group: rabbit-test-queue # Consumer group for the input channel
binder: rabbit
consumer:
bind-queue: false
declare-exchange: false
queue-name-group-only: true
Is this expected behaviour or do I need to disable some auto configuration or add some other dependencies. I see that the PubSubBinderConfiguration class has @ConditionalOnMissingBean(Binder.class)
Upvotes: 0
Views: 48