Closed zregvart closed 6 years ago
Ah yeah I can see the problem. You need to determine the headers in the createEndpoint method. And then you have trouble to set those headers before calling the producer.
We have some support for this by using a Processor
and set that as setBeforeProducer
in the component class. Then this processor will be invoked before the producer. However this processor is shared, and therefore you cannot store local state such as the headers.
So we should make it possible to set a instance of BeforeProducer
on the endpoint, so you can do it all from the createEndpoint
class.
Then you just set
Map headers = ... determineHeaders
endpoint.setBeforeProducer(e -> e.getIn().setHeaders(headers));
I logged a ticket: https://issues.apache.org/jira/browse/CAMEL-11975
And there is a commit https://github.com/apache/camel/commit/ceb8669704f87561c53a4324893b5fb31302e704
Now you can do what I do in that FooComponent
in the createEndpoint
method of your connector. You should just use setBeforeProducer
instead.
Adds a Initial implementation of a Connector that uses Swagger specification to invoke REST services.
Fixes #96