From my spring-boot service(with camel) I need to connect to two RabbitMQ instances;not cluster, but altogether different instances(with diff IP, vhost and credentials)
Versions: spring-boot: 1.5.12 and camel: 2.21.5
I want to create multiple connection factories and specify them in the camel endpoint name like this.
rabbitmq:exchange1?connectionFactory=#customFactory1
rabbitmq:exchange2?connectionFactory=#customFactory2
Currently this is not supported as RabbitAnnotationDrivenConfiguration class expects only one instance of ConnectionFactory
Even if I qualify the ConnectionFactory Beans with #Qualifier/#Primary the connectionFactory query param used in camel endpoint is ignored (or) properties from camel.component.rabbitmq are taking priority
I'm now using a workaround to specify all the connection properties in the endpoint name like
rabbitmq:exchange1?host=<host>&vhost=<vhost>&username=something&password=something
Is there a better way to achieve this...?
Related
I have two Spring Boot applications running on one server. Both use embedded ActiveMQ JMS. I want to have separate JMS instance for each application. How could I set the port for each of them? Is there any property like spring.activemq.port?
When I run second application I get the following expected error:
Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create JMX connector, trying to remedy this issue.
I have same issue, two SpringBoot process and I want to send messages through the ActiveMQ.
First I got it working starting another process with the ActiveMQ, and configuring both SpringBoot process into their application.properties files with:
spring.activemq.broker-url = tcp://localhost:61616
Whit this configuration you tell Springboot to connect to a external ActiveMq service. This works, but then I need to first start the ActiveMQ and after my Springboot process. In some page I have read this must be the way to use at production environments.
Another solution is to use the embedded JMS support at one of the SpringBoot process, for this way you need to configure the ActiveMQ broker service listening for connections in one Springboot process. You can do this adding a Broker bean:
#Bean
public BrokerService broker() throws Exception {
final BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:61616");
broker.addConnector("vm://localhost");
broker.setPersistent(false);
return broker;
}
Now this SpringBoot process with this bean do not need the previous configuration at the application.properties, and this will be the first process to start, in order to have the ActiveMQ listening for other process connections.
The other Springboot process still need to have the configuration at the application.properties in order to connect to the ActiveMq created by the first process.
Hope it helps you.
Best regards.
You can configure the broker url using the spring.activemq.broker-url property, e.g. set it to spring.activemq.broker-url=tcp://localhost:61616.
For a comprehensive reference of available properties you can check out this reference.
spring.activemq.broker-url
Including the port according to spring boot properties
I am currently successfully using an MQConnectionFactory to connect and post to a Websphere MQ queue using JMS.
However I'm getting a requirement from a client that I must use mqclient.ini instead.
So my question is, for a 'standard' JMS setup, should I be using:
Straight up MQConnectionFactory instance
A JMS configuration file
An mqclient.ini file
? What would one use one over the other? Does one take precedence over another?
The mqclient.ini and JMSconfig files are used setting attributes like what client side exits to use, TCP level overrides etc. They are basically used for configuring the client libraries/jars. They are not meant for application configuration for example what queue manager or queue to use. This sort of info, connection factory or destination info, is typically pulled from a JNDI so that the configuration can be modified without affecting application.
Would it be possible to set up a DataSource using Spring Cloud in which open JDBC connections could be injected into all of my Spring Boot applications?
Something kind of like a JNDI server lookup? If so, can someone provide some examples or a description on how to use this type of configuration?
You could use a Spring Cloud bootstrap configuration to create a DataSource. I don't see much value in doing it that way over a normal Spring Boot autoconfiguration though. Link: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-developing-auto-configuration.
One solution I found out was to set all datasources info into the properties files which will supplied by Spring Cloud Config Server to applications clients. So the aplications clients which creates DataSources gets from remote properties those values.
I am using the Spring AMQP library .How do I configure connectionTimeouts and socketTimeouts in CachingConnectionFactory.I assume it must internally use
http://www.rabbitmq.com/javadoc/com/rabbitmq/client/ConnectionFactory.html#setConnectionTimeout(int)
We have an open JIRA to expose some more of these attributes, which should be in the next releease.
In the meantime, you can wire up a Rabbit ConnectionFactory and provide it to the CachingConnectionFactory - see the documentation.
I managed to create simple Websocket application with Spring 4 and Stomp. See my last question here
Then I tried to use remote message broker(ActiveMQ). I just started the broker and changed
registry.enableSimpleBroker("/topic");
to
registry.enableStompBrokerRelay("/topic");
and it worked.
The question is how the broker is configured? I understand that in this case the application automagicaly finds the broker on localhost:defaultport, bu what if I need to point the app to some other broker on other machine?
The enableStompBrokerRelay method returns a convenient Registration instance that exposes a fluent API.
You can use this fluent API to configure your Broker relay:
registry.enableStompBrokerRelay("/topic").setRelayHost("host").setRelayPort("1234");
You can also configure various properties, like login/pass credentials for your broker, etc.
Same with XML Configuration:
<websocket:message-broker>
<websocket:stomp-endpoint path="/foo">
<websocket:handshake-handler ref="myHandler"/>
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay prefix="/topic,/queue"
relay-host="relayhost" relay-port="1234"
client-login="clientlogin" client-passcode="clientpass"
system-login="syslogin" system-passcode="syspass"
heartbeat-send-interval="5000" heartbeat-receive-interval="5000"
virtual-host="example.org"/>
</websocket:message-broker>
See the StompBrokerRelayRegistration javadoc for more details on properties and default values.