39734

Is it possible to return a 204 from a Spring Integration http inbound-channel-adapter?

Question:

I have an inbound-channel-adapter that forwards to a bean method that returns null, but since http has to return a response, a 200 is returned. There are cases where I'd like to specify what the return value is, e.g. a 204 and I've tried a bunch of things, but nothing seems to work.

I'm using spring-integration 3.0.2.

Thanks, Justin

Answer1:

Yes, set the http_statusCode header in the reply message to 204.

EDIT: (see comments below)

<int-http:inbound-gateway request-channel="receiveChannel" path="/receiveGateway" supported-methods="POST"/> <int:publish-subscribe-channel id="receiveChannel" task-executor="exec" /> <int:service-activator input-channel="receiveChannel" expression="payload + ' from the other side'" output-channel="next"/> <int:chain input-channel="receiveChannel"> <int:header-enricher> <int:header name="http_statusCode" value="204"/> </int:header-enricher> <int:transformer expression="''"/> </int:chain>

Assumes the main flow doesn't return a result.

If you want to wait until the flow completes, remove the task executor.

You probably also need a transformer, to transform the payload to "".

Recommend

  • In jQuery how do I create alert every 5 seconds?
  • Populate Backbone Marionette Views with data from Mongoose using Express Route
  • Python ValueError at /admin/ too many values to unpack
  • convert list of values from a txt file to dictionary
  • Fail SonarQube quality gate when coverage decreases
  • How to use HTTP Authentication with PHP and then run the entered data against a database?
  • PHP - sending email with attachment does not show message content
  • How to reply a tweet using the Twitter gem?
  • Aspect advising other aspects
  • Can't get LogCat (Alcatel OneTouch Evolve)
  • get latest text entry of GROUP BY statement
  • Defining variable by logical subseting on time interval in data.table
  • how to convert open xml representation of word document into RTF format using c#.net 4.0?
  • Sending rails errors to rspec output
  • Partial specialization of a class template in derived class affects base class
  • jersey/tomcat Description The origin server did not find a current representation for the target res
  • Unable to connect to OnVif enabled camera using C#
  • .NET video play library which allows to change the playback rate?
  • Getting different value with placeholder over CPU/GPU
  • saving file generated by TCPDF
  • How to view images from protected folder with php?
  • Textfile Structure (tables)
  • Problems to linebreak with an int in JLabel
  • How reduce the height of an mschart by breaking up the y-axis
  • output of program is not same as passed argument
  • MySQL WHERE-condition in procedure ignored
  • vba code to select only visible cells in specific column except heading
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Confusion with PayPal's monthly billing cycle
  • How to set the response of a form post action to a iframe source?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Sorting a 2D array using the second column C++
  • reshape alternating columns in less time and using less memory
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal