Want to use same topic across multiple environments like QA, Staging and Prod.
I want to use same topic across multiple environments like QA, Staging and Prod. Is it possible to use Event broker with topic name domain/test/{env}/supply, where {env} is the variable dynamically replaced with a value sent from client in message header? I know the actual Topic name is required to be provided from Publisher end but creating different set of topics for each environment is an effort.
Answers
-
Hey @Rudra ! While your approach is completely valid since topics in Solace are dynamic and you can programmatically generate a topic for every environment, you also have the option of creating different message VPNs for every environment.
You can read more about message VPNs here https://docs.solace.com/Configuring-and-Managing/Managing-Message-VPNs.htm
Hopefully this gives you a good start with what you want to do 👍
0 -
@Rudra depending on the programming language you are using to develop your publisher, you can build your topic String in your code prior to publishing. So for example if you are using Python check out this sample on how dynamic topics are created priori to publishing https://github.com/SolaceSamples/solace-samples-python/blob/master/patterns/direct_publisher.py#L82
Basically if you want to define the target environment as a system environment variable prior to running your publisher:
env = os.environ.get('DEPLOYMENT_ENV') topic = Topic.of(f'domain/test/{env}/supply') direct_publisher.publish(destination=topic, message=outbound_msg)
Note: you can also run the same code and find a way to pass the environment of choice to your program before running the publisher (e.g. via env variables, or program parameters...etc)
You can take the same approach with Java as well https://github.com/SolaceSamples/solace-samples-java/blob/main/src/main/java/com/solace/samples/java/patterns/DirectPublisher.java#L106-L108
Hopefully this helps!
1 -
I would recommend using different brokers for different environments. You don't want your lower level environment to be going through your production brokers. This can lead to activity in lower level environments impacting your production applications.
Instead, you should have at least one broker for lower level environment and separate broker(s) for production. You can then use the same topic across different environments. Your applications will connect to different brokers based on the environment.
Additionally, for your production setup, make sure you have considered redundancy such as High Availability and Disaster Recovery.
0