Adding prefix to RabbitMQ queues and exchanges in Spring Cloud dataflow backend - spring

I would like to utilize my own RabbitMQ instance as the middleware broker for Spring Cloud Data Flow.
The problem is that we have a prefix and suffix policy on exchange and queue creation that has to be in place.
Is it possible to force Spring Cloud Data Flow to add this prefix and suffix?
Example:
RABBITMQ_QUEUE_PREFIX="TEAM1"
RABBITMQ_QUEUE_SUFFIX="IN"
RABBITMQ_EXCHANGE_PREFIX="TEAM1"
RABBITMQ_EXCHANGE_SUFFIX="OUT"
To result in queues and exchanges:
TEAM1.queuename.IN
TEAM1.exchangename.OUT

You can configure the prefix at the application level (e.g. in application.properties) or set as a deployer property in SCDF. See https://docs.spring.io/spring-cloud-stream-binder-rabbit/docs/current/reference/html/spring-cloud-stream-binder-rabbit.html#_rabbitmq_consumer_properties

Related

Does spring cloud stream support dynamic routing, which is rabbitmq feaure?

Is dynamic routing is same as dynamic destination binding in spring cloud stream ?
Dynamic routing as per rabbit all producer published to same queue, producer configured with routingKeyExpression and consumer listener configured with bindingRoutingKey and exchange routes the message to matched bindingKey.
does this can be accomplished using stream bridge or BinderAwareChannelResolver? If not how does spring manage with this in case someone wants to move from rabbit to any other broker.
Yes this can be accomplished with StreamBridge, RoutingFunction, spring.cloud.stream.sendto.destination etc., depending on your use case which is not clear from your post, hence I am giving you everything.
You can find more information here and here for StreamBridge.
The BinderAwareChannelResolver is deprecated in favor of StreamBridge

RabbitMq: prohibit consumer from creating queues

Our java spring boot application is creating/declaring queues (if they do not exist) after successful connection to a certain exchange / topic.
Is it possible (from rabbitmq admin panel) to prohibit certain users (in this case the one used by this spring boot app) from creating/declaring a queue if it does no exist?
Thanks!
You can configure the permissions of the user a Spring-Boot app uses to connect to the broker.
This is achieved by supplying 3 regex (configuration, write, read), if you let the first one empty ("^$"), the user will not be able to delare any queue as mentionned in the complete documentation
You can also disable the RabbitAdmin bean by adding the following property to the app configuration file spring.rabbitmq.dynamic=false, so Spring will not try to declare anything.

How Spring BOOT Logger Actuator behaves in clustered environment?

I have a query related to Spring Boot Actuator. Through Actuator I can change the log level dynamically.
In clustered environment how it works?
If I do the REST (POST) call to change the log level then in which node it will be applied?
Or will it be applied to all the nodes?
If it gets applied to all the nodes in the cluster then how to restrict it to only a particular node?
You should use external configuration server (spring cloud config) and use spring cloud bus to reflect configuration changes into all the servers of your cluster.
Place your log configuration on the configuration server, on each change, a message will be sent to a message broker (like rabbitMq) to all the servers listening to the config.

Create RabbitMQ queues with spring boot

I would like to create rabbitmq queues everytime my Spring Boot application starts (if queues don't exists already).
In the current architecture, we manually create durabl queues using rabbitmq admin. But we want our application, to detect new queues in the configuration and create durable ones if they don't exist
That is built-in feature of Spring AMQP:
The AMQP specification describes how the protocol can be used to configure Queues, Exchanges and Bindings on the broker. These operations which are portable from the 0.8 specification and higher are present in the AmqpAdmin interface in the org.springframework.amqp.core package.
Since amqpAdmin bean is auto-configured by Spring Boot, you only need to declare particular #Beans for Queues, Exchanges and Bindings between them.

How can I list queues on a RabbitMQ exchange using Java?

I had two host every host have some queue.I want to list all queue declared by other node.
On basis of that queues, I have to perform some operation.
I didn't get any method which will list all queues from amqp server.
Thanks
Spring AMQP does not provide a direct abstraction, but RabbitMQ provides a ReST API via its management plugin.
You can use the Spring RestTemplate to query the API.

Resources