package blog.activemq.jms.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.jms.*;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Bikash on 3/15/2016.
 */
@Component
public class DurableSenderScheduledTasks {

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Autowired
    private JmsTemplate jmsTemplate;

    @Scheduled(fixedRate = 2500)
    public void reportCurrentTime() {

        jmsTemplate.send("simpleTopic", new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                TextMessage textMessage = session.createTextMessage("Durable Message sent at " + dateFormat.format(new Date()));
                textMessage.setJMSCorrelationID("cid001");
                return textMessage;
            }
        });
    }
}

@@ -967,137 +967,21 @@
 c%22, 
-new MessageCreator() %7B%0A            @Override%0A            public Message createMessage(Session session) throws JMSException %7B%0A    
+session -%3E %7B%0A
     
@@ -1113,20 +1113,16 @@
         
-    
 textMess
@@ -1168,20 +1168,16 @@
         
-    
 return t
@@ -1192,22 +1192,8 @@
 ge;%0A
-            %7D%0A
     

inner class converted to lambda expression