Oh, that's unfortunate. I used the "< raw >" tag using nabble. 

Here is the artemis (2.9) client code snippet (hopefully this works):

public class SampleProducer {
    public static void main(String[] args) throws JMSException,
InterruptedException {
        String brokerUrl = "tcp://artemis:61616?ha=true";
        ConnectionFactory cf = new ActiveMQConnectionFactory(brokerUrl);

        try (Connection connection = cf.createConnection();
             Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE)) {
            connection.start();

            Queue queue = session.createQueue("myJmsQueue");
            try (MessageProducer producer = session.createProducer(queue)) {
                for (int i = 0; i < 500000; i++) {
                    try {
                        TextMessage message =
session.createTextMessage("Message " + i);
                        producer.send(message);
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                    Thread.sleep(500);
                }
            }
        }
    }
}


Here is the exception that I get:
javax.jms.IllegalStateException: Session is closed
        at
org.apache.activemq.artemis.jms.client.ActiveMQSession.checkClosed(ActiveMQSession.java:1249)
        at
org.apache.activemq.artemis.jms.client.ActiveMQSession.createTextMessage(ActiveMQSession.java:248)



I do have a follow up question - is the sample code correct in terms of a
producer handling automatic failover/failback?



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Reply via email to