PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] Why property doesn't get evaluated correctly in Camel 3.7.3?

 April 14, 2022     apache-camel, apache-camel-3, java, migration, spring-boot     No comments   

Issue

I have a route

String XYZ = "xyz";

from(URL_A)
  .bean(PropertiesSetterBean.class)
  .to("${property." + XYZ + "}")

where PropertiesSetterBean is:

@Component
class PropertiesSetterBean {
  public void copyProperties(@Headers Map<String, Object> headers, @ExchangeProperties Map<String, Object> properties) {
    properties.put("xyz", "direct:test")
  }
}

The error I get:

Failed to create route route1 at: >>> DynamicTo[${property.xyz}] <<< in route: Route(route1)[From[seda:inEvents?concurrentCon... because of Property with key [property.xyz] not found in properties from text: ${property.xyz}

It looks like bean doesn't get executed.

I use camel:3.7.3, spring-boot:2.4.3, java:11

Steps I did:

  • I read the migration guide
  • Looked at available code snippets on GitHub
  • Search StackOverflow
  • Talked to colleagues

I looked into a similar issue.

And still, I cannot triage the issue.

What am I doing wrong?

UPDATE 1

I added the processor:

.process(exchange -> {
  System.out.println("This is my property: " + exchange.getProperty("xyz"));
})

It works. In the meantime, I still cannot retrieve this property with simple DSL in Camel.


Solution

After several hours of search with no result, I bumped into an old post.

To access the property, I will need to use "${exchangeProperty." + XYZ + "}".

Note:

  • It worked with Camel 2.X.X, so beware of this change.
  • If you have a collision between Spring and Camel placeholders, use $simple instead of $.
  • In Camel 3.X.X you will need to check where your properties located and repoint them to exchangeProperty


Answered By - Dmytro Chasovskyi
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing