You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Filip Hanik - Dev Lists <de...@hanik.com> on 2008/06/24 17:34:25 UTC

spec violation(?)-Temporary queue creation based on name

The fix to
http://issues.apache.org/activemq/browse/AMQ-1142

in revision:
http://svn.apache.org/viewvc?view=rev&revision=546476

causes the queue or topic creation to use the name to determine if it is 
supposed to be temporary or not, ignoring the call the client is making.

This simple test case

String connectionId = 
connection.getConnectionInfo().getConnectionId().toString();
topic = session.createTopic(connectionId);

returns a temporary topic, even though the API call was explicit it 
didn't want a temp topic.

I would say that this must violate the spec, that a temp queue is 
created when using an explicit API call to to create a regular one.

A quick fix would be to simply allow a system property to control the 
behavior (as seen below), but I will take a deeper look into 1142, and 
see if I can understand why this behavior was put into the session

Filip


Index: activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
===================================================================
--- 
activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java        
(revision 669337)
+++ 
activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java        
(working copy)
@@ -141,6 +141,9 @@
         */
        public static final int INDIVIDUAL_ACKNOWLEDGE=4;

+    public static final boolean STRICT_DESTINATION_CREATION =
+       
Boolean.getBoolean(System.getProperty("org.apache.activemq.STRICT_DESTINATION_CREATION", 
"false"));
+
     public static interface DeliveryListener {
         void beforeDelivery(ActiveMQSession session, Message msg);

@@ -1040,7 +1043,7 @@
      */
     public Queue createQueue(String queueName) throws JMSException {
         checkClosed();
-        if 
(queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
+        if 
(queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) 
&& (!STRICT_DESTINATION_CREATION)) {

             return new ActiveMQTempQueue(queueName);
         }
         return new ActiveMQQueue(queueName);
@@ -1066,9 +1069,11 @@
      *                 internal error.
      * @since 1.1
      */
+
+
     public Topic createTopic(String topicName) throws JMSException {
         checkClosed();
-        if 
(topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
+        if 
(topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) 
&& (!STRICT_DESTINATION_CREATION)) {

             return new ActiveMQTempTopic(topicName);
         }
         return new ActiveMQTopic(topicName);


Re: spec violation(?)-Temporary queue creation based on name

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Perhaps we should throw a JMSException in the createTopic if an
invalid (temp topic) name is used.  That would be much more spec
compliant.

On Tue, Jun 24, 2008 at 1:29 PM, Rob Davies <ra...@gmail.com> wrote:
> damn! :)
> On 24 Jun 2008, at 17:37, Filip Hanik - Dev Lists wrote:
>
>> ok, all I have to do is this
>>
>> javax.jms.Session.createTopic("ID:/mytopic");
>>
>> and activeMQ creates a temp topic,
>>
>> how is that non JMS API?
>>
>> Filip
>>
>> Rob Davies wrote:
>>>
>>> How does that violate the spec - when you are using non JMS API's to get
>>> that info ?
>>>
>>> On 24 Jun 2008, at 16:34, Filip Hanik - Dev Lists wrote:
>>>
>>>> The fix to
>>>> http://issues.apache.org/activemq/browse/AMQ-1142
>>>>
>>>> in revision:
>>>> http://svn.apache.org/viewvc?view=rev&revision=546476
>>>>
>>>> causes the queue or topic creation to use the name to determine if it is
>>>> supposed to be temporary or not, ignoring the call the client is making.
>>>>
>>>> This simple test case
>>>>
>>>> String connectionId =
>>>> connection.getConnectionInfo().getConnectionId().toString();
>>>> topic = session.createTopic(connectionId);
>>>>
>>>> returns a temporary topic, even though the API call was explicit it
>>>> didn't want a temp topic.
>>>>
>>>> I would say that this must violate the spec, that a temp queue is
>>>> created when using an explicit API call to to create a regular one.
>>>>
>>>> A quick fix would be to simply allow a system property to control the
>>>> behavior (as seen below), but I will take a deeper look into 1142, and see
>>>> if I can understand why this behavior was put into the session
>>>>
>>>> Filip
>>>>
>>>>
>>>> Index:
>>>> activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
>>>> ===================================================================
>>>> --- activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
>>>>        (revision 669337)
>>>> +++ activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
>>>>        (working copy)
>>>> @@ -141,6 +141,9 @@
>>>>      */
>>>>     public static final int INDIVIDUAL_ACKNOWLEDGE=4;
>>>>
>>>> +    public static final boolean STRICT_DESTINATION_CREATION =
>>>> +
>>>> Boolean.getBoolean(System.getProperty("org.apache.activemq.STRICT_DESTINATION_CREATION",
>>>> "false"));
>>>> +
>>>>  public static interface DeliveryListener {
>>>>      void beforeDelivery(ActiveMQSession session, Message msg);
>>>>
>>>> @@ -1040,7 +1043,7 @@
>>>>   */
>>>>  public Queue createQueue(String queueName) throws JMSException {
>>>>      checkClosed();
>>>> -        if
>>>> (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
>>>> +        if
>>>> (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) &&
>>>> (!STRICT_DESTINATION_CREATION)) {
>>>>
>>>>          return new ActiveMQTempQueue(queueName);
>>>>      }
>>>>      return new ActiveMQQueue(queueName);
>>>> @@ -1066,9 +1069,11 @@
>>>>   *                 internal error.
>>>>   * @since 1.1
>>>>   */
>>>> +
>>>> +
>>>>  public Topic createTopic(String topicName) throws JMSException {
>>>>      checkClosed();
>>>> -        if
>>>> (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
>>>> +        if
>>>> (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) &&
>>>> (!STRICT_DESTINATION_CREATION)) {
>>>>
>>>>          return new ActiveMQTempTopic(topicName);
>>>>      }
>>>>      return new ActiveMQTopic(topicName);
>>>>
>>>
>>>
>>>
>>
>
>



-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Open Source SOA
http://open.iona.com

Re: spec violation(?)-Temporary queue creation based on name

Posted by Rob Davies <ra...@gmail.com>.
damn! :)
On 24 Jun 2008, at 17:37, Filip Hanik - Dev Lists wrote:

> ok, all I have to do is this
>
> javax.jms.Session.createTopic("ID:/mytopic");
>
> and activeMQ creates a temp topic,
>
> how is that non JMS API?
>
> Filip
>
> Rob Davies wrote:
>> How does that violate the spec - when you are using non JMS API's  
>> to get that info ?
>>
>> On 24 Jun 2008, at 16:34, Filip Hanik - Dev Lists wrote:
>>
>>> The fix to
>>> http://issues.apache.org/activemq/browse/AMQ-1142
>>>
>>> in revision:
>>> http://svn.apache.org/viewvc?view=rev&revision=546476
>>>
>>> causes the queue or topic creation to use the name to determine if  
>>> it is supposed to be temporary or not, ignoring the call the  
>>> client is making.
>>>
>>> This simple test case
>>>
>>> String connectionId =  
>>> connection.getConnectionInfo().getConnectionId().toString();
>>> topic = session.createTopic(connectionId);
>>>
>>> returns a temporary topic, even though the API call was explicit  
>>> it didn't want a temp topic.
>>>
>>> I would say that this must violate the spec, that a temp queue is  
>>> created when using an explicit API call to to create a regular one.
>>>
>>> A quick fix would be to simply allow a system property to control  
>>> the behavior (as seen below), but I will take a deeper look into  
>>> 1142, and see if I can understand why this behavior was put into  
>>> the session
>>>
>>> Filip
>>>
>>>
>>> Index: activemq-core/src/main/java/org/apache/activemq/ 
>>> ActiveMQSession.java
>>> ===================================================================
>>> --- activemq-core/src/main/java/org/apache/activemq/ 
>>> ActiveMQSession.java        (revision 669337)
>>> +++ activemq-core/src/main/java/org/apache/activemq/ 
>>> ActiveMQSession.java        (working copy)
>>> @@ -141,6 +141,9 @@
>>>       */
>>>      public static final int INDIVIDUAL_ACKNOWLEDGE=4;
>>>
>>> +    public static final boolean STRICT_DESTINATION_CREATION =
>>> +        
>>> Boolean 
>>> .getBoolean 
>>> (System 
>>> .getProperty("org.apache.activemq.STRICT_DESTINATION_CREATION",  
>>> "false"));
>>> +
>>>   public static interface DeliveryListener {
>>>       void beforeDelivery(ActiveMQSession session, Message msg);
>>>
>>> @@ -1040,7 +1043,7 @@
>>>    */
>>>   public Queue createQueue(String queueName) throws JMSException {
>>>       checkClosed();
>>> -        if  
>>> (queueName 
>>> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
>>> +        if  
>>> (queueName 
>>> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) && (! 
>>> STRICT_DESTINATION_CREATION)) {
>>>
>>>           return new ActiveMQTempQueue(queueName);
>>>       }
>>>       return new ActiveMQQueue(queueName);
>>> @@ -1066,9 +1069,11 @@
>>>    *                 internal error.
>>>    * @since 1.1
>>>    */
>>> +
>>> +
>>>   public Topic createTopic(String topicName) throws JMSException {
>>>       checkClosed();
>>> -        if  
>>> (topicName 
>>> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
>>> +        if  
>>> (topicName 
>>> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) && (! 
>>> STRICT_DESTINATION_CREATION)) {
>>>
>>>           return new ActiveMQTempTopic(topicName);
>>>       }
>>>       return new ActiveMQTopic(topicName);
>>>
>>
>>
>>
>


Re: spec violation(?)-Temporary queue creation based on name

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
ok, all I have to do is this

javax.jms.Session.createTopic("ID:/mytopic");

and activeMQ creates a temp topic,

how is that non JMS API?

Filip

Rob Davies wrote:
> How does that violate the spec - when you are using non JMS API's to 
> get that info ?
>
> On 24 Jun 2008, at 16:34, Filip Hanik - Dev Lists wrote:
>
>> The fix to
>> http://issues.apache.org/activemq/browse/AMQ-1142
>>
>> in revision:
>> http://svn.apache.org/viewvc?view=rev&revision=546476
>>
>> causes the queue or topic creation to use the name to determine if it 
>> is supposed to be temporary or not, ignoring the call the client is 
>> making.
>>
>> This simple test case
>>
>> String connectionId = 
>> connection.getConnectionInfo().getConnectionId().toString();
>> topic = session.createTopic(connectionId);
>>
>> returns a temporary topic, even though the API call was explicit it 
>> didn't want a temp topic.
>>
>> I would say that this must violate the spec, that a temp queue is 
>> created when using an explicit API call to to create a regular one.
>>
>> A quick fix would be to simply allow a system property to control the 
>> behavior (as seen below), but I will take a deeper look into 1142, 
>> and see if I can understand why this behavior was put into the session
>>
>> Filip
>>
>>
>> Index: 
>> activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
>> ===================================================================
>> --- 
>> activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java        
>> (revision 669337)
>> +++ 
>> activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java        
>> (working copy)
>> @@ -141,6 +141,9 @@
>>        */
>>       public static final int INDIVIDUAL_ACKNOWLEDGE=4;
>>
>> +    public static final boolean STRICT_DESTINATION_CREATION =
>> +       
>> Boolean.getBoolean(System.getProperty("org.apache.activemq.STRICT_DESTINATION_CREATION", 
>> "false"));
>> +
>>    public static interface DeliveryListener {
>>        void beforeDelivery(ActiveMQSession session, Message msg);
>>
>> @@ -1040,7 +1043,7 @@
>>     */
>>    public Queue createQueue(String queueName) throws JMSException {
>>        checkClosed();
>> -        if 
>> (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) 
>> {
>> +        if 
>> (queueName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) 
>> && (!STRICT_DESTINATION_CREATION)) {
>>
>>            return new ActiveMQTempQueue(queueName);
>>        }
>>        return new ActiveMQQueue(queueName);
>> @@ -1066,9 +1069,11 @@
>>     *                 internal error.
>>     * @since 1.1
>>     */
>> +
>> +
>>    public Topic createTopic(String topicName) throws JMSException {
>>        checkClosed();
>> -        if 
>> (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) 
>> {
>> +        if 
>> (topicName.startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) 
>> && (!STRICT_DESTINATION_CREATION)) {
>>
>>            return new ActiveMQTempTopic(topicName);
>>        }
>>        return new ActiveMQTopic(topicName);
>>
>
>
>


Re: spec violation(?)-Temporary queue creation based on name

Posted by Rob Davies <ra...@gmail.com>.
How does that violate the spec - when you are using non JMS API's to  
get that info ?

On 24 Jun 2008, at 16:34, Filip Hanik - Dev Lists wrote:

> The fix to
> http://issues.apache.org/activemq/browse/AMQ-1142
>
> in revision:
> http://svn.apache.org/viewvc?view=rev&revision=546476
>
> causes the queue or topic creation to use the name to determine if  
> it is supposed to be temporary or not, ignoring the call the client  
> is making.
>
> This simple test case
>
> String connectionId =  
> connection.getConnectionInfo().getConnectionId().toString();
> topic = session.createTopic(connectionId);
>
> returns a temporary topic, even though the API call was explicit it  
> didn't want a temp topic.
>
> I would say that this must violate the spec, that a temp queue is  
> created when using an explicit API call to to create a regular one.
>
> A quick fix would be to simply allow a system property to control  
> the behavior (as seen below), but I will take a deeper look into  
> 1142, and see if I can understand why this behavior was put into the  
> session
>
> Filip
>
>
> Index: activemq-core/src/main/java/org/apache/activemq/ 
> ActiveMQSession.java
> ===================================================================
> --- activemq-core/src/main/java/org/apache/activemq/ 
> ActiveMQSession.java        (revision 669337)
> +++ activemq-core/src/main/java/org/apache/activemq/ 
> ActiveMQSession.java        (working copy)
> @@ -141,6 +141,9 @@
>        */
>       public static final int INDIVIDUAL_ACKNOWLEDGE=4;
>
> +    public static final boolean STRICT_DESTINATION_CREATION =
> +        
> Boolean 
> .getBoolean 
> (System 
> .getProperty("org.apache.activemq.STRICT_DESTINATION_CREATION",  
> "false"));
> +
>    public static interface DeliveryListener {
>        void beforeDelivery(ActiveMQSession session, Message msg);
>
> @@ -1040,7 +1043,7 @@
>     */
>    public Queue createQueue(String queueName) throws JMSException {
>        checkClosed();
> -        if  
> (queueName 
> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
> +        if  
> (queueName 
> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) && (! 
> STRICT_DESTINATION_CREATION)) {
>
>            return new ActiveMQTempQueue(queueName);
>        }
>        return new ActiveMQQueue(queueName);
> @@ -1066,9 +1069,11 @@
>     *                 internal error.
>     * @since 1.1
>     */
> +
> +
>    public Topic createTopic(String topicName) throws JMSException {
>        checkClosed();
> -        if  
> (topicName 
> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) {
> +        if  
> (topicName 
> .startsWith(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX) && (! 
> STRICT_DESTINATION_CREATION)) {
>
>            return new ActiveMQTempTopic(topicName);
>        }
>        return new ActiveMQTopic(topicName);
>