Default spring.cloud.stream.rabbit.* properties to appy to multiple channels? - rabbitmq

With spring cloud stream, you can avoid redundant properties for each individual channel, by specifying "default" properties.
For example, if I have 2 channels bound to the same destination/exchange, I can do:
spring.cloud.stream.default.destination=myExchange
spring.cloud.stream.bindings.myChannel1.group=queue1
spring.cloud.stream.bindings.myChannel2.group=queue2
And queue1 and queue2 will both by bound to myExchange.
That works as documented, and I do it for some properties.
But....I'd like to do the same for RabbitMQ binding properties.
For example, if I want DLQ for all of my consumers/queues, do something like:
spring.cloud.stream.rabbit.default.consumer.auto-bind-dlq=true
spring.cloud.stream.rabbit.default.consumer.dlq-ttl=10000
spring.cloud.stream.rabbit.default.consumer.dlq-dead-letter-exchange=
Otherwise, I have to specify those same 3 lines for every channel.
Is there any way to do this? I've tried several different permutations to no avail.
BTW, I'm on version 1.2.1.RELEASE of spring-cloud-starter-stream-rabbit.
Thanks.

It is supported. Please see https://docs.spring.io/spring-cloud-stream/docs/Elmhurst.RELEASE/reference/htmlsingle/#binding-properties section of the user guide
To avoid repetition, Spring Cloud Stream supports setting values for all channels, in the format of spring.cloud.stream.default.<property>=<value>

According to Spring Cloud Stream documentation, it is possible since version 2.1.0.RELEASE.
See 9.2 Binding Properties.
When it comes to avoiding repetitions for extended binding properties,
this format should be used
spring.cloud.stream.<binder-type>.default.<producer|consumer>.<property>=<value>
Unfortunately so far I couldn't make it work. Did anyone get it?

It is not supported yet.
See 3.2. RabbitMQ Consumer Properties
The following properties are available for Rabbit consumers only and must be prefixed with spring.cloud.stream.rabbit.bindings..consumer..
including ttl/dlq*

Related

Two-way Apache Camel Routes - Infinite loop

I have 2 endpoints that I would like to establish routes between. Due to the nature of these endpoints (JMS topics), I would like the bridging to be bidirectional.
The underlying JmsComponent for the Tibco endpoint has the pubSubNoLocal parameter enabled which ensures that a consumer does not receive messages it has itself sent as per http://camel.apache.org/jms.html
pubSubNoLocal false
Specifies whether to inhibit the delivery of messages published by its own connection.
However this has no effect since the 2 routes create separate connections to the JMS topic my.topic.
As a result, the following will create an infinite loop.
As mentioned, I need the routes to operate in both directions for "seamless integration"
<c:route>
<c:from uri="tibco:topic:my.topic"/>
<c:to uri="solace-jms:topic:mytopic" />
</c:route>
<c:route>
<c:from uri="solace-jms:topic:mytopic"/>
<c:to uri="tibco:topic:my.topic" />
</c:route>
I suggest le consideration the concepts of message selectors and headers.
The way I see it, you do 2 things:
Add a "PRODUCER" header with your Server ID (however you define it)
All your listeners must be configured with a negative selector "NOT (PRODUCER='YOUR_ID')"
Done ?
(Of course, you could also use 2 topics... but I assume it is out of the question...)
You will need to add some indication in the message that it has been sent through either bridge. You could play with existing properties (redelivery ?) or better add a new one. For example set property bridged=true when it passes your bridge. Then inside your definition you can filter out each message already bridged.

ActiveMQ MessageGroupHashBucket - what is cache property needed for?

I'm trying to find a best strategy to deal with ActiveMQ Message Groups support.
ActiveMQ has several strategies (MessageGroupMap implementations).
The one that is confusing me a little is MessageGroupHashBucket.
Specifically, after looking at sources, I don't understand why is the cache property needed there? When assigning consumer id for message group or retrieving consumer id by message group - the array of buckets is used.
It would be great if someone can suggest why.
Thanks in advance,
MessageGroupHashBucket implements MessageGroupMap interface method getGroups() by returning the cache property as a map of all group names and associated consumer Id.
Adding to #piola's answer, it looks like the cache property is used to configure the number of group names that will be inside a bucket. This is a very efficient way to handle a large number of groups. Going by this logic, a configuration of 1024 buckets with the cache size of 64 can handle 65,536 groups.

How to remove all the properties (INVOCATION/INBOUND/OUTBOUND/SESSION) in a specific scope in mule

I am having a problem where my rabbit mq message put is erroring and it does not tell me what the root cause for the put failure is. Looking at stackoverflow, I see that my problem is identical to what was reported here-to store a message in rabbitmq from mule-as far as exception goes.
Now I am trying to find out if there is a way to remove all the properties present in the message or if the removal can be performed per scope (i.e. INVOCATION/INBOUND/OUTBOUND/SESSION). Reason being, I dont know which property, if at all, is causing this.
I did look at <remove-property> & <message-properties-transformer> but they work on a specific property only (& not all).
are you sure that <remove-property> works on specific properties only? i recall using this transformer with a wildcard to achieve something similar to what you are trying to do:
<remove-property propertyName="*" doc:name="Property"/>
You could do it with this inside a Groovy Transformer:
import org.mule.api.transport.PropertyScope
message.getPropertyNames(PropertyScope.OUTBOUND).each {p -> message.removeProperty(p, PropertyScope.OUTBOUND)}
I would be looking at scopes OUTBOUND and SESSION, as the other scopes shouldn't be propagated over a transport boundary.

advice handler on aws outbound channel adapter

In the past I have been able to apply advice chain handlers on different outbound channel adapters. I am trying to do the same on int-aws:s3-outbound-channel-adapter but its not allowing that. Does this component not allows this behavior. Basically I am interested in finding out when the adapter completes the upload of a file to S3.
<int-aws:s3-outbound-channel-adapter
id="s3-outbound" channel="files" bucket="${s3.bucket}"
multipart-upload-threshold="5192" remote-directory="${s3.remote.dir}"
accessKey="${accessKey}" secretKey="${secretKey}">
THIS DOESNT WORKS - throws an error !!!
<int:request-handler-advice-chain>
</int:request-handler-advice-chain>
</int-aws:s3-outbound-channel-adapter>
Right, that isn't allowed by the XSD. Feel free to raise a JIRA on the matter.
But that doesn't matter that it doesn't work at all.
If you are on Spring Integration 4.x already you can move that <int-aws:s3-outbound-channel-adapter> to the Java & Annotation configuration using #Bean and #ServiceActivator for the AmazonS3MessageHandler.
Where #ServiceActivator has adviceChain attribute to specify bean references to your Advices.
... or you can do that using generic <int:outbound-channel-adapter> and specify AmazonS3MessageHandler as raw <bean> for the ref of the first one.
HTH

Mule Web Service Consumer Warning : Operation Messages With More then 1 Part Are Not Supported

Hi I am working with Mule Web Service Consumer and i was trying to call operation with Multiple Parameters it is warning me that
Warning : Operation Messages With More then 1 Part Are Not Supported
I just want to pass multiple parameters to access my SOAP method to achieve the task.
Is this the problem with Web Service Consumer or is their any way to deal with this.
I'm afraid this is a known limitation of the web services consumer. However you can accomplish this with the cxf component.
I having the same issue and found some information around it ...
There is a improvement logged in JIRA, may help if you vote for it :)
This link suggests that you can still use WSConsumer but need to do some hand crafting of the request XML ... I could not understand what that exactly it meant so if anyone has an example on it would be great
PS: The problem I had with using CXF component is that it does not play well with the new Dataweave transformer as the Dataweave needs to be placed within the response block and from there it cannot datasense the response coming out from the CXF component
The Solution here is very simple. You just have to comment other messages and then load metadata for non-commented message (for one which you're trying to load metadata). Repeat this procedure for all the other messages and you're good to go.
Hope this helps !