Hi,

as far as I can see, you message is marked as non-persistent, however
if you want to set explicit time to live you have to set
isExplicitQosEnabled(). See here
http://www.jarvana.com/jarvana/view/org/springframework/spring/1.2.9/spring-1.2.9-javadoc.jar!/org/springframework/jms/core/JmsTemplate.html#isExplicitQosEnabled()
for more info.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net



On Thu, Dec 3, 2009 at 11:03 PM, neillott <neilmatthewl...@yahoo.com> wrote:
>
> Hi,
>
> I'm using activemq 5.3.0.
>
> Essentially, I'd like to have a queue that is not persistent whose producers
> will send non-persistent messages.
>
> If I send a message to the queue through the activemq ui and mark it as
> persistent delivery=false and timetolive=10000 -- after 10 seconds it goes
> away.
>
> However, if I set up a java application using spring as follows:
>
>  <bean id="activeMQConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>        <property name="brokerURL" value="tcp://10.254.0.47:61616"/>
>        <property name="useAsyncSend" value="true"/>
>
>    </bean>
>
>    <bean id="cachingConnectionFactory"
> class="org.springframework.jms.connection.CachingConnectionFactory">
>        <property name="targetConnectionFactory"
> ref="activeMQConnectionFactory"/>
>        <property name="sessionCacheSize" value="100"/>
>        <property name="exceptionListener" ref="preludeExceptionListener"/>
>    </bean>
>
>    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>        <constructor-arg ref="cachingConnectionFactory"/>
>        <property name="deliveryPersistent" value="false"/>
>        <property name="deliveryMode" value="1"/>
>        <property name="timeToLive" value="20000"/>
>    </bean>
>
> --- and here's my sender
>
> public void send(final String message)
>   {
>
>      log.info("delivery mode {}, timeToLive {}",
> jmsTemplate.getDeliveryMode(), jmsTemplate.getTimeToLive());
> //      jmsTemplate.convertAndSend(QUEUE_NAME, message);
>
>
>      MessageCreator mc = new MessageCreator()
>      {
>         public Message createMessage(Session session) throws JMSException
>         {
>            TextMessage msg = session.createTextMessage();
>            msg.setJMSPriority(9);
>            msg.setText("This is easy!");
>            return msg;
>         }
>      };
>
>      jmsTemplate.send(QUEUE_NAME, mc);
>
>   }
>
> --
>
> The message gets delivered to activemq however it gets marked as persistent
> and it never expires.
>
> Here's the log messages:
>
> 2009-12-03 14:58:29,927  INFO [main] (PreludeNavigationSender.send:68) -
> delivery mode 1, timeToLive 20000
> 2009-12-03 14:58:29,936 DEBUG [main]
> (CachingConnectionFactory.getSession:152) - Created cached Session for mode
> 1: ActiveMQSession {id=ID:flicker-54570-1259877509487-0:0:3,started=true}
> 2009-12-03 14:58:29,936 DEBUG [main] (JmsTemplate.execute:469) - Executing
> callback on JMS Session: ActiveMQSession
> {id=ID:flicker-54570-1259877509487-0:0:3,started=true}
> 2009-12-03 14:58:29,940 DEBUG [main]
> (CachingConnectionFactory$CachedSessionInvocationHandler.invoke:244) -
> Created cached MessageProducer for destination
> [queue://preludenavigationout]: ActiveMQMessageProducer {
> value=ID:flicker-54570-1259877509487-0:0:3:1 }
> 2009-12-03 14:58:29,952 DEBUG [main] (JmsTemplate.doSend:572) - Sending
> created message: ActiveMQTextMessage {commandId = 0, responseRequired =
> false, messageId = null, originalDestination = null, originalTransactionId =
> null, producerId = null, destination = null, transactionId = null,
> expiration = 0, timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime
> = 0, correlationId = null, replyTo = null, persistent = false, type = null,
> priority = 9, groupID = null, groupSequence = 0, targetConsumerId = null,
> compressed = false, userID = null, content = null, marshalledProperties =
> null, dataStructure = null, redeliveryCounter = 0, size = 0, properties =
> null, readOnlyProperties = false, readOnlyBody = false, droppable = false,
> text = This is easy!}
>
> Anyone have any ideas?
>
> Thanks,
>
> Neil
>
> --
> View this message in context: 
> http://old.nabble.com/Failing-to-send-non-persistent-ttl-message-using-spring-java-tp26634035p26634035.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Reply via email to