I am using below configs in my container factory. After i add this config, i am not able to see anything being consumed by the spring-kafka consumer.
Is there a standard way of setting the SSL for kafka consumer using spring.
When i remove these configs, i am able to get the messages and consumer them.
config.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL")
config.put("ssl.keystore.location", "location_to/abc.keystore.jks"); //
config.put("ssl.keystore.password", "pwd1122");
config.put("ssl.truststore.location", "location_to/serv.truststore.jks");
config.put("ssl.truststore.password", "pwd11223");
When i remove these configs, i am able to get the messages and consume[r] them.
That simply means the broker is not configured for SSL - the client and server have to agree to use SSL or not.
If the broker is configured with an SSL listener, it must be on another port.
Related
We're using spring cloud for consuming messages from Kafka.
Before #StreamListener start to read messages we need to make HTTP request in class implementing ApplicationRunner. In this class, we stop binding with BindingsEndpoint.changeState, send the request and then enable binding.
However, messages are consumed even before the application has started.
How do i get #StreamListener to work after ApplicationRunner?
Or maybe there are another ways to make http request before #StreamListener?
Set the consumer autoStartup binding property to false to prevent it starting before the runner.
The use case is following.
I am passing producer or consumer reference over many objects instances in Java code.
At some of them I would like to do some checks for the Kafka configuration.
It means I would like to get back, what effective configuration is stored in Kafka Producer/Consumer (including defaults).
I do not see anthing explicit in java docs:
KafkaProducer
KafkaConsumer
So, how to get back Kafka producer and consumer configuration?
Unfortunately it's not possible. I have to admit it could be a useful feature for showing the "core" configuration properties at least (avoiding the possibility to get the "secrets" for authentication stuff for example).
The only solution that I see today for you is to have a link between the consumer/producer instance and the related properties bag used for setting the client configuration. I understand it's a waste of memory because such configuration is internally in the client but you need to keep your properties bag for having it.
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.
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.