1

I have a configuration that should service query parameters and return a response. Here is my configuration. Unfortunately, the Service Activator bean cannot be created by Spring.

<int-http:inbound-gateway request-channel="inChannel"
        reply-channel="outChannel" supported-methods="GET" 
        path="/ticket">

        <int-http:request-mapping consumes="text/plain" params="param1,param2,param3"
            produces="text/plain" />
</int-http:inbound-gateway>

<int:service-activator ref="ticketIssuingService" method="processTicket"
        input-channel="inChannel" output-channel="outChannel"/>

@MessageEndpoint
public class TicketIssuingService {



    public String processTicket(??? payload){
        System.out.println("Query Paramter String is "+payload);
        return null;
    }
}

http://localhost:8080/job/ticket?param1=type&param2=linkstate&param3=duration

How can I retrieve the parameters so that I can handoff to the processTicket method? Spring complains that no eligible methods were found. What should the arguments be for the method processTicket? Please help

1 Answer 1

2

For GET method without payload-expression the payload of the Message<?> for your inChannel is exactly this object:

MultiValueMap<String, String> requestParams = this.convertParameterMap(servletRequest.getParameterMap());

...

        if (payload == null) {
            if (requestBody != null) {
                payload = requestBody;
            }
            else {
                payload = requestParams;
            }
        }

So, that should be an answer for your question about the payload type in the processTicket service method.

Pay attention, please, that you can customize that payload via payload-expression and using some built-in SpEL EvaluationContext variables like:

#requestParams - the MultiValueMap from the ServletRequest parameterMap.
#pathVariables - the Map from URI Template placeholders and their values;
#matrixVariables - the Map of MultiValueMap according to Spring MVC Specification. Note, #matrixVariables require Spring MVC 3.2 or higher;
#requestAttributes - the org.springframework.web.context.request.RequestAttributes associated with the current Request;
#requestHeaders - the org.springframework.http.HttpHeaders object from the current Request;
#cookies - the Map<String, Cookie> of javax.servlet.http.Cookie s from the current Request. 

Some sample is like this to get the queryString:

payload-expression="T(org.springframework.web.context.request.RequestContextHolder).requestAttributes.request.queryString"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.