Uploaded image for project: 'Policy Framework'
  1. Policy Framework
  2. POLICY-1289

Apex only considers 200 response codes as successful result codes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • Dublin Release
    • Casablanca Release, Dublin Release
    • None

      From: Cillian O'Shea (Ericsson)

      I want to ask you about this error we are getting from apex.
      2018-10-20 22:18:37,733 [procId=processId_IS_UNDEFINED] WARN c.e.a.c.i.m.i.w.RawMessageHandler - Error while forwarding events for Apex-SonApexEngine:com.ericsson.apex.service.engine.main.ApexEventMarshaller:retOutputProducer-2:0
      com.ericsson.apex.service.engine.event.ApexEventRuntimeException: send of event to URL "http://jboss:8080/son-om/cm-change/v1/changes" using HTTP "POST" failed with status code 201 and message "", event:

      We are using a standard RestClient producer
      "retOutputProducer": {
      "carrierTechnologyParameters": {
      "carrierTechnology": "RESTCLIENT",
      "parameterClassName": "com.ericsson.apex.plugins.event.carrier.restclient.RESTClientCarrierTechnologyParameters",
      "parameters":

      { "url": "http://jboss:8080/son-om/cm-change/v1/changes", "httpMethod": "POST" }

      },
      "eventProtocolParameters":

      { "eventProtocol": "JSON" }

      ,
      "eventNameFilter": "ChangeEvent"
      },

      We are sending a 201 response back because it is the correct code as we see for a creation.
      “If a resource has been created on the origin server, the response SHOULD be 201”
      https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5

      My question is why does the apex only consider 200 to be a correct response?
      From ApexRestClientProducer,
      // Check that the request worked
      if (response.getStatus() != Response.Status.OK.getStatusCode())

      { String errorMessage = "send of event to URL \"" + restProducerProperties.getURL() + "\" using HTTP \"" + restProducerProperties.getHttpMethod() + "\" failed with status code " + response.getStatus() + " and message \"" + response.readEntity(String.class) + "\", event:\n" + event; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); }

      There are many other status codes that should be considered here also.
      https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Response.Status.html

            Unassigned Unassigned
            liamfallon liamfallon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: