On Apr 20, 2008, at 9:30 AM, wesley wrote:

I'm using ActiveMQ(v5.1) jca adapter in Resin 3.1 snapshot0331.

In my topic producer I manually create a JmsSesion and JmsConnection using JmsFactory and send a TextMessage, then close the connection explicitly. In my message driven bean I did not inject anything because resin should be responsible to call onMessage() method when there is a new message in topic.

I've met the 6h max-active-time problem.

After server running for 6 hours, it prints a log message:
closing pool item from active timeout:PoolItem[activemq, 0, ActiveMQManagedConnection]

I think it should be the container, which eventually invoked message driven bean when topic has new message, closed the connection when a timeout happened.

My questions:
1. How could I configure the "max-active-time" to a fairly long time for com.caucho.jca.ConnectionPool. I've googled around and found no useful info. I only knew how to do it for DBPool within <database> config tag. Is there any "max-active-time" attr could be placed within <resource-adapter> or <connection-factory>?

I've added this as a bug report as http://bugs.caucho.com/view.php?id=2618 . The connection-factory is using the JDBC defaults, which is not appropriate.


2. I felt strange that I have to create a new JmsConnection and JmsSession when producing a message, but need not to do it when consuming it. I think there should be a easy way to producing a message using resin IoC, eliminating the JmsConnection/JmsSession stuff.

I've added this as http://bugs.caucho.com/view.php?id=2619.

We'll need to create a com.caucho.jms.queue.JmsBlockingQueue bean to implement this for 3rd party JMS.

-- Scott


My current config is as below:
================================================
 <resource-adapter uri="activemq:">
  <init server-url="tcp://192.168.1.240:61616"/>
 </resource-adapter>
 <connection-factory uri="activemq:" name="activemq"/>
 <jms-topic uri="activemq:" name="clearCache">
<init physicalName="topic.clearCache"/> <!-- NOTE: There should be a resin documentation error: should be "physicalName", not "physical- name" -->
 </jms-topic>
 <ejb-message-bean class="com.buysou.cache.ClearCacheListener">
  <destination>#{clearCache}</destination>
 </ejb-message-bean>
====================================================

My topic producer code:
====================================================
 @Named("clearCache")
 Topic clearCacheTopic;
 @In
 ConnectionFactory jmsFactory;
 public void sendClearCacheMessage() {
  Connection conn = null;
  try {
   conn = jmsFactory.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(clearCacheTopic);
   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(session.createTextMessage("Clear cache at " + DateUtils.toDateTimeString(new Date())));
  } catch (JMSException e) {
   log.warn(StringUtils.stackTraceAsString(e));
  } finally {
   try {
    conn.close();
   } catch (Throwable ignore) {
   }
  }
 }
====================================================

My message driver bean code:
====================================================
public class ClearCacheListener implements MessageListener {
private static final Log log = LogFactory.getLog(ClearCacheListener.class);
 public void onMessage(Message message) {
  try {
   if (message instanceof TextMessage) {
    TextMessage txtMsg = (TextMessage) message;
    log.info(txtMsg.getText());
   } else if (message instanceof ObjectMessage) {
    ObjectMessage objMessage = (ObjectMessage) message;
    log.info(objMessage.getObject());
   }
  } catch (JMSException e) {
   log.warn(StringUtils.stackTraceAsString(e));
  }
 }
}
====================================================


Additional:
I tried the Resin's own JDBC queue and found it corrupt. I could only produce a message, and found the message inserted into database. But my message driven bean was never invoked.

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

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

Reply via email to