2

I have a route which interacts with 4 http endpoints. the first http endpoint is an authorization service from which i will get one authentication token. What i want is once i get the token from the authorization service i will pass the token to each further http service in the header. so how can i achieve that? is there any way of creating a temporary variable using the token value and if i can place it in the context then in any endpoint i can set it. or else i was thinking if i can invoke the authorization service once at application startup once and store the token somewhere and i can use it.

dks551
  • 1,113
  • 1
  • 15
  • 39

2 Answers2

2

You can store properties on your exchange object:

http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html#setProperty(java.lang.String,%20java.lang.Object)

For example in my "pipeline" I'm storing ID from DB for later use:

from("quartz2://myScheduler?cron=0+0+6,14,22+*+*+?")
   .to("sql:" + getNextID() + "?dataSource=#dataSource&outputType=SelectOne")
   .setProperty("NextID", simple("${body[id]}"))

Then, the NextID is accessible from exchange exchange.getProperty("NextID")

kamil
  • 3,482
  • 1
  • 40
  • 64
0

You can use headers or properties

Aku Nour
  • 406
  • 4
  • 9