I'm using spring cloud to connect to my Kafka broker. It works fine. Now I want to create my binding by code instead of annotation.
Is there a convenient way to do it?
Could you elaborate why do you want to do the binding programmatically instead of using #EnableBinding.
While Spring Cloud Stream simplifies exactly that, if you prefer to use your own way of connecting (for any other specific reason), then you might want to check the Spring Integration adapters to do the binding. But, in this case, you are on your own by setting up the lifecycle and all other goodies that Spring Cloud Stream provides.
If you still want to use Spring Cloud Stream but don't want to use the annotation, then check here to see all the configuration that Spring Cloud Stream does when you annotate and apply your use case.
Please follow https://github.com/spring-cloud/spring-cloud-stream/issues/954. We plan to add this feature to 1.3.0.RC1.
Related
I'm using Spring Cloud Data Flow.
Is there any way to deploy a stream defined with the Java DSL providing the .jar uri instead of executing it as a client?
I want to threat it like the applications I can register (e.g. log-sink) because in fact is an application.
Thanks!
You can use the Java DSL (which implements the Spring Cloud Data Flow REST client). For documentation on using Java DSL, you can refer to the documentation here.
I'm using Kafka in Spring Boot project. There are a lot of benefits in case you have simple flow (to use #KafkaListener, #KafkaHandler) and spring prepares almost everything for development.
In my application I have different handlers for the same message data. I want to use SpEL to manage handlers manipulating header data, but I've not detected corresponding API for that.
So my question: is it possible to manage my handlers via SpEL in case I have special headers for that (Header for example "X-OPERATION_TYPE":"patch")? How?
P.S.
I can make workarounds using GoF Strategy as example, but I hope spring already has solution for that case.
There is not such a "conditional routing" in Spring for Apache Kafka, but you can do that routing manually in the single #KafkaListener with plain if...else or switch.
For more comprehensive routing logic it would be better to take a look into Spring Integration: https://docs.spring.io/spring-integration/docs/5.0.9.RELEASE/reference/html/messaging-routing-chapter.html
I want to implement logging-channel-adapter in java class which monitors all the inbounds and outbounds of all the applications. If there is any another way of logging spring integration calls please advice.
Note : I am using spring boot.
Spring integration provides option to configure global Wire Tap. That is what you want.
Reaction on comment:
Here is example project I created.
I am working on some new custom distributed objects to run in Hazelcast SPI.
As can be seen in : http://docs.hazelcast.org/docs/latest/manual/html/spiaddproperties.html you can enable via the Hazelcast xml config, or of course, you can enable programmatically.
It appears that the spring hazelcast xml schema does not support SPI creation, and I would like to create/enable and inject spring beans as properties to the new service.
Can anyone advise if this is possible? I want to utilize spring to instantiate the hazelcast instance as this is the most robust way I've found to do so in a large application.
I think it is supported.
You can find an example here: https://github.com/hazelcast/hazelcast/blob/master/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullcacheconfig-applicationContext-hazelcast.xml#L309
We are planning to move a Spring based application to Cloud Foundry.
The application currently uses WAS server and access data sources using JNDI lookup.
We are using spring features like MVC, AOP etc.
I have certain questions in mind :
Is it possible to switch to Tomcat and configure dataSources using Spring-cloud-connectors and possible conflicts we might run into ?
Currently , datasources are configured in XML files, Should I use the same XML files or switch to annotations.
Can anyone please provide some clarity over this and other known issues with this approach?
Spring Cloud Connectors are by far the easiest way to bind to data sources in Cloud Foundry. I would recommend converting your JNDI lookups to use these service connections as described here:
http://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html
cloud foundry automatically reconfigures your datasource when it find a database service attached the cloud app. its super coooool....