1 2 Previous Next 20 Replies Latest reply on Nov 15, 2012 6:39 AM by gaohoward Go to original post
      • 15. Re: invalid type code
        gaohoward

        In that case all I can say is that your using two threads with two sessions won't affect the order of message flow. It is not possible that a new order could jump ahead of an old order in the process.

         

        Howard

        • 16. Re: invalid type code
          akhil08

          "It is not possible that a new order could jump ahead of an old order in the process."...

           

          My concern was not between orders. My concern is between order (published in first thread) and it's executions(2nd thread). An order should always be delivered before it's executions. Can you take a look at the test case again.

          • 17. Re: invalid type code
            akhil08

            Let me know if we are not on the same page regarding test case.

             

            Thread1 publishes an order. Only after Thread1 publishes an order system starts receiving executions from exchange. We publish these executions on separate thread. All we care is the order should go first before it's executions. These two threads Thread1 and Thread2 uses different sessions. The reason being client can create and publish new orders on Thread1 while it is still publishing executions for previous order .  Is the order gaunranteed between an Order Message and it's executions here?

             

            If the Order is gauranteed then what does the documentation "

            Each time a client creates a TopicPublisher on a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent."

            for createPublisher mean in this link http://docs.oracle.com/javaee/1.4/api/javax/jms/TopicSession.html

            • 18. Re: invalid type code
              gaohoward

              Thread1 publishes an order. Only after Thread1 publishes an order system starts receiving executions from exchange. We publish these executions on separate thread. All we care is the order should go first before it's executions. These two threads Thread1 and Thread2 uses different sessions. The reason being client can create and publish new orders on Thread1 while it is still publishing executions for previous order .  Is the order gaunranteed between an Order Message and it's executions here?

              I don't think the order between an 'order' message and an 'execution' message can be guaranteed by how you use JMS sessions. This should be your applications responsibility to make sure the client doesn't send the execution before its order.

               

              If the Order is gauranteed then what does the documentation "

              Each time a client creates a TopicPublisher on a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent."

              for createPublisher mean in this link http://docs.oracle.com/javaee/1.4/api/javax/jms/TopicSession.html

              My understanding is that it is so said as opposed to the 'send ordering' concept in JMS 1.1 spec (Sect 4.4.10.2). "no ordering relationship" doesn't mean the messages can jump back and forth, it's more like a guidance for a JMS provider to implement a JMS broker.

              • 19. Re: invalid type code
                akhil08

                So you are telling as long as 'order' message is published first before 'execution' even though i use different sessions to publish 'order' message and 'execution' message, the 'order' message is always delivered first ?

                 

                 

                Also another trivial question.

                 

                Lets say I have two sessions Session1 and Session2 and I have corresponding Publishers publihser1 created using session1 and publihser2 created using session2.

                 

                If i created an Object message using Session1( object message =  session1.createObjectMessage()), should i be using only publisher1 to publish this message (publisher1.publish(message))

                or can i use either publisher1 or publisher2 to publish message created by session1?

                • 20. Re: invalid type code
                  gaohoward

                  So you are telling as long as 'order' message is published first before 'execution' even though i use different sessions to publish 'order' message and 'execution' message, the 'order' message is always delivered first ?

                  It should be noted that within JMS area publish/send and receive/subscribe are separated from, or asynchronous to each other. A message is published first doesn't mean the message will be delivered first. In addition it makes no sense to talk about message orders on different destinations (topic/queues).

                   

                  For example, if an order message (let's call it O1) is published to TopicA, i.e. when producer.send(O1) is returned (assuming message is persistent), what you can be sure is that the message is successfully reached HornetQ server. At this point you can't say the message is already reached to each living subscriber.

                   

                  Then if an execution message (call E1) is send right after producer.send(O1) returned (I don't know how you can control this among the two threads, I assume you have some signal to notify Thread2?), you can be sure that E1 reaches the HornetQ server after O1 does. If O1 and E1 are targeted to the same topic (topicA), then you can be sure the order to reach subscribers will be O1 and E1 (however remember we talk about it before, this is subject to some conditions, like priorities, failures etc). If O1 and E1 are targeted to different topics (like E1 is for topic B), then you can't be sure about the ordering. (as JMS spec says, 'no relationship').

                   

                  Using one session or two has little meaning regarding the order issue here. It is only for avoiding concurrent access to one session (which is also not allowed by jms spec).

                   

                   

                  Also another trivial question.

                   

                  Lets say I have two sessions Session1 and Session2 and I have corresponding Publishers publihser1 created using session1 and publihser2 created using session2.

                   

                  If i created an Object message using Session1( object message =  session1.createObjectMessage()), should i be using only publisher1 to publish this message (publisher1.publish(message))

                  or can i use either publisher1 or publisher2 to publish message created by session1?

                  This is not defined clearly in JMS spec, neither in HornetQ's manual. But I believe you can do this without problem (as once the message is created, it seems has no reference to it's creating session). But my question is why you need to do that? It should be more conformant in my opinion that you use the publisher's own session to create the messages.

                  1 2 Previous Next