Here are modifications to the lingo ExampleTest class. Do attachments work on the mailing list? I CC'ed you james in case they get filtered out. I attached these files:

spring-client.xml
spring-server.xml
ExampleTest.java

The java file is a modified version where I added a main method. Here is how you can reproduce the problem. Save those 3 files in the example package of the lingo 1.1 src/test folder. Setup your environment to use ActiveMQ 4. The supplied XML files only work with v4.

There are 2 issues I found:
- Problem A: server terminates when broker stops
- Problem B: client adds threads indefinitely when broker restarts

Please let me know if the way I coded both version of the main (client and server) are not correct.

Problem A (server stops):

1- Execute
     java org.logicblaze.lingo.example.ExampleTest server
  The server uses failover and waits for the broker to be available.

2- Start activemq on its default port (61616). I am currently using March 23rd snapshot.

3- The server connects to the broker.

4- Stop activemq

5- The server (started in #1) terminates.


Problem B (client adds threads indefinitely):

1- Execute
     java org.logicblaze.lingo.example.ExampleTest client
  The client uses failover and waits for the broker to be available.

2- Start activemq.

3- The client connects to the broker, sends the message and waits for response.

4- Stop activemq

5- The client disconnects from the broker but continues to wait for the answer.

6- restart activemq

7- The client connects to the broker.

8- a TcpTransport thread is created at each 20 seconds or so indefinitely.

--
Claude

James Strachan a écrit :
I've no idea how to reproduce this in ActiveMQ; I wonder if you could
create a JUnit test case? I'm pretty sure the failover code is working
and will keep retrying forever until someone closes the
connection/transport.

I wonder if your problem is actually that Lingo is timing things out
and failing with an exception if a request does not complete within a
specific amount of time?

Can you reproduce your issue using just JMS?


/** 
 * 
 * Copyright 2005 LogicBlaze, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 * 
 **/
package org.logicblaze.lingo.example;

import org.logicblaze.lingo.SpringTestSupport;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * A simple test case which tests the use of Lingo from Spring using the Spring 
XML deployment descriptor
 *
 * @version $Revision: 1.5 $
 */
public class ExampleTest extends SpringTestSupport {

    public void testClient() throws Exception {
        // START SNIPPET: simple

        // lets lookup the client in Spring
        // (we could be using DI here instead)
        ExampleService service = (ExampleService) getBean("client");

        // regular synchronous request-response
        int i = service.regularRPC("Foo");
        System.out.println("Found result: " + i);

        // async request-response
        TestResultListener listener = new TestResultListener();
        service.asyncRequestResponse("IBM", listener);

        // the server side will now invoke the listener
        // objects's methods asynchronously
        // END SNIPPET: simple

        listener.waitForAsyncResponses(2);

        System.out.println("Found results: " + listener.getResults());
    }

    public void testOneWayMethodCall() throws Exception {
        ExampleServiceImpl serverImpl = (ExampleServiceImpl) 
getBean("serverImpl");

        callOneWayMethod();

        serverImpl.assertOneWayCalled();
    }

    protected void callOneWayMethod() {
        ExampleService service = (ExampleService) getBean("client");

        long start = System.currentTimeMillis();
        service.someOneWayMethod("James", 35);
        logTime("Method invocation took", System.currentTimeMillis() - start);
        System.out.println("### client side method invoked");
    }

    protected void logTime(String text, long millis) {
        System.out.println(text + " took: " + (millis) + " milli(s) to 
complete");
    }

    protected void setUp() throws Exception {
        super.setUp();

        // lets force the creation of the server side
        getBean("server");
    }

    protected String getApplicationContextXml() {
        return "org/logicblaze/lingo/example/spring.xml";
    }
    
    public static void main(String[] args){
      if (args.length == 0 || (!"server".equals(args[0]) && 
!"client".equals(args[0])))
        throw new IllegalArgumentException("Missing or invalid program 
argument. \nUsage: java org.logicblaze.lingo.example.ExampleTest [server | 
client]");
      
      if ("server".equals(args[0])){
        ApplicationContext ctx = new 
ClassPathXmlApplicationContext("org/logicblaze/lingo/example/spring-server.xml");
        //ctx.getBean("server");
      } else {
        ConfigurableApplicationContext ctx = new 
ClassPathXmlApplicationContext("org/logicblaze/lingo/example/spring-client.xml");
        try {
          ExampleService service = (ExampleService) ctx.getBean("client");
          TestResultListener listener = new TestResultListener();
          service.asyncRequestResponse("allo", listener);
          listener.waitForAsyncResponses(1);
        } finally {
          ctx.close();
        }
      }
    }
}
<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: spring -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd";>

<beans>

  <!-- client side proxy-->
  <bean id="client" class="org.logicblaze.lingo.jms.JmsProxyFactoryBean">
    <property name="serviceInterface" value="org.logicblaze.lingo.example.ExampleService"/>
    <property name="connectionFactory" ref="jmsFactory"/>
    <property name="destination" ref="exampleDestination"/>
  </bean>

  <!-- JMS ConnectionFactory to use -->
  <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="failover:(tcp://localhost:61616)?maxReconnectAttempts=0"/>
  </bean>

  <bean id="exampleDestination" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg index="0" value="test.org.logicblaze.lingo.example"/>
  </bean>
</beans>

<!-- END SNIPPET: spring -->
<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: spring -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd";>

<beans>

  <!-- the server side -->
  <bean id="server" class="org.logicblaze.lingo.jms.JmsServiceExporter">
    <property name="service" ref="serverImpl"/>
    <property name="serviceInterface" value="org.logicblaze.lingo.example.ExampleService"/>
    <property name="connectionFactory" ref="jmsFactory"/>
    <property name="destination" ref="exampleDestination"/>
  </bean>

  <!-- the actual implementation of the service - which is only made public for testing purposes -->
  <bean id="serverImpl" class="org.logicblaze.lingo.example.ExampleServiceImpl" singleton="true"/>


  <!-- JMS ConnectionFactory to use -->
  <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="failover:(tcp://localhost:61616)?maxReconnectAttempts=0"/>
  </bean>

  <bean id="exampleDestination" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg index="0" value="test.org.logicblaze.lingo.example"/>
  </bean>
</beans>

<!-- END SNIPPET: spring -->

Reply via email to