Changeset 27
- Timestamp:
- 05/28/13 18:21:37 (12 years ago)
- Location:
- trunk/objectmq
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/objectmq/.classpath
r22 r27 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="src" path="test"/> 4 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 5 6 <classpathentry kind="lib" path="lib/gson-2.2.3.jar"/> -
trunk/objectmq/src/omq/common/broker/Broker.java
r24 r27 23 23 import com.rabbitmq.client.Connection; 24 24 import com.rabbitmq.client.QueueingConsumer; 25 import com.rabbitmq.client.QueueingConsumer.Delivery; 25 26 import com.rabbitmq.client.ShutdownListener; 26 27 import com.rabbitmq.client.ShutdownSignalException; 27 import com.rabbitmq.client.QueueingConsumer.Delivery;28 28 29 29 public class Broker { … … 38 38 Environment.setEnvironment(env); 39 39 connection = OmqConnectionFactory.getNewConnection(env); 40 connection.addShutdownListener(new ShutdownListener() {41 @Override42 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 });59 40 channel = connection.createChannel(); 41 addFaultTolerance(); 60 42 try { 61 43 tryConnection(env); … … 165 147 } 166 148 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 167 184 } -
trunk/objectmq/src/omq/ztest/calculator/ClientTest.java
r24 r27 31 31 // Set info about where the message will be sent 32 32 env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange"); 33 env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");33 // env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug"); 34 34 35 35 // Set info about the queue & the exchange where the ResponseListener
Note: See TracChangeset
for help on using the changeset viewer.