Below is a simple servlet/MDB/resin-web combo that sends/reads a
message. It works in 4.0.27 but does not work in later versions. By
"does not work" I mean that the message does not appear to be sent at
all. At the 'fine' logging level there is an entry like:
[13-01-14 13:47:59.091] {resin-port-8080-39}
ClusterTopic[TestClusterTopic] sending
TextMessageImpl[ID:5dQYaEuP/vkAE8OpoeJQAA]

but never a subsequent entry like:
[13-01-14 13:51:22.083]
{ValueItemProcessor[PacketProcessor[mess...@aaa.app.admin.resin]]}
FileSubscriberQueue[TestClusterTopic] send message
TextMessageImpl[ID:/bKgP3znGffAE8Op2cowAA]

and never an entry indicating that the message was received by either
server in the cluster.

For my testing, the only configuration changes that I made to resin's
out-of-the-box config were the following properties:

log_level      : fine
app_servers    : 127.0.0.1:6801 127.0.0.1:6802
app-0.http     : 8080
app-1.http     : 8081
admin_user     : test
admin_password : {plain}test


Am I doing something wrong and I just got lucky that it worked in
earlier versions?

Dan


/**
 * Servlet implementation class CtTest
 */
public class CtTest extends HttpServlet {
        private static final long serialVersionUID = 1L;

        @javax.inject.Inject
        ClusterTopic<? extends Serializable> _topic;

        @Resource(mappedName = "jms/TestConnectionFactory")
        JmsConnectionFactory factory = new
com.caucho.jms.JmsConnectionFactory();

        /**
         * @see HttpServlet#HttpServlet()
         */
        public CtTest() {
                super();
        }

        /**
         * @see Servlet#init(ServletConfig)
         */
        public void init(ServletConfig config) throws ServletException {

                try {

                        // Initialize JMS objects
                        TopicConnection conn = factory.createTopicConnection();
                        Session session = conn.createSession(false,
                                        Session.AUTO_ACKNOWLEDGE);
                        MessageConsumer consumer = 
session.createConsumer(_topic);
                        consumer.setMessageListener(new TestListener());

                        // Subscribe to the topic.
                        _topic.subscribeTopic();

                        conn.start();

                } catch (JMSException je) {
                        System.out.println(je.toString());
                }
        }

        /**
         * @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse
         *      response)
         */
        protected void doGet(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, 
IOException {
                
                try {
                        // Initialize JMS objects
                        TopicConnection conn = factory.createTopicConnection();

                        // Publish the message.
                        TopicSession jmsSession = 
conn.createTopicSession(false, 1);
                        TopicPublisher publisher = 
jmsSession.createPublisher(_topic);
                        Message msg = jmsSession.createTextMessage("test Get");
                        System.out.println("**** Sending message");

                        ServletOutputStream out = response.getOutputStream();

                        publisher.publish(msg);

                        response.setContentType("text/plain");
                        out.print("Message Sent");
                        out.close();
                } catch (JMSException je) {
                        // Do exception handling
                }
        }

}


@MessageDriven(mappedName="TestClusterTopic",
activationConfig={@ActivationConfigProperty(
             propertyName="destinationType", propertyValue="javax.jms.Topic")})
public class TestListener implements MessageListener {
         
         public TestListener()
         {
         }
         
        public void onMessage(Message msg)
        {
                try {
                         System.out.println(String.format("**** Received 
message: '%s'",
((TextMessage)msg).getText()));
                } catch (JMSException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
}


<web-app xmlns='http://caucho.com/ns/resin'
xmlns:jms="urn:java:com.caucho.jms"
xmlns:resin="urn:java:com.caucho.resin"
xmlns:ee="urn:java:ee">

    <resin:JmsConnectionFactory resin:Jndi="jms/TestConnectionFactory"/>
       
        <jms:ClusterTopic>
          <jms:name>TestClusterTopic</jms:name>
        </jms:ClusterTopic>
        
        <servlet>
                <servlet-name>cttest</servlet-name>
                <load-on-startup/>
                <servlet-class>com.sendthisfile.trouble.CtTest</servlet-class>
        </servlet>
        <servlet-mapping servlet-name="cttest" url-pattern="/test"/>            
        
</web-app>


_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to