这里只获取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);
}
答案 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
。