/** * {@inheritDoc} */ public Destination getDestination(EndpointInfo endpointInfo, Bus bus) throws IOException { JMSConfiguration jmsConf = JMSConfigFactory.createFromEndpointInfo(bus, endpointInfo, null); return new JMSDestination(bus, endpointInfo, jmsConf); }
protected void restartConnection() { int tries = 0; do { tries++; try { deactivate(); this.jmsListener = createTargetDestinationListener(); LOG.log(Level.INFO, "Established JMS connection"); } catch (Exception e1) { jmsListener = null; String message = "Exception on reconnect. Trying again, attempt num " + tries; if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.WARNING, message, e1); } else { LOG.log(Level.WARNING, message); } try { Thread.sleep(jmsConfig.getRetryInterval()); } catch (InterruptedException e2) { shutdown = true; } } } while (jmsListener == null && !shutdown); }
public void shutdown() { this.shutdown = true; getLogger().log(Level.FINE, "JMSDestination shutdown()"); this.deactivate(); }
@Override public void initialize(Server server, Bus bus) { Destination destination = server.getDestination(); if (destination instanceof JMSDestination) { JMSConfiguration jmsConfig = ((JMSDestination) destination).getJmsConfig(); updateJMSConfig(jmsConfig); } }
/** * Initialize jmsTemplate and jmsListener from jms configuration data in jmsConfig {@inheritDoc} */ public void activate() { getLogger().log(Level.FINE, "JMSDestination activate().... "); jmsConfig.ensureProperlyConfigured(); try { this.jmsListener = createTargetDestinationListener(); } catch (Exception e) { if (e.getCause() != null && InvalidClientIDException.class.isInstance(e.getCause())) { throw e; } if (!jmsConfig.isOneSessionPerConnection()) { // If first connect fails we will try to establish the connection in the background new Thread(new Runnable() { @Override public void run() { restartConnection(); } }).start(); } } }
origLoader = ClassLoaderUtils.setThreadContextClassloader(loader); getLogger().log(Level.FINE, "JMS destination received message " + message + " on " + jmsConfig.getTargetDestination()); processExceptions(inMessage.getExchange()); getLogger().log(Level.FINE, "Request message has been suspended"); } catch (UnsupportedEncodingException ex) { getLogger().log(Level.WARNING, "can't get the right encoding information. " + ex); } catch (JMSException e) { throw JMSUtil.convertJmsException(e);
@Override public void run() { restartConnection(); } }).start();
public JMSDestination(Bus b, EndpointInfo info, JMSConfiguration jmsConfig) { super(b, getTargetReference(info, b), info); this.bus = b; this.jmsConfig = jmsConfig; info.setProperty(OneWayProcessorInterceptor.USE_ORIGINAL_THREAD, Boolean.TRUE); loader = bus.getExtension(ClassLoader.class); int restartLimit = jmsConfig.getMaxSuspendedContinuations() * jmsConfig.getReconnectPercentOfMax() / 100; this.suspendedContinuations = new ThrottlingCounter(restartLimit, jmsConfig.getMaxSuspendedContinuations()); }
@Override public void initialize(Server server, Bus bus) { checkJmsConfig(); Destination destination = server.getDestination(); if (!(destination instanceof JMSDestination)) { throw new ConfigurationException(new Message("JMSCONFIGFEATURE_ONLY_JMS", LOG)); } JMSDestination jmsDestination = (JMSDestination)destination; jmsDestination.setJmsConfig(jmsConfig); super.initialize(server, bus); }
@Override public void initialize(Server server, Bus bus) { Destination destination = server.getDestination(); if (destination instanceof JMSDestination) { JMSDestination jmsDestination = (JMSDestination)destination; jmsDestination.getJmsConfig().setConnectionFactory(connectionFactory); } super.initialize(server, bus); } private class JMSConduitConfigOutInterceptor extends AbstractPhaseInterceptor<Message> {
public void onException(JMSException exception) { if (!shutdown) { LOG.log(Level.WARNING, "Exception on JMS connection. Trying to reconnect", exception); restartConnection(); } } };
private void checkJmsTransportTransaction() { Destination destination = server.getDestination(); if (destination instanceof JMSDestination) { JMSDestination jmsDestination = (JMSDestination)destination; JMSConfiguration jmsConfig = jmsDestination.getJmsConfig(); if (jmsConfig.isSessionTransacted()) { TransactionManager tm = (TransactionManager) getContext().getTransactionManager(); if (tm == null) { throw new IllegalStateException("No TransactionManager available"); } else if (tm instanceof PlatformTransactionManager) { jmsConfig.setSessionTransacted(true); jmsConfig.setTransactionManager((PlatformTransactionManager)tm); jmsConfig.setUseJms11(false); setSynchronous(true); transactionEnabled = true; } } } }