Multi-thread questions

  • anonp

    anonp - 2003-03-21

    Hello,  I have more questions on multi-thread.

    If I create 2 different publishers on 2 different topics from the SAME session, can I use the 2 publishers on 2 different threads?  Although each publisher is operated by a single thread, they do share the same session and connection.  Is this alright?

    Likewise, if I create a publisher and a subcriber from the Same session, am I breaking anything?


    • anonp

      anonp - 2003-03-21

      Okay.  After reading posts from other forums, it seems to me that having 2 publishers operating on the same session in 2 threads is bad.

      As a result, I will need to have a pool of publishers.  Each of them will have its own session.  When I need to publish to a topic, I will get a publisher and then pass in the topic.  The function signature is:

      public void publish(Topictopic,                Messagemessage)

      However, topics are created via a TopicSession.  So, can a topic created by one TopicSession be used by another? 

      In the pool case, the topics are created by a controler TopicSession.  But the topic must be passed to the publisher who is using its own TopicSession.  Is this okay?


      • Jimmy P

        Jimmy P - 2003-03-21

        Hello there,
        Topic objects are totally thread-safe. You can pass them around as you see fit.

        The JMS spec defines that connection factories and destinations must be thread-safe objects. Other objects are implementation specific.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks