ブートストラップで以下を設定し、コードで @Value("${configvalue}") を使用して読み取り、consul KV ストアにアクセスしようとしています。
application:
name: appname
cloud:
consul:
host: consulhost
port: 8500
config :
enabled: true
@Value("${configvalue}")
private String configvalue;
@GetMapping("/home")
private String home() { return configvalue; }
public Message<String> trans4mformat(Message<JsonNode> msg)
{
System.out.println("********Got the consul parameters-->"+configvalue);
//do transform and return Message<String>
}
<int:gateway id="inboundListener" service-interface="KafkaGateway" default-request-channel="inboundChannel" error-channel="errorChannel"/>
<int:transformer id="transform" input-channel="inboundChannel" output-channel="outboundChannel" method="trans4mformat" requires-reply="false" >
<bean id="trns4m" class="com.package.Tranformation"/>
<int:poller fixed-rate="5"/>
</int:transformer>
これは、Rest Controller 内で使用するとうまく機能します。しかし、kafka リスナーとそこから始まる統合フローがあり、この @Value("${configvalue}") 内の transform にアクセスする必要がありますか? これは常に null になります。ただし、別のメソッドで get HTTP 呼び出しを使用して値を確認できます。