expireMessagesPeriod for activemq broker

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

expireMessagesPeriod for activemq broker

jeffrey
In our activemq.xml file, simplified a little bit:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/sch
ema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sprin
gframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd     http://
activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  </bean>
  <bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope
="singleton" init-method="start" destroy-method="stop">
  </bean>
  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="testname" dataDirectory="${activemq.data}">
    <managementContext>
      <managementContext createConnector="false"/>
    </managementContext>
    <persistenceAdapter>
      <kahaDB directory="${activemq.data}/kahadb"/>
    </persistenceAdapter>
    <systemUsage>
      <systemUsage>
        <memoryUsage>
          <memoryUsage percentOfJvmHeap="70"/>
        </memoryUsage>
        <storeUsage>
          <storeUsage limit="1 gb"/>
        </storeUsage>
        <tempUsage>
          <tempUsage limit="500 mb"/>
        </tempUsage>
      </systemUsage>
    </systemUsage>
    <sslContext>
      <sslContext keyStore="/etc/BROKER.jks" keyStorePassword="xxx" trustStore="/etc/BROKERTRUST.jks" trustStorePassword="xxx"/>
    </sslContext>
    <transportConnectors>
      <transportConnector name="ssl" uri="ssl://hostname:61616?needClientAuth=true&amp;maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    </transportConnectors>
    <shutdownHooks>
      <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook"/>
    </shutdownHooks>
    <plugins>
      <jaasCertificateAuthenticationPlugin configuration="CertLogin"/>
      <authorizationPlugin>
        <map>
          <authorizationMap>
            <authorizationEntries>
              <authorizationEntry topic="ActiveMQ.Advisory.&gt;" read="*" write="*" admin="*"/>
              <authorizationEntry queue="events" reader="read" admin="writer" write="writer"/>
              </authorizationEntries>
          </authorizationMap>
        </map>
      </authorizationPlugin>
    </plugins>
    <destinationPolicy>
      <policyMap>
        <policyEntries>
          <policyEntry queue="events" expireMessagesPeriod="10000"/>
        </policyEntries>
      </policyMap>
    </destinationPolicy>
  </broker>
</beans>

At the bottom, we have this expireMessagesPeriod, which I assume should be in milliseconds, I cannot find this properly stated anywhere.
But I am writing to this queue, and if no one receives the message within 10 seconds, I am expecting it to expire and be deleted from the broker.  This functionality does not seem to be working at all, even reducing the time to 1 has no effect.  When the receiver program reconnects, it receives all the messages that should have expired.

Is there something I am missing in the xml to enable this feature, or something I could be doing in my sending client to cause this?  I am using ActiveMQ 5.9, both Java and C++ APIs. But in this scenario I am sending with Java and receiving with C++.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: expireMessagesPeriod for activemq broker

Tim Bain
You're right that the units for that parameter are milliseconds.

But I think you've misunderstood what it does; that setting specifies how
often the broker should look for messages whose expiration date has
arrived, and process them (e.g. by moving them to the DLQ), but the
messages have to have already been given a timeout at which they'll
expire.  I use Camel to send my messages, and there's a URI option that
Camel provides to set the timeout, but there's definitely a call within the
ActiveMQ API to do it.  I can't tell you what it is since I haven't needed
it, but Google should turn it up for you easily enough.

On Wed, Sep 24, 2014 at 3:50 PM, jeffrey <[hidden email]> wrote:

> In our activemq.xml file, simplified a little bit:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:amq="http://activemq.apache.org/sch
> ema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.sprin
> gframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd     http://
> activemq.apache.org/schema/core
> http://activemq.apache.org/schema/core/activemq-core.xsd">
>   <bean
>
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>   </bean>
>   <bean id="logQuery"
> class="org.fusesource.insight.log.log4j.Log4jLogQuery"
> lazy-init="false" scope
> ="singleton" init-method="start" destroy-method="stop">
>   </bean>
>   <broker xmlns="http://activemq.apache.org/schema/core"
> brokerName="testname" dataDirectory="${activemq.data}">
>     <managementContext>
>       <managementContext createConnector="false"/>
>     </managementContext>
>     <persistenceAdapter>
>       <kahaDB directory="${activemq.data}/kahadb"/>
>     </persistenceAdapter>
>     <systemUsage>
>       <systemUsage>
>         <memoryUsage>
>           <memoryUsage percentOfJvmHeap="70"/>
>         </memoryUsage>
>         <storeUsage>
>           <storeUsage limit="1 gb"/>
>         </storeUsage>
>         <tempUsage>
>           <tempUsage limit="500 mb"/>
>         </tempUsage>
>       </systemUsage>
>     </systemUsage>
>     <sslContext>
>       <sslContext keyStore="/etc/BROKER.jks" keyStorePassword="xxx"
> trustStore="/etc/BROKERTRUST.jks" trustStorePassword="xxx"/>
>     </sslContext>
>     <transportConnectors>
>       <transportConnector name="ssl"
>
> uri="ssl://hostname:61616?needClientAuth=true&maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
>     </transportConnectors>
>     <shutdownHooks>
>       <bean xmlns="http://www.springframework.org/schema/beans"
> class="org.apache.activemq.hooks.SpringContextHook"/>
>     </shutdownHooks>
>     <plugins>
>       <jaasCertificateAuthenticationPlugin configuration="CertLogin"/>
>       <authorizationPlugin>
>         <map>
>           <authorizationMap>
>             <authorizationEntries>
>               <authorizationEntry topic="ActiveMQ.Advisory.>" read="*"
> write="*" admin="*"/>
>               <authorizationEntry queue="events" reader="read"
> admin="writer" write="writer"/>
>               </authorizationEntries>
>           </authorizationMap>
>         </map>
>       </authorizationPlugin>
>     </plugins>
>     <destinationPolicy>
>       <policyMap>
>         <policyEntries>
>           <policyEntry queue="events" expireMessagesPeriod="10000"/>
>         </policyEntries>
>       </policyMap>
>     </destinationPolicy>
>   </broker>
> </beans>
>
> At the bottom, we have this expireMessagesPeriod, which I assume should be
> in milliseconds, I cannot find this properly stated anywhere.
> But I am writing to this queue, and if no one receives the message within
> 10
> seconds, I am expecting it to expire and be deleted from the broker.  This
> functionality does not seem to be working at all, even reducing the time to
> 1 has no effect.  When the receiver program reconnects, it receives all the
> messages that should have expired.
>
> Is there something I am missing in the xml to enable this feature, or
> something I could be doing in my sending client to cause this?  I am using
> ActiveMQ 5.9, both Java and C++ APIs. But in this scenario I am sending
> with
> Java and receiving with C++.
>
> Thanks
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/expireMessagesPeriod-for-activemq-broker-tp4685839.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: expireMessagesPeriod for activemq broker

jeffrey
So what is the time used if the field is not supplied?

If the number is given as 0?

If a message has timed out, but the queue has not been cleaned yet, will a client still receive the message if it asks for it? Or will the broker refuse to release the timedout message and send the next  valid one?

Reply | Threaded
Open this post in threaded view
|

Re: expireMessagesPeriod for activemq broker

Tim Bain
The default value, the meaning of "0", and the units for that field are
documented at http://activemq.apache.org/per-destination-policies.html
along with all the other options for policies.

In my experience, clients that are delivered an expired message will not
process it.  For the scenario you describe, I don't know whether the broker
or the client would be the one to identify and delete the expired message
(though you could probably check the source code if you were curious), but
the end result will be that the message will not be processed.

On Thu, Sep 25, 2014 at 8:28 AM, jeffrey <[hidden email]> wrote:

> So what is the time used if the field is not supplied?
>
> If the number is given as 0?
>
> If a message has timed out, but the queue has not been cleaned yet, will a
> client still receive the message if it asks for it? Or will the broker
> refuse to release the timedout message and send the next  valid one?
>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/expireMessagesPeriod-for-activemq-broker-tp4685839p4685868.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>