0

JMSRecieverConnection.send() 将响应刷新到传输输出流并将 responseMessage 返回到 replyQueue。但是 responseMessage 是 TextMessage[null, null]。这是我正在使用的代码,有人可以帮忙找出问题所在吗?

  • 消费者配置

JMS 传输配置,

<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>
  • 客户端代码,

     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;
    
    }
    
  • 输出

消息 ID:ID:<507866.1373381334004.0> inMessage 类型:null inMessage:TextMessage[ID:<507866.1373381341790.0>,null] 响应消息:null 开始时间:Tue Jul 09 15:48:53 BST 2013 结束时间:Tue Jul 2013 年英国夏令时 09 时 15:49:01

  • 调试结果

The responseMessage is TextMessage[ID:<507866.1373381341790.0>, null] while sending reply to replyQueue in onSendAfterWrite of JMSReceiverConnection.

4

1 回答 1

0

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

于 2013-07-10T15:50:24.193 回答