Search code examples
javaqueueweblogicspring-integration

how to get JMS payload and header Message and queue type


here am getting Queue Body Content only,but want to get the value of payload,JMS Header value,queue type etc.. If i change createNewEmployee(String newData) to createNewEmployee(Message newData) it throws exceptions like no method found createNewEmployee(java.lang.String)

    <int-jms:message-driven-channel-adapter id="inBound" destination="requestQueue" channel="msgReceiver" />

    <int:service-activator id="msgRouter" input-channel="msgReceiver"   output-channel="msgSender" ref="routeClass" method="createNewEmployee"/>

    public String createNewEmployee(String newData) {}

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.Message;
import javax.jms.TextMessage;
    public String createEmployee(Message message) {
        String response = null;
        try {
            System.out.println("from  message message :" + message);
            TextMessage textMessage=(TextMessage)message;
            String operation=textMessage.getStringProperty("requestType");
            String newData=textMessage.getText();
            System.out.println("from operation :"+operation);
            System.out.println("from createCmcContact :"+newData);
}

Solution

  • Sounds like you need this property:

    /**
     * Specify whether the JMS request Message's body should be extracted prior
     * to converting into a Spring Integration Message. This value is set to
     * <code>true</code> by default. To send the JMS Message itself as a
     * Spring Integration Message payload, set this to <code>false</code>.
     * @param extractRequestPayload true if the request payload should be extracted.
     */
    public void setExtractRequestPayload(boolean extractRequestPayload) {
    

    It is extract-payload XML attribute of the <int-jms:message-driven-channel-adapter>.

    But it is really just the best guess since your createNewEmployee(Message newData) doesn't want to accept a Message, then it is javax.jms.Message but not org.springframework.messaging.Message.