2 Replies Latest reply on May 26, 2014 8:41 AM by jmesnil

    JMS Message is being pushed twice during the restart

    murthy516

      Hi All,

      In JBOSS 7

      I've a JMS Producer which establishes the session,connection and sends the message to queue running on other server with the code:

        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

        env.put(Context.PROVIDER_URL, "remote://10.4.5.66:4447"));

        env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces:org.jboss.naming");

       

        Queue queue = (Queue) initialContext.lookup(queueName);

        connection = connectionFactory.createConnection(userName,password);

        Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);

        MessageProducer sender = session.createProducer(queue);

       

        TextMessage message = session.createTextMessage(textMessage);

        sender.send(message);

        connection.start();

        connection.close();

       

      This was being successful and no issue in this.It is being pushed successful to other server.Now,the problem is whenever the message got failed to push due to some issue like "The Queue Server where Consumer is sitting got down/network failure",the pushing has failed.

       

      But,after few minutes/hrs the server has started and the message which got failed to push has been successfully pushed to Queue server.

       

      This scenario has to be stopped.The reconnect should not happen and that transaction should be closed and session must be destroyed whenever that connection to server has failed for first time.

       

      My standalone-full.xml settings of JMS are

                      <jms-connection-factories>

                          <connection-factory name="InVmConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="in-vm"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/ConnectionFactory"/>

                              </entries>

                              <connection-ttl>-1</connection-ttl>

                          </connection-factory>

                          <connection-factory name="RemoteConnectionFactory">

                              <connectors>

                                  <connector-ref connector-name="netty"/>

                              </connectors>

                              <entries>

                                  <entry name="RemoteConnectionFactory"/>

                                  <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                              </entries>

                              <connection-ttl>-1</connection-ttl>

                          </connection-factory>

                          <pooled-connection-factory name="hornetq-ra">

                              <transaction mode="xa"/>

                              <max-pool-size>600</max-pool-size>

                              <connectors>

                                  <connector-ref connector-name="in-vm"/>

                              </connectors>

                              <entries>

                                  <entry name="java:/JmsXA"/>

                              </entries>

                              <connection-ttl>-1</connection-ttl>

                          </pooled-connection-factory>

                      </jms-connection-factories>

                      <address-settings>

                          <address-setting match="#">

                              <dead-letter-address>jms.queue.DLQ</dead-letter-address>

                              <expiry-address>jms.queue.ExpiryQueue</expiry-address>

                              <redelivery-delay>0</redelivery-delay>

                              <max-delivery-attempts>1</max-delivery-attempts>

                              <max-size-bytes>104857600</max-size-bytes>

                              <page-size-bytes>10485760</page-size-bytes>

                              <address-full-policy>PAGE</address-full-policy>

                              <message-counter-history-day-limit>10</message-counter-history-day-limit>

                          </address-setting>

                      </address-settings>

       

      Please suggest the same.

       

      Thanks

      Kris