title: Send last sent message to new consumer on a jms topic
body: <p>Is it possible to configure the topic to store a copy of just the last message and send this to new connections without knowing client identifiers or other info?</p>
  
  <p><strong>Update:</strong>
  From the info provided by Shashi I found this two pages where they describe a use case similar to mine (applied over stock prices) by using <a href="http://activemq.apache.org/retroactive-consumer.html" rel="noreferrer">retroactive consumer</a> and a <a href="http://activemq.apache.org/subscription-recovery-policy.html" rel="noreferrer">subscription recovery policy</a>. How ever I'm not getting the desired behaviour. What I currently do is:</p>
  
  <p>Include in the activemq the folowing lines in the policyEntry for <code>topic="&gt;"</code></p>
  
  <pre><code>&lt;subscriptionRecoveryPolicy&gt;
    &lt;fixedCountSubscriptionRecoveryPolicy maximumSize="1"/&gt; 
  &lt;/subscriptionRecoveryPolicy&gt;
  </code></pre>
  
  <p>Add to the URL used to connect to the brocker (using activemq-cpp) <code>consumer.retroactive=true</code>.</p>
  
  <p>Set the consumer has durable. (But I strongly think this is not want since I only need the last one, but without it I didn't get any message when starting the consumer for the second time) </p>
  
  <ol>
  <li><p>Start up the broker.</p></li>
  <li><p>Start the consumer.</p></li>
  <li><p>Send a message to the topic using the activemq web admin console. (I receive it in the consumer, as expected)</p></li>
  <li><p>Stop consumer.</p></li>
  <li><p>Send another message to the topic.</p></li>
  <li><p>Start consumer. I receive the message, also as expected.</p></li>
  </ol>
  
  <p>However, if the consumer receives a message, then it goes offline (stop process) and then I restart it, it doesn't get the last message back.</p>
  
  <p>The goal is to whenever the consumer starts get the last message, no mater what (obviously, except when there weren't messages sent to the topic).</p>
  
  <p>Any ideas on what I'm missing?</p>
  
  <p><strong>Background:</strong></p>
  
  <p>I have a device which publishes his data to a topic when ever its data changes. A variable number of consumer may be connected to this topic, from 0 to less than 10. There is only one publisher in the topic and always publish all of his data as a single message (little data, just a couple of fields of a sensor reading). The publication rate of this information is variable, not necessarily time based, when something changes a new updated message is sent to the broker.
  The problem is that when a new consumer connects to the topic it has no data of the device readings until a new message is send to the topic by the device. This could be solve by creating an additional queue so new connections can subscribe to the topic and then request the device for the current reading through the queue (the device would consume the queue message which would be a request for data, and then response in the same queue).
  But Since the messages send to the topic are always information complete I was wondering if is it possible to configure the topic to store a copy of just the last message and send this to new connections without know client identifiers or other info?</p>
  
  <p>Current broker in use is ActiveMQ.</p>