The JMSRecieverConnection.send() flushes the response to transport output stream and returns the responseMessage to replyQueue. But the responseMessage is TextMessage[null, null]. Here is the code I am using, can anybody help in finding what is going wrong?
JMS transport configuration,
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName"
value="temp.connection" />
</bean>
<!-- Bean definition for jndi template -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory
</prop>
</props>
</property>
</bean>
<bean id="testQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName"
value="temp.test.request" />
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
<bean id="defaultMessageListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="testQueue"/>
<property name="messageListener">
<bean class="org.springframework.ws.transport.jms.WebServiceMessageListener">
<property name="messageFactory" ref="messageFactory"/>
<property name="messageReceiver" ref="messageDispatcher"/>
</bean>
</property>
</bean>
<bean id="messageDispatcher" class="org.springframework.ws.soap.server.SoapMessageDispatcher">
<property name="endpointMappings">
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop
key="{http://www.test.com/schema/mms/MSGM}ExampleRequest">exampleRequestEndpoint</prop>
</props>
</property>
<property name="interceptors">
<list>
<!-- ref bean="validatingInterceptor" /> -->
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
</list>
</property>
</bean>
</property>
</bean>
</beans>
Client code,
public static void main(String[] args) throws JMSException, Exception
{
String messageID = null;
String outString = null;
String qcfName = "temp.connection";
String qnameIn = "temp.test.request";
String qnameOut = "";
boolean verbose = false;
QueueSession session = null;
QueueConnection connection = null;
Context ctx = null;
QueueConnectionFactory qcf = null;
Queue inQueue = null;
Queue outQueue = null;
FileReader fr = new FileReader(new File("c:/myMsgm.xml"));
StringWriter sw = new StringWriter();
IOUtil.copyCompletely(fr, sw);
outString = sw.toString();
System.out.println("input : "+sw.toString());
Hashtable ht = new Hashtable();
ht.put("weblogic.jndi.replicateBindings", "false");
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
ctx = new InitialContext(ht);
qcf = (QueueConnectionFactory)ctx.lookup( qcfName );
inQueue = (Queue)ctx.lookup( qnameIn );
outQueue = (Queue)ctx.lookup( qnameOut );
connection = qcf.createQueueConnection();
connection.start();
boolean transacted = false;
session = connection.createQueueSession( transacted, Session.CLIENT_ACKNOWLEDGE);
QueueReceiver queueReceiver =null;
QueueSender queueSender = null;
time = Calendar.getInstance().getTime().toString();
for (int i = 0; i < 1; i++) {
queueSender = session.createSender(inQueue);
TextMessage outMessage = session.createTextMessage(outString);
Queue tempQueue = session.createTemporaryQueue();
outMessage.setJMSReplyTo(tempQueue);
queueSender.send(outMessage);
messageID = outMessage.getJMSMessageID();
System.out.println("Message ID : "+messageID);
// String selector = "JMSCorrelationID = '"+messageID+"'";
queueReceiver = session. createReceiver(tempQueue);
Message inMessage = queueReceiver.receive();
System.out.println("inMessage type : "+inMessage.getJMSType());
System.out.println("inMessage : "+inMessage);
if ( inMessage instanceof TextMessage ){
String replyString = ((TextMessage) inMessage).getText();
System.out.println("response message : "+ replyString);
}
}
System.out.println("start time : "+ time);
System.out.println("end time : "+ Calendar.getInstance().getTime());
sw.close();
queueReceiver.close();
queueSender.close();
session.close();
session = null;
connection.close();
connection = null;
}
Output
Message ID : ID:<507866.1373381334004.0> inMessage type : null inMessage : TextMessage[ID:<507866.1373381341790.0>, null] response message : null start time : Tue Jul 09 15:48:53 BST 2013 end time : Tue Jul 09 15:49:01 BST 2013
The responseMessage is TextMessage[ID:<507866.1373381341790.0>, null] while sending reply to replyQueue in onSendAfterWrite of JMSReceiverConnection.
This problem is fixed using Spring-ws-core 1.5.4. This was a bug in spring-ws-core 1.5.1 and fixed from 1.5.3. Thanks to the people who have taken a look to resolve it.
reference: https://jira.springsource.org/browse/SWS-367
Prabhu