camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From usha Kanteti <u_kant...@yahoo.com>
Subject Messages not persisted during broker restart
Date Thu, 06 May 2010 13:58:44 GMT

HI,
I am newbi to JMS and here is the trouble that I see.

 1) I started the jms broker and producer and my producer code produced 10
messages to the topic   "myTopic". I see these messages in jconsole with
EnqueueCount=10 in "myTopic"
 2) I didn't configure any consumers for this topic  "myTopic"
 2) Now I stopped the jms broker and producer
 3) restarted the jms broker and producer and started producing another 10
messages to the same topic
 4) Now if I see  EnqueueCount on this topic "myTopic", it is still showing
10 but I am thinking, it should be 20 (10 previous ones + 10 current) as
they have not been consumed.

Now my question is are these messages persisted while the jms broker
restart.

I use camel activemq and here is my code snippet

######### JMSSERVER Broker
public class ConfigureJMSServer {

        Logger logger = Logger.getLogger(ConfigureJMSServer.class);
        private static final String jmsServerUrl="tcp://localhost:61616";
        public void startServer() {

                try {
                        BrokerService broker = new BrokerService();
                        // configure the broker
                        broker.addConnector(jmsServerUrl);
                        broker.setPersistent(true);
                        broker.start();
                } catch (Exception e) {
                        logger.info("##### Unable to start JMS Server");
                       
                }

##############################################

######### ActiveMQProducer  
public class ActiveMQProducer {

  private Connection connection;
  private Session session;
  private MessageProducer producer;
  private MessageConsumer consumer;

  public void init() throws Exception {
    ActiveMQConnectionFactory connectionFactory =
      new ActiveMQConnectionFactory("tcp://localhost:61616");
    connection = connectionFactory.createConnection();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Topic request = session.createTopic("myTopic");
    // and attach a consumer and producer to them
    producer = session.createProducer(request);
    producer.setDeliveryMode(DeliveryMode.PERSISTENT);
    // and start your engines...
    connection.start();
  }

 

  public void sendMessage(String messageText) throws Exception {
   producer.send(session.createTextMessage(messageText));
  }
 
  public void produce() throws Exception {
          this.init();
          for (int i=0; i < 10; i++ ) {
                  this.sendMessage("TEST TEST TEST");
          }
         // this.destroy();
  }

############################################################
my camel configuration
#####################################################

<!-- Bean Declarations  -->
    <bean id="configureJMSServer" class="jmsserver.ConfigureJMSServer"/>
    <bean id="jmsProducer" class="jmsserver.ActiveMQProducer"/>
   
       
        <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL"
value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=-1" />
        </bean>
       
       
        <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
                <property name="connectionFactory"
ref="jmsConnectionFactory" />
                <property name="useMessageIDAsCorrelationID" value="true" />
               
        </bean>
       
       
        <camelContext xmlns="http://camel.apache.org/schema/spring">
                <package>Start JMS Server</package>
                 
                 
                <route>
                        <!--  just a fake route to start the JMS server -->
                      <from
uri="file://src/test/resources/?fileName=testJMSMessage.xml&delay=1000&idempotent=true&noop=true"
/>  
                         <bean ref="configureJMSServer"
method="startServer"/>  
                          <bean ref="jmsProducer" method="produce"/>
                </route>
       </camelContext>

can somebody please suggest me how I can persist the messages in the jms
topics if they are not consumed. Thx. 
-- 
View this message in context: http://old.nabble.com/Messages-not-persisted-during-broker-restart-tp28474043p28474043.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message