Changeset 27


Ignore:
Timestamp:
05/28/13 18:21:37 (11 years ago)
Author:
stoda
Message:
 
Location:
trunk/objectmq
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/objectmq/.classpath

    r22 r27  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" path="test"/>
    45        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    56        <classpathentry kind="lib" path="lib/gson-2.2.3.jar"/>
  • trunk/objectmq/src/omq/common/broker/Broker.java

    r24 r27  
    2323import com.rabbitmq.client.Connection;
    2424import com.rabbitmq.client.QueueingConsumer;
     25import com.rabbitmq.client.QueueingConsumer.Delivery;
    2526import com.rabbitmq.client.ShutdownListener;
    2627import com.rabbitmq.client.ShutdownSignalException;
    27 import com.rabbitmq.client.QueueingConsumer.Delivery;
    2828
    2929public class Broker {
     
    3838                        Environment.setEnvironment(env);
    3939                        connection = OmqConnectionFactory.getNewConnection(env);
    40                         connection.addShutdownListener(new ShutdownListener() {
    41                                 @Override
    42                                 public void shutdownCompleted(ShutdownSignalException cause) {
    43                                         if (connection.isOpen()) {
    44                                                 try {
    45                                                         connection.close();
    46                                                 } catch (IOException e) {
    47                                                         e.printStackTrace();
    48                                                 }
    49                                         }
    50                                         try {
    51                                                 Properties env = Environment.getEnvironment();
    52                                                 connection = OmqConnectionFactory.getNewWorkingConnection(env);
    53                                                 channel = connection.createChannel();
    54                                         } catch (Exception e) {
    55                                                 e.printStackTrace();
    56                                         }
    57                                 }
    58                         });
    5940                        channel = connection.createChannel();
     41                        addFaultTolerance();
    6042                        try {
    6143                                tryConnection(env);
     
    165147        }
    166148
     149        private static void addFaultTolerance() {
     150                connection.addShutdownListener(new ShutdownListener() {
     151                        @Override
     152                        public void shutdownCompleted(ShutdownSignalException cause) {
     153
     154                                if (cause.isHardError()) {
     155                                        if (connection.isOpen()) {
     156                                                try {
     157                                                        connection.close();
     158                                                } catch (IOException e) {
     159                                                        e.printStackTrace();
     160                                                }
     161                                        }
     162                                        try {
     163                                                Properties env = Environment.getEnvironment();
     164                                                connection = OmqConnectionFactory.getNewWorkingConnection(env);
     165                                                channel = connection.createChannel();
     166                                                addFaultTolerance();
     167                                        } catch (Exception e) {
     168                                                e.printStackTrace();
     169                                        }
     170                                } else {
     171                                        Channel channel = (Channel) cause.getReference();
     172                                        if (channel.isOpen()) {
     173                                                try {
     174                                                        channel.close();
     175                                                } catch (IOException e) {
     176                                                        e.printStackTrace();
     177                                                }
     178                                        }
     179                                }
     180                        }
     181                });
     182        }
     183
    167184}
  • trunk/objectmq/src/omq/ztest/calculator/ClientTest.java

    r24 r27  
    3131                // Set info about where the message will be sent
    3232                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
    33                 env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");
     33                // env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");
    3434
    3535                // Set info about the queue & the exchange where the ResponseListener
Note: See TracChangeset for help on using the changeset viewer.