spring cloud stream multi sink with dynamic destinations - spring

I need to use dynamic group names for RabbitMQ binder based Multisink (multiple sinks) app.
Seems like the
spring.cloud.stream.bindings..group property can't be set at runtime.
Any thoughts on how to go about it ?
SPB: 2.2.8.RELEASE ,
spring-cloud-dependencies: Hoxton.SR6 ,
spring-cloud-stream-dependencies: Horsham.SR6
Thanx,

You can use a property placeholder there...
spring.cloud.stream.bindings.input-in-0.group=${group.prop:foo}
...and then set the property on the command line:
-Dgroup.prop=bar

Related

In Spring boot, I'm trying to create another .property file that functions like messages.property, Is that possible?

So I'm trying to create another .property file (called labels.properties) that i can use in Thymeleaf like this:
<div th:text=#{property.from.labels}></div>
Right now I just add labels.properties in the root of resource folder, for now its not working. The purpose of this is I want to separate the property file that handles the error messages from texts for labels & buttons.
Is that possible?
if yes, how to do it?
if yes again, can I do internationalization like adding labels_ja.properties (Japanese)?
You can customize the naming (and location) of the message bundles by configuring the spring.messages.basename property. For example:
spring.messages.basename=labels
By doing so, Spring will look for messages within classpath:labels.properties and classpath:labels_{locale}.properties, such as classpath:labels_ja.properties.
If you want to use this in addition to the regular messages.properties, you can use a comma separated value:
spring.messages.basename=messages,labels
The first one within that comma separated list will take priority over the other ones. If you have a property.from.labels in both messages.properties and labels.properties, the one within messages.properties would be chosen in this example.
This can also be found within the documentation about internationalization.

Migration from Spring Data Elasticsearch 4.0.0.M3 to M4

In Spring Data Elasticsearch 4.0.0.M3 I used UpdateQuery.builder().withUpdateRequest() while building UpdateRequest directly. So I could set retryOnConflict() parameter.
After moving to M4 I can't set it anymore because there is no withUpdateRequest() method in the UpdateQuery and the UpdateRequst is being built internally. UpdateQuery.builder doesn't provide an option to set retryOnConflict().
My question is what is the right way to migrate my code so that I will have full control over UpdateRequst?
Thanks.
wait for 4.0.0.RC1. I just merged the code to expose all the update query parameters on the UpdateQuery.builder

Spring boot: Override property value

Into my application-pre.properties file there's coded this property:
scheduler.url-backoffice=http://${BACKOFFICE_SERVICE}:8080
In order to fill it, I'm using -Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties.
scheduler-config.properties:
BACKOFFICE_SERVICE=localhost
scheduler.url-backoffice=http://localhost:8081
I need to set BACKOFFICE_SERVICE property, otherwise spring doesn't start. So, it means that scheduler.url-backoffice comes to http://localhost:8080.
I 've added another line after that in order override its value.
My surprise is its value is not changed. I mean, scheduler.url-backoffice's value is http://localhost:8080 instead of http://localhost:8081.
I'm not able to change application-pre.properties content file.
Use multiple application properties files.
One can ship in the jar;
this contains the defaults.
For me, defaults translates to either the prod values,
if there is only one set of prod values,
or the developer local values (which should cause failures in production).
The second file contains the environment specific property values that
override the defaults.
You must change your startup values to achieve this.
Here is an example:
-Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties,local-scheduler-config.properties
Edit: in response to "still not working".
It seems like you need much more than the "simple" approach I described above.
For that,
check out section 24. Externalized Configuration in the Spring Boot Reference Guide.
There are many techniques to override configuration values;
all are covered in the reference guide.

Dynamic xquery/xpath in activevos

I want to configure xpath or xquery in property file and need to use that variable while reading data.
for example, I configured xquery property in configuration file like
aXquery = types:Request/types:Person/type:details/type:a/text()
I need to use this aXquery variable in script some thing like
$RESTRequest/types:payload/string($configData/ns2:XPaths/ns2:aXquery)
Can anyone help me on this how to do in activevos?
I don't think that you can use property files directly. AFAIK there are three options to implement a dynamic configuration mechanism:
Use URN Mappings (Configurable in ActiveVOS Console / Administration / URN Mappings). You can read those with functions available in XQuery in ActiveVOS (resolveURN).
Place the configuration value in the database (e.g. create a new table) and read those with ActiveVOS DB access mechanisms.
Wrap your config file in a Web service and call the service from your process.

Spring Data: can it find by two values of the same field without writing the implementation?

I am doing a Spring web app and I use Spring Data.
I am able to use Spring Data to find objects by a single value of a field. For example:
some_object_repository.findByFirstName("John")
Is there any way I can provide two first names (e.g., "John", "David") similar to the following in concept:
some_object_repository.findByFirstName({"John", "David"})
without me writing a custom implementation?
Regards and thanks!
You can do this with In at the end
findByAgeIn(Collection ages) … where x.age in ?1
http://docs.spring.io/spring-data/jpa/docs/1.6.0.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods
Section 2.3.2 Query creation
In your case it will be
findByFirstNameIn(Collection names)

Resources