How to send a response to the invoker of a service without reaching the end of the pipeline

StackOverflow https://stackoverflow.com/questions/9929176

  •  27-05-2021
  •  | 
  •  

Pergunta

I have 2 custom actions exectuting one after the other in the same service like this

<actions mep="RequestResponse">
    <action name="ActionA" class="ClassA"/>
    <action name="ActionB" class="ClassB"/>
</actions>

Suppose that ActionA does some validations over the received msg. If the validations found that the msg is invalid, how does you send a response to the invoker about that failure?

Right now in my actions I set the response in the message at ActionA and put a mark in it indicating that I found an error in ActionA and ActionB checks for that mark before executing its code. I found this method useful but a burden because all of my actions have to start with:

if (!markIspressent) {
    //Code goes here
}
return message.

I have tried setting the response msg at ActionA and returning null to stop the pipeline but that isn't working. I also tried another method that I found of throwing an ActionProcessingFaultException(message,"SomeTextGoesInHere") but that also isn't working. My main problem with this second one is that the ESB tries to reprocess the msg that thrown that exception and I don't see the response that I set into message until the ESB gives up and sends it back. But that giving up takes up to 60s.

So my question is how can you send a response msg to the invoker before reaching up the end of the service pipeline.

Thanks

Foi útil?

Solução

The options in finishing earlier the pipeline are: - return null; - split the service into three (note service 1 is OneWay and based on your action's results routes to the appropriate service) Service 1

<actions mep="OneWay">
    <action name="ActionA" class="ClassA"/>
    <action name="ActionA1" class="RouteBasedOnMsgContentTo(Service 2 or Service 3)"/>
</actions>

Service 2

<actions mep="RequestResponse">
    <action name="ActionB" class="ClassB"/>
</actions>

Service 3

<actions mep="RequestResponse">
    <action name="ActionC" class="ClassC-SimplyRespondsTheProblem"/>
</actions>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top