Comments (4)
I think, the issue is in this file:
should be replaced by
if (!(resolvedValue.**contains**("#{") && value.**contains**("}"))) {
from spring-amqp.
I think you have a point here!
Indeed the TemplateAwareExpressionParser
used from the StandardBeanExpressionResolver
parses the first aaa.bbb.
part as LiteralExpression
and the next part with the #{...}
as a SpelExpression
to evaluation.
I've just tested and confirmed that we are good to go with your suggestion!
@RabbitListener(queues = "test.#{'simple'}", group = "testGroup")
But that's only the part of the solution for your. Since your expression is very complex there, you should be careful with all the required symbols to honor SpEL syntax.
For now I'd suggest you as workaround as:
amqp:
queue:
suffix: 001
name: #{'aaa.bbb.' + '${amqp.queue.suffix}' == '001' ? 'default': '${amqp.queue.suffix}'}
Pay attention to single quotes everywhere. Since after resolving the property placeholder, the result becomes something valuable for the SpEL and tries to be resolved against application context. As far as they all are literals
they have to be quoted
. Not sure though if a single quote '
will be enough: https://docs.spring.io/spring-cloud-dataflow/docs/1.3.0.M2/reference/htmlsingle/#shell-white-space. But it worth to try!
Feel free to come back to us with the contribution on the matter!
from spring-amqp.
I don't think changing it contains(()
is the right solution.
I think we should simply document that the SpEL evaluation is done after the property placeholder resolution and must match the regex pattern ^#{...}$
.
My 2c.
from spring-amqp.
Gary, one more time.
The TemplateAwareExpressionParser
is able to parse an expression like foo.#{myBean.x}.bar
to the CompositeStringExpression
: LiteralExpression
, SpelExpression
, LiteralExpression
. Just because it has a logic like:
while (startIdx < expressionString.length()) {
int prefixIndex = expressionString.indexOf(prefix, startIdx);
if (prefixIndex >= startIdx) {
// an inner expression was found - this is a composite
if (prefixIndex > startIdx) {
expressions.add(new LiteralExpression(expressionString.substring(startIdx, prefixIndex)));
}
That CompositeStringExpression
does exactly string concatenation under hood:
for (Expression expression : this.expressions) {
String value = expression.getValue(String.class);
if (value != null) {
sb.append(value);
}
}
I would even say that we don't need that condition to check if that contains expression tokens or not.
We always can rely on the TemplateAwareExpressionParser
and get a simple LiteralExpression
for non-templated string. Well, that is actually what is done by Spring per se. See AbstractBeanFactory.doResolveBeanClass()
for example:
String className = mbd.getBeanClassName();
if (className != null) {
Object evaluated = evaluateBeanDefinitionString(className, mbd);
if (!className.equals(evaluated)) {
So, I would even say that with the current logic we even restrict the user in possible expression variants.
Well, I may see your concern to make such a change in the current GA release, but we definitely should reconsider it in the next 2.1.0
or even in the point 2.0.1
version.
FYI. I have just commented out the code:
if (!(resolvedValue.startsWith("#{") && value.endsWith("}"))) {
return resolvedValue;
}
And all our tests are passing.
from spring-amqp.
Related Issues (20)
- Consumer failed to start in 60000 milliseconds HOT 7
- Unable to connect to RabbitMQ Stream HOT 29
- Failed to check/redeclare auto-delete queue(s) - missing exception cause HOT 2
- When batch processing, when one of the messages is empty, all of this batch fails HOT 4
- How about expand Builder for Queue Object like durable() HOT 2
- Ignore Kotlin Continuation Parameter While Inferring Conversion Type
- Ignore Kotlin Continuation Parameter While Inferring Conversion Type HOT 1
- Ignore Kotlin Continuation Parameter While Inferring Conversion Type HOT 1
- Exclusive Consumer Logging Improvements HOT 3
- Super Stream Builder for usability HOT 1
- The CachingConnectionFactory findOpenChannel message lock contention is severe HOT 3
- Fix Super Stream Example in Docs
- Fix Super Stream Example in Docs HOT 1
- CachingConnectionFactory leaks channels during connection resets when used in a SimpleMessageContainer HOT 1
- Stream/Queue size in bytes (x-max-length-bytes)
- build branch 2.3.x, cannot download io.spring.docresources:spring-doc-resources:0.2.1.RELEASE HOT 5
- Context being lost between @RabbitListener and Webclient HOT 14
- Refactor to support Virtual Threads HOT 1
- rabbit properties in application.properties cannot overwrite the dafault values HOT 1
- WARN------Using deprecated '-debug' fallback for parameter name resolution. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp.