Да, я перезапустил intellij, и все это заработало, только добавив заголовок Content-type как application / json. Очевидно, библиотека Джексона была в моем классе.

ользуюHttpRequestExecutingMessageHandler сделать POST-запрос к местной службе.

Услуга выглядит следующим образом:

@RestController
@RequestMapping("/accountbalance")
public class AccountBalanceController {

    @Autowired
    private AccountBalanceDetailsRepo accountBalanceDetailsRepo;

    @RequestMapping(method = RequestMethod.POST, path = "/exp")
    public List<AccountBalanceDetails> getAccounts(@RequestBody User name) {
        System.out.println(">>>>>>>>>>> " + name);
        return accountBalanceDetailsRepo.findAll();
    }
}

Пользовательский класс: -

public class User implements Serializable {

    private String name;
    private Integer age;

//getters and setters
}

Конфигурация весенней интеграции:

@Bean
    public HttpRequestExecutingMessageHandler httpOutBound(@Qualifier("httpOutChannel") DirectChannel outputChannel) {
        HttpRequestExecutingMessageHandler httpRequestExecutingMessageHandler = new
                HttpRequestExecutingMessageHandler("http://localhost:8080/accountbalance/exp");
        httpRequestExecutingMessageHandler.setHttpMethod(HttpMethod.POST);
        httpRequestExecutingMessageHandler.setExpectedResponseType(ArrayList.class);
        httpRequestExecutingMessageHandler.setMessageConverters(Arrays.asList(new SerializingHttpMessageConverter()));
        httpReq,uestExecutingMessageHandler.setOutputChannel(outputChannel);
        return httpRequestExecutingMessageHandler;
    }

    @Bean
    public IntegrationFlow httpFlow(@Qualifier("httpReqChannel") DirectChannel directChannel,
                                    HttpRequestExecutingMessageHandler messageHandler) {
        return IntegrationFlows.from(directChannel).handle(messageHandler).get();
    }

    @Bean
    public DirectChannel httpReqChannel() {
        return new DirectChannel();
    }

    @Bean
    public DirectChannel httpOutChannel() {
        return new DirectChannel();
    }

    @Bean
    public IntegrationFlow httpOutFlow(@Qualifier("httpOutChannel") DirectChannel directChannel) {
        return IntegrationFlows.from(directChannel).handle(msg -> System.out.println(">>>>> "+ msg)).get();
    }

В основном классе я отправляю сообщениеhttpReqChannel канал следующим образом:

User user = new User();
        user.setAge(29);
        user.setName("Amar");
        directChannel.send(MessageBuilder.withPayload(user).build())

Я получаю следующее исключение: -

Caused by: org.springframework.messaging.MessageHandlingException: HTTP request execution failed for URI [http://localhost:8080/accountbalance/exp]; nested exception is org.springframework.web.client.HttpClientErrorException: 406 null
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:409) ~[spring-integration-http-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) ~[spring-integration-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at com.bhargo.Main.run(Main.java:51) [classes/:na]

Что я здесь не так делаю ???

Ответы на вопрос(1)

Ваш ответ на вопрос