Session session2 = con2.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE); session2.close(); session2 = con2.createSession(true, Session.AUTO_ACKNOWLEDGE); session2.getTransacted(); session2.close();
private JMSProducer(final long timeout, String brokerURL) throws JMSException { // if brokerURL not defined before, get property if (brokerURL == null) { brokerURL = System.getProperty("broker.url"); } // Create a ConnectionFactory topicConnectionFactory = new ActiveMQConnectionFactory(brokerURL); topicConnection = topicConnectionFactory.createTopicConnection(); session = topicConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); topic = session.createTopic(TOPIC_NAME); topicConnection.start(); producer = session.createProducer(topic); this.timeout = timeout; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { topicConnection.stop(); producer.close(); session.close(); topicConnection.close(); } catch (final JMSException e) { System.err.println("Cannot stop the synchro service, probably already stopped?"); } } }); }
private JMSProducer(final long timeout, String brokerURL) throws JMSException { // if brokerURL not defined before, get property if (brokerURL == null) { brokerURL = System.getProperty("broker.url"); } // Create a ConnectionFactory topicConnectionFactory = new ActiveMQConnectionFactory(brokerURL); topicConnection = topicConnectionFactory.createTopicConnection(); session = topicConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); topic = session.createTopic(TOPIC_NAME); topicConnection.start(); producer = session.createProducer(topic); this.timeout = timeout; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { topicConnection.stop(); producer.close(); session.close(); topicConnection.close(); } catch (final JMSException e) { System.err.println("Cannot stop the synchro service, probably already stopped?"); } } }); }