如何获取JMS有效负载和头消息和队列类型

时间:2017-11-02 09:55:28

标签: java queue weblogic spring-integration

这里只获取Queue Body Content,但想获得有效负载,JMS Header值,队列类型等的值。     如果我将createNewEmployee(String newData)更改为createNewEmployee(Message newData),则抛出异常,如找不到方法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);
}

1 个答案:

答案 0 :(得分:0)

听起来你需要这个属性:

/**
 * 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) {

extract-payload的{​​{1}} XML属性。

但这只是最好的猜测,因为<int-jms:message-driven-channel-adapter>不想接受createNewEmployee(Message newData),那么它是Message但不是javax.jms.Message