code snippet is as follows:
public class ActivityLogPublisher implements ActivityLogging {
        private String m_url;
        private Context m_context;
        private TopicConnection m_topicConnection;
        static private String TOPIC_NAME = "topic/activityLogTopic";
        private Hashtable env = new Hashtable();
        private static final String CONNECTION_JNDI =
    "java:comp/env/jms/TCF";
        
        public ActivityLogPublisher() {
                try {
                        
                        // Create a context
                        
                        //WEBLOGIC SPECIFIC
                        //m_url = "t3://localhost:7001";
                        //JBOSS SPECIFIC
                        m_url = "jnp://localhost";
                        
                        m_context = getInitialContext();
                        // Create the connection and start it
//WEBLOGIC SPECIFIC                     
//                      TopicConnectionFactory cf =
//                              (TopicConnectionFactory) m_context.lookup(
//                                      "weblogic.jms.ConnectionFactory");

//JBOSS SPECIFIC
                        TopicConnectionFactory cf =
                                (TopicConnectionFactory) 
m_context.lookup(CONNECTION_JNDI);
                        m_topicConnection = cf.createTopicConnection();
                        m_topicConnection.start();

                } catch (Exception ex) {
                        ex.printStackTrace();
                        //throw ex;
                }
        }
        public void send(TransferObject to)
                throws RemoteException, JMSException, NamingException {
                Topic newTopic = null;
                TopicSession session = null;
                try {
                                System.out.println("ActivityLogPublisher.java.send:: 
to.getUserId " + to.getUserId());
                                System.out.println("ActivityLogPublisher.java.send:: 
to.getMsg " + to.getMsg());
                                
                                session =
                                        
m_topicConnection.createTopicSession(false,session.AUTO_ACKNOWLEDGE);
                        newTopic = (Topic) m_context.lookup(TOPIC_NAME);
                } catch (NamingException ex) {
                        newTopic = session.createTopic(TOPIC_NAME);
                        m_context.bind(TOPIC_NAME, newTopic);
                }
                TopicPublisher sender = session.createPublisher(newTopic);
                ObjectMessage om = session.createObjectMessage();
                om.setObject(to);
                sender.publish(om);

        }
  private Context getInitialContext() throws NamingException {
    
    try {
      // Get an InitialContext
      
      Hashtable h = new Hashtable();
      //h = null;
// WEBLOGIC SPECIFIC            
//      h.put(Context.INITIAL_CONTEXT_FACTORY,
//        "weblogic.jndi.WLInitialContextFactory");
//      h.put(Context.PROVIDER_URL, m_url);

//JBOSS SPECIFIC org.jboss.naming.NamingContextFactory
                System.out.println("test");
      h.put(Context.INITIAL_CONTEXT_FACTORY,
        "org.jnp.interfaces.NamingContextFactory");
      h.put(Context.PROVIDER_URL, m_url);
          h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
      return new InitialContext(h);
    }
    catch (NamingException ne) {
      log("We were unable to get a connection to the Jboss server at 
org.jboss.naming.NamingContextFactory"+m_url);
      log("Please make sure that the server is running.");
      throw ne;
    }
  }


ejb-jar.xml

<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <ejb-name>ActivityLogMessageBean</ejb-name>
      
<ejb-class>com.etindia.etnucleus.logging.activitylogging.ActivityLogMessageBean</ejb-class>
      <message-selector></message-selector>
      <transaction-type>Container</transaction-type>
      <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode> 
      <message-driven-destination>
        <destination-type>javax.jms.Topic</destination-type>
        <subscription-durability>NonDurable</subscription-durability>
      </message-driven-destination>
      
      <resource-ref> 
        <res-ref-name>jms/TCF</res-ref-name> 
        <res-type>javax.jms.TopicConnectionFactory</res-type> 
        <res-auth>Container</res-auth> 
      </resource-ref> 
      
      
    </message-driven>
  </enterprise-beans>
  <assembly-descriptor>
    <container-transaction>
      
        <ejb-name>ActivityLogMessageBean</ejb-name>
        <method-name>*</method-name>
      
      <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>


jboss.xml

  <enterprise-beans>
    <message-driven>
      <ejb-name>ActivityLogMessageBean</ejb-name>
      <configuration-name>Standard Message Driven Bean</configuration-name>
      <destination-jndi-name>topic/activityLogTopic</destination-jndi-name>

        <resource-ref> 
                <res-ref-name>jms/TCF</res-ref-name> 
                <jndi-name>TopicConnectionFactory</jndi-name> 
        </resource-ref> 
    </message-driven>

  </enterprise-beans>


thanks in advance

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3822640#3822640

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3822640


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to