cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Baptiste Quenot (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (COCOON-1810) [PATCH] JMSEventMessageListener does not work
Date Wed, 19 Jul 2006 21:31:16 GMT
     [ http://issues.apache.org/jira/browse/COCOON-1810?page=all ]

Jean-Baptiste Quenot reassigned COCOON-1810:
--------------------------------------------

    Assignee:     (was: Jean-Baptiste Quenot)

> [PATCH] JMSEventMessageListener does not work
> ---------------------------------------------
>
>                 Key: COCOON-1810
>                 URL: http://issues.apache.org/jira/browse/COCOON-1810
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: JMS
>    Affects Versions: 2.1.9
>            Reporter: vincent Demay
>         Attachments: jndi.properties
>
>
> Event if the rigth jars are copied to WEB-INF/lib, JMSEventMessageListener does not work,
it can not create a connection.
> Here is a patch but it needs to copy the jndi.properties file from OpenJMS sample to
the cocoon classPath (see attachement)
> Index: /cvs/cocoon/cocoon_BRANCH_2_1_X/src/blocks/jms/java/org/apache/cocoon/components/jms/AbstractMessageListener.java
> ===================================================================
> --- /cvs/cocoon/cocoon_BRANCH_2_1_X/src/blocks/jms/java/org/apache/cocoon/components/jms/AbstractMessageListener.java
(revision 388114)
> +++ /cvs/cocoon/cocoon_BRANCH_2_1_X/src/blocks/jms/java/org/apache/cocoon/components/jms/AbstractMessageListener.java
(working copy)
> @@ -15,6 +15,8 @@
>   */
>  package org.apache.cocoon.components.jms;
>  
> +import javax.jms.Connection;
> +import javax.jms.ConnectionFactory;
>  import javax.jms.JMSException;
>  import javax.jms.MessageListener;
>  import javax.jms.Session;
> @@ -22,6 +24,10 @@
>  import javax.jms.TopicConnection;
>  import javax.jms.TopicSession;
>  import javax.jms.TopicSubscriber;
> +import javax.naming.Context;
> +import javax.naming.InitialContext;
> +import javax.naming.NamingException;
> +
>  import org.apache.avalon.framework.activity.Disposable;
>  import org.apache.avalon.framework.activity.Initializable;
>  import org.apache.avalon.framework.logger.AbstractLogEnabled;
> @@ -101,7 +107,7 @@
>      private JMSConnectionManager m_connectionManager;
>  
>      /* our session */
> -    private TopicSession m_session;
> +    private Session m_session;
>  
>      /* our subscriber */
>      private TopicSubscriber m_subscriber;
> @@ -121,7 +127,7 @@
>          m_connectionName = parameters.getParameter(CONNECTION_PARAM);
>          m_topicName = parameters.getParameter(TOPIC_PARAM);
>  
> -        m_subscriptionId = parameters.getParameter(SUBSCRIPTION_ID_PARAM, null);
> +        m_subscriptionId = parameters.getParameter(SUBSCRIPTION_ID_PARAM, "default_id");
//should not be null
>          m_selector = parameters.getParameter(MESSAGE_SELECTOR_PARAM, null);
>  
>      }
> @@ -168,26 +174,25 @@
>          // concrete implementations may want to override this
>          m_acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
>  
> -        // register this MessageListener with a TopicSubscriber
> -        final TopicConnection connection = (TopicConnection) m_connectionManager.getConnection(m_connectionName);
> -        if (connection != null) {
> -            m_session = connection.createTopicSession(false, m_acknowledgeMode);
> -            final Topic topic = m_session.createTopic(m_topicName);
> -            if (m_subscriptionId != null) {
> -                m_subscriber = m_session.createDurableSubscriber(topic, m_subscriptionId,
m_selector, false);
> -            }
> -            else {
> -                m_subscriber = m_session.createSubscriber(topic, m_selector, false);
> -            }
> +    	Context context;
> +		try {
> +			// The jndi.properties should be in the classpath
> +			// it will set up the connection (see OpenJMS samples)
> +			context = new InitialContext();
> +			String factoryName = "ConnectionFactory";
> +        	ConnectionFactory factory = (ConnectionFactory) context.lookup(factoryName);
> +        	Topic topic = (Topic) context.lookup(m_topicName);
> +        	Connection connection = factory.createConnection();
> +        	m_session = connection.createSession(
> +                       false, Session.AUTO_ACKNOWLEDGE);
> +        	m_subscriber = m_session.createDurableSubscriber(
> +                    topic, m_subscriptionId);
>              m_subscriber.setMessageListener(this);
>              // recover in case of reconnection
>              m_session.recover();
> -        }
> -        else {
> -            if (getLogger().isWarnEnabled()) {
> -                getLogger().warn("Could not obtain JMS connection '" + m_connectionName
+ "'");
> -            }
> -        }
> +		} catch (NamingException e) {
> +			getLogger().warn("Could not obtain JMS connection '" + m_connectionName + "'");
> +		}
>      }
>  
>      private void closeSubscriberAndSession() {

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message