0

In current model, we have a REST endpoint, which gets requestbody, based on which a jms text message is created and sent to JMS queue,

TextMessage outMessage = session.createTextMessage(messagePayloadText);
           ..          
outMessage.setStringProperty("clientType", clientType);
outMessage.setStringProperty("DYNAMIC", dynaHeader);

In above code DYNAMIC is required to help me in creating our url

<int:chain input-channel="gCStatusInChannel" output-channel="headerFilterChannel">
    <int:header-enricher>           
        <int:header name="Api-Key" value="B8872853E8B"></int:header>
        <int:header name="Accept" value="application/json" /> 
        <int:header name="Content-Type" value="application/json" />         
    </int:header-enricher>      
    <int-http:outbound-gateway  
           url="https://i-zaie.sr13.tst.bst/ia-zaaie/rest/search/v2/cReference/{cref}"
           http-method="PUT"               
           header-mapper="headerMapper" 
           expected-response-type="java.lang.String"
           encode-uri="false"
           request-factory="sslFactory">               
     <int-http:uri-variable name="cref" expression="headers['DYNAMIC']" />                 
    </int-http:outbound-gateway>
    <int:object-to-string-transformer></int:object-to-string-transformer>
</int:chain>

Everything works in this model. Now I want to use gateway instead of JMS

New code:

<int:gateway id="gService"
    service-interface="n.d.lr.eai.gw.GGateway"
    default-reply-channel="dest-channel"
    default-request-timeout="5000" default-reply-timeout="5000">
    <int:method name="vCreateSignal" request-channel="vCreateSignalInChannel"/> ...

Question: can i have method in gateway as below?

public String vCreateSignal(String caseDat, String dynamic);

what should I do to enable

<int:chain input-channel="gCStatusInChannel"...
..>

to get headers['DYNAMIC'] value and continue.

1 Answer 1

1

Yes, you can do that. What you just need is to add a @Header("DYNAMIC") into that dynamic parameter:

public String vCreateSignal(String caseDat, @Header("DYNAMIC") String dynamic);

And when you call this gateway's method you just specify an argument and it will be mapped to an appropriate header and that all: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints-chapter.html#gateway-mapping

Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't help and fully is not readable. Please, edit your question with a fully stack trace. BTW, I don't see how it is related to the <gateway> question...
solution works. Bad request was external service issue.

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.