11 Replies Latest reply on Nov 20, 2008 12:02 PM by timfox

    Why ServerSessionImpl::doHandleCreateQueue is not calling jo

    clebert.suconic

      Original Subject: Why ServerSessionImpl::doHandleCreateQueue is not calling journal.addDestination

      Maybe I'm confused on when addDestination should be called?

      But the fact is, if you call session.createQueue, you will have BindingRecords on the Journal, but not DestinationRecords.


      But other places, such as JMSServerManagerImpl are also calling addDestination.


      And actually, do we really need AddDestination records? couldn't we just have a single record (Binding(AddressName, QueueName))?

        • 1. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
          ataylor

          As far as i can see there are 2 main reasons.

          1. security, if a destination doesn't exist then a client needs the correct security permissions to create a binding or mapping.

          2. in regard to topics, there are initially no mappings, so you need to create a destination that queues can be bound to.

          • 2. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
            timfox

            The reason is, we need some way to denote the existence of a topic.

            JMS API requires IllegalDestinationException to be thrown when routing to a topic that doesn't exist.

            A topic with no subscriptions would otherwise be indistinguishable from no topic.

            • 3. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
              clebert.suconic

              Ok.. I see one inconsistence then between two different methods for creating Queues. On JMSServerManagerImpl.createQueue and ServerSessionImpl.doHandleCreateQueue.


              JMSServerManagerImpl is creating a destination when Queues are created:


              public boolean createQueue(final String queueName, final String jndiBinding) throws Exception
               {
               JBossQueue jBossQueue = new JBossQueue(queueName);
               postOffice.addDestination(jBossQueue.getSimpleAddress(), true);
               messagingServer.createQueue(jBossQueue.getAddress(), jBossQueue.getAddress());
              


              While ServerSessionImpl::doHandleCreateQueue is only creating the binding.

              
               public void doHandleCreateQueue(final SessionCreateQueueMessage packet)
               {
               SimpleString address = packet.getAddress();
              
               SimpleString queueName = packet.getQueueName();
              
               SimpleString filterString = packet.getFilterString();
              
               boolean temporary = packet.isTemporary();
              
               boolean durable = packet.isDurable();
              
               boolean fanout = packet.isFanout();
              
               Packet response = null;
              
               try
               {
               // make sure the user has privileges to create this queue
               if (!postOffice.containsDestination(address))
               {
               securityStore.check(address, CheckType.CREATE, this);
               }
              
               Binding binding = postOffice.getBinding(queueName);
              
               if (binding != null)
               {
               throw new MessagingException(MessagingException.QUEUE_EXISTS);
               }
              
               Filter filter = null;
              
               if (filterString != null)
               {
               filter = new FilterImpl(filterString);
               }
              
               binding = postOffice.addBinding(address, queueName, filter, durable, temporary, fanout);
              


              • 4. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                jmesnil

                 

                "clebert.suconic@jboss.com" wrote:

                JMSServerManagerImpl is creating a destination when Queues are created:

                ...

                While ServerSessionImpl::doHandleCreateQueue is only creating the binding.



                The two bits of code are not on the same level: JMSServerManager creates a *JMS* Queue (which implies the creation of a destination for the corresponding core queue) while ServerSessionImpl creates a *core* queue

                • 5. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                  clebert.suconic

                  I still don't understand why the JMS Queue needs a Destination, while the Core Queue doesn't.

                  I understand about the Topics requiring the Destination. But what about the core Queues?


                  Shouldn't both queues work the same way, i.e. or Having a Destination or not having it?

                  • 6. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                    timfox

                    The post office maintains a set of queues bound to an address, the post office also maintains a set of "allowable destinations" (see the code).

                    If postoffice.checkallowable = true then the post office will only allow messsages to be routed to allowable destinations.

                    In other words it's a way of restricting the set of addresses to which you are allowed to route.

                    This is useful for JMS, since JMS prohibits routing to addresses (JMS queues or topics) which "do not exist".

                    Without such an address we wouldn't have any way of determining if such an address exists.

                    • 7. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                      timfox

                      If you can think of a better way of doing this that does not involve maintaining allowable addresses I am open to suggestions.

                      • 8. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                        timfox

                        What is the reason for this comment and TODO in the code:

                        // TODO: This is related to http://www.jboss.com/index.html?module=bb&op=viewtopic&t=145597
                        


                        • 9. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                          clebert.suconic

                          I need to get a list of valid Addresses in order to start the PageStores.

                          I was expecting Queues to be listed on the destinations, but they weren't.

                          So, to get a list of Addresses, I needed:

                          I - to interact over Destinations.

                          II - interact over Bindings to find the core-queues that didn't have Destination.

                          Then I had the list of valid queues.



                          That's why I actually started this thread.. I needed to go over all the bindings to extra a list of valid addresses.

                          IMO the CoreQueue should aways have a destination like the JMS queues. Then I would just need to interact with Destinations.


                          If we conclude this is the way it should be, I will just remove the TODO and leave the code as it is.

                          • 10. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                            ataylor

                            can't you just call getMappings() and iterate thru the key set.

                            • 11. Re: Why ServerSessionImpl::doHandleCreateQueue is not callin
                              timfox

                              If the stores are just started lazily there's no need for any of this.

                              The current code Clebert added in post office is incorrect since it assumes there will always be an allowable address for each address, which is incorrect.