Rollins999
Rollins999

Reputation: 688

Spring Integration, catching exception on error channel prevents return

I have a set of simple REST services which are all configured with an error-channel to allow a service-activator specified bean to catch exceptions.

When an exception does occur, the method in the bean is called, as expected, and I log the exception. However, the caller (i.e. HTTP client) never gets a response.

What do I need to do to return some sort of error (or indeed anything) back to the client?

I'm assuming I'm missing something obvious!

Upvotes: 1

Views: 668

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121282

I guess your service-activator doesn't return anything, but it isn't good for request-reply case. For the top-level HTTP component it doesn't matter if you catch an Exception within error-channel or not, it expects response anyway.

Even if you catch and log that exception in your service-activator it has to return something specific to the state of the response, e.g. some String message.

In addition you can populate the HttpHeaders.STATUS_CODE message header from there or using <header-enricher>.

In this case you just should rely on the TemporaryReplyChannel from the request message header, hence don't provide any output-channel from the end component in the error-flow. But the valid return must be there anyway.

Upvotes: 1

Related Questions