2017-03-24 6 views
0

私は、スキンレジストリサーバーとスキーマレジストリクライアントを春のブート1.5.2で使用しています。Springクラウドストリームスキーマレジストリがスタンドアロンのtomcatにデプロイされる

私はカフカバインダーにavroメッセージを送信しています。 Brooklyn.SR3を使用しています。スキーマはpostgres DBに永続化されます。私は春のブートのメインクラスを開始している間、すべてうまく動作します。

試みは、スタンドアロンのTomcatにデプロイしようとは、バインダーにメッセージを送信するとエラーがあります:

caused by: org.springframework.web.client.HttpClientErrorException: 404 null 
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) 
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700) 
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653) 
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) 
    at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:407) 
    at org.springframework.cloud.stream.schema.client.DefaultSchemaRegistryClient.register(DefaultSchemaRegistryClient.java:53) 
    at org.springframework.cloud.stream.schema.avro.AvroSchemaRegistryClientMess****ageConverter.resolveSchemaForWriting(AvroSchemaRegistryClientMessageConverter.java:187)**** 
    at org.springframework.cloud.stream.schema.avro.AbstractAvroMessageConverter.convertToInternal(AbstractAvroMessageConverter.java:174) 
    at org.springframework.messaging.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:193) 
    at org.springframework.cloud.stream.binding.MessageConverterConfigurer$ContentTypeConvertingInterceptor.preSend(MessageConverterConfigurer.java:237) 
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415) 

私はTomcatを9に切り替え、現在いくつかの他のエラー取得:

Caused by: org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [interface java.util.Map] and content type [text/html;charset=UTF-8] 
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:109) 
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:917) 
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:901) 
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:655) 
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) 
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:407) 
at org.springframework.cloud.stream.schema.client.DefaultSchemaRegistryClient.register(DefaultSchemaRegistryClient.java:54) 
at org.springframework.cloud.stream.schema.avro.AvroSchemaRegistryClientMessageConverter.resolveSchemaForWriting(AvroSchemaRegistryClientMessageConverter.java:219) 
at org.springframework.cloud.stream.schema.avro.AbstractAvroMessageConverter.convertToInternal(AbstractAvroMessageConverter.java:174) 
at org.springframework.messaging.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:193) 
at org.springframework.cloud.stream.binding.MessageConverterConfigurer$ContentTypeConvertingInterceptor.preSend(MessageConverterConfigurer.java:238) 
at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538) 
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415) 

UPDATEを:

原因404が原因でスタンドアロンのTomcatにデプロイされたアプリケーションのルートが発生する問題。私はそれを修正しましたが、別のエラーが発生しました:

Failed to register schema: <302 Found,{Location=[/csl/], Transfer-Encoding=[chunked], Date=[Mon, 27 Mar 2017 10:08:40 GMT]}> 
at org.springframework.cloud.stream.schema.client.DefaultSchemaRegistryClient.register(DefaultSchemaRegistryClient.java:64) 
at org.springframework.cloud.stream.schema.avro.AvroSchemaRegistryClientMessageConverter.resolveSchemaForWriting(AvroSchemaRegistryClientMessageConverter.java:219) 
at org.springframework.cloud.stream.schema.avro.AbstractAvroMessageConverter.convertToInternal(AbstractAvroMessageConverter.java:174) 
at org.springframework.messaging.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:193) 
at org.springframework.cloud.stream.binding.MessageConverterConfigurer$ContentTypeConvertingInterceptor.preSend(MessageConverterConfigurer.java:238) 
at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538) 
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415) 

答えて

0

サーバーをスタンドアロンプ​​ロセスとして実行していますか?アプリケーションのspring.cloud.stream.schemaRegistryClient.endpointの値は何ですか? Chelsea RC1にもお勧めしたいと思います。私たちは、スキーマ登録とキャッシングについて多くの改良を行いました。

+0

の終わりに/愚かだった:http://localhost/user/avroを照会するとき

また、私は、生成されたスキーマを取り戻します。 Tomcatはスタンドアロンプ​​ロセスとして実行されています。スキーマのレジストリは同じサーバー上にあります。spring.cloud.stream.schemaRegistryClient.endpoint = http:// localhost:8080同じエラーが発生します。ありがとう。 –

+0

私はあなたが行方不明になるかもしれないか分からない。しかし、私はちょうどあなたが与えた同じ基本情報に従ったプロジェクトをセットアップし、すべてが機能しています。設定プロパティは次のとおりです。 –

0

私はあなたが行方不明になるかもしれないか分かりません。しかし、私はちょうどあなたが与えた同じ基本情報に従ったプロジェクトをセットアップし、すべてが機能しています。

spring.cloud.stream.bindings.output.contentType=application/*+avro 
server.port=8080 
spring.cloud.stream.schemaRegistryClient.endpoint=http://localhost:8080 
spring.cloud.stream.schema.avro.dynamic-schema-generation-enabled=true 

そして私は

@SpringBootApplication 
@EnableSchemaRegistryServer 
@EnableSchemaRegistryClient 
@EnableBinding(Source.class) 
@RestController 
public class SchemaApplication { 

    @Autowired 
    private Source source; 

    public static void main(String[] args) { 
     SpringApplication.run(SchemaApplication.class, args); 
    } 

    @RequestMapping(value = "/messages", method = RequestMethod.POST) 
    public void sendMessage(){ 
     User user = new User(); 
     user.setName("Joe"); 
     user.setFavoriteColor("Blue"); 
     source.output().send(MessageBuilder.withPayload(user).build()); 
    } 


} 

メッセージが正しいヘッダを使用してウサギに公開されているメッセージを送信するように設定し、残りのエンドポイントを持っている一つのクラスがあります:ここで構成プロパティですapplication/vnd.user.v1+avro

を私が指摘したことの1つは、エンドポイントにプロトコルhttpがないことです。投げたエラーは通常、起動時に不正なプロトコルの例外になります。

また、私はあなたのアプリとは別のエンティティとしてサーバーを残しておいて、クラスパスがビジネスエンティティとサーバーとの間でクラッシュすることを避けたいと考えています。 {"id":1,"version":1,"subject":"user","format":"avro","definition":"{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"io.acme\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"favoriteColor\",\"type\":\"string\"}]}"}

+0

配備別のTomcatにSchema Registry warを配備しました。私はURLの前にプロトコルhttpを持っています。しかし、ポストスキーマとkafkaにメッセージを送信しようとすると、まだ302 Foundが見つかりました。 –

+0

ブローカーのタイプは本当に重要ではありません。 POSTを使用してスキーマ・サーバーに直接アクセスしてから、スキーマを戻してみましたか。ドキュメントにはサーバーのエンドポイントに関するセクションがあります。 –

+0

別のTomcatにレジストリサーバーをデプロイし、(http):// localhost:8090/sr/schemas/1でスキーマを取得できます。 spring.cloud.stream.schemaRegistryClient.endpoint =(http):// localhost:8090/srを持つ別のアプリからバインダーにメッセージを送信しようとしていて、まだ302件が見つかりました。 Springはこのリダイレクトを行っていますが、理由を見ることはできません。 –

関連する問題