Spring Cloud Config с помощью Spring Cloud Bus - PullRequest
0 голосов
/ 06 апреля 2019

Я пытаюсь интегрировать весеннюю облачную шину с моим сервером конфигурации, чтобы обновить конфигурацию для наших служб.Для всех услуг это работает нормально.Но в одном сервисе, где я уже настроил прослушиватель, он дает мне исключение для RefreshRemoteApplicationEvent & AckRemoteApplicationEvent.Я не уверен, если нам нужно написать собственный картограф для этого типа.Пожалуйста, помогите / предложите мне то же самое.

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'AckRemoteApplicationEvent' into a subtype of [simple type, class org.springframework.cloud.bus.event.RemoteApplicationEvent]: known type ids = [RemoteApplicationEvent] at [Source:{"type":"AckRemoteApplicationEvent","timestamp":1554561718361,"originService":"cm-config:local:8888","destinationService":"**","id":"743ecc3c-228e-4046-a4f9-e169740b6cff","ackId":"ac66387d-fa22-40d5-985d-29d91ff227fc","ackDestinationService":"**","event":"org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent"}; line: 1, column: 9]

Caused by: org.springframework.messaging.converter.MessageConversionException: Could not read JSON: Could not resolve type id 'RefreshRemoteApplicationEvent' into a subtype of [simple type, class org.springframework.cloud.bus.event.RemoteApplicationEvent]: known type ids = [RemoteApplicationEvent] at [Source:{"type":"RefreshRemoteApplicationEvent","timestamp":1554561718297,"originService":"cm-config:local:8888","destinationService":"**","id":"ac66387d-fa22-40d5-985d-29d91ff227fc"}; line: 1, column: 9]; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'RefreshRemoteApplicationEvent' into a subtype of [simple type, class org.springframework.cloud.bus.event.RemoteApplicationEvent]: known type ids= [RemoteApplicationEvent] at [Source: {"type":"RefreshRemoteApplicationEvent","timestamp":1554561718297,"originService":"cm-config:local:8888","destinationService":"**","id":"ac66387d-fa22-40d5-985d-29d91ff227fc"}; line: 1,column: 9]

Пожалуйста, дайте мне знать, если вам нужна дополнительная информация о том же.

Существующая конфигурация RabbitMQ в службе, которая вызывает у меня проблему.Пожалуйста, дайте мне знать, если я делаю что-то не так.

@Bean
Binding binding(Queue queue, TopicExchange exchange) {
    return BindingBuilder.bind(queue).to(exchange).with(routingKey);
}

@Bean
public RabbitTemplate rabbitTemplate(final ConnectionFactory connectionFactory) {
    final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
    rabbitTemplate.setMessageConverter(producerJackson2MessageConverter());
    return rabbitTemplate;
}

@Bean
public Jackson2JsonMessageConverter producerJackson2MessageConverter() {
    return new Jackson2JsonMessageConverter();
}

@Bean
public MappingJackson2MessageConverter consumerJackson2MessageConverter() {
    return new MappingJackson2MessageConverter();
}

@Bean
public DefaultMessageHandlerMethodFactory messageHandlerMethodFactory() {
    DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
    factory.setMessageConverter(consumerJackson2MessageConverter());
    return factory;
}

@Override
public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) {
    registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory());
}

Спасибо, Сагар

...