1 Reply Latest reply on Oct 8, 2003 11:26 AM by Stephane Nicoll

    connecting to a remote topic in a MDB

    Pucky Loucks Newbie

      I'm wanting to have a MDB on server2 subscribe to a Topic on server one. How to I instatiate the MDB to start listening to the topic?

      currently I have the following.

      private MessageDrivenContext context;
      private Logger log = Logger.getLogger(this.getClass());
      private TopicConnection topicConnection = null;
      private TopicConnectionFactory factory = null;
      private Topic pixpoSearchTopic = null;
      private TopicSubscriber subscriber = null;

      public void ejbCreate()
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jmsdestinationserver.mynet.net");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
      InitialContext remoteic = new InitialContext(env);
      InitialContext messaging = new InitialContext(env);
      factory = (TopicConnectionFactory) messaging.lookup("TopicConnectionFactory");
      // Get a Topic
      pixpoSearchTopic = (Topic) messaging.lookup("topic/myRemoteTopic");
      // Get a TopicConnection
      topicConnection = factory.createTopicConnection();
      // Get a TopicSession
      TopicSession session;
      session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      // Get a TopicSubscriber
      subscriber = session.createSubscriber(pixpoSearchTopic);
      // Start the connection
      catch(Exception e)
      log.error("Error in the ejbCreate of the MDB on server2: " + e.getMessage());

      public void onMessage(Message msg)
      log.error("found a new message");

      public void ejbRemove()
      log.error("got a search request");

      public void setMessageDrivenContext(MessageDrivenContext ctx)
      this.context = ctx;

      Hope someone can help me out on this...