activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Davies <rajdav...@gmail.com>
Subject Re: scheduler message deliver immediately
Date Thu, 27 Oct 2016 08:24:16 GMT
Can’t spot any  gottchas. Could you set the Scheduler directory for your embedded broker
- just to check its actually being created ? - see https://github.com/apache/activemq/blob/master/activemq-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/JobSchedulerTestSupport.java#L100
for inspiration


> On 27 Oct 2016, at 08:28, CallMeXYZ <amos.callmexyz@gmail.com> wrote:
> 
> I'm using ActiveMQ with Spring , I have set the /SchedulerSupport / but seems
> not to work.
> Below is my configuration.
> ============================
> @Configuration
> @EnableJms
> public class MessageConfig {
>    private static final String DEFAULT_BROKER_URL =
> "tcp://localhost:61616";
> 
>    public static final String DESTINATION_FB = "fb";
>    private static final String USER_NAME = "admin";
>    private static final String USER_PASSWORD = "admin";
>    @Profile("embedded")
>    @Bean(initMethod = "start", destroyMethod = "stop")
>    public BrokerService brokerService() throws Exception {
>        BrokerService brokerService = new BrokerService();
>        brokerService.setSchedulerSupport(true);
>        brokerService.addConnector(DEFAULT_BROKER_URL);
>        return brokerService;
>    }
>    @Bean
>    public ConnectionFactory connectionFactory() {
>        ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory();
>       connectionFactory.setBrokerURL(DEFAULT_BROKER_URL);
>         /*  connectionFactory.setUserName(USER_NAME);
>        connectionFactory.setPassword(USER_PASSWORD);*/
>        connectionFactory.setTrustedPackages(Arrays.asList("com.test.test",
> "java.lang"));
>        return connectionFactory;
>    }
> 
>    @Bean
>    public JmsTemplate jmsTemplate(ConnectionFactory factory) {
>        JmsTemplate template = new JmsTemplate();
>        template.setConnectionFactory(factory);
>        template.setDefaultDestinationName(DESTINATION_FB);
>        return template;
>    }
>    @Bean
>    public DefaultMessageListenerContainer
> jmsListenerContainerFactory(ConnectionFactory connectionFactory){
>        DefaultMessageListenerContainer containerFactory = new
> DefaultMessageListenerContainer();
>        containerFactory.setConnectionFactory(connectionFactory);
>        return containerFactory;
>    }
> }
> ========Sender============
> @Component
> public class MessageSender {
>    @Autowired
>    JmsTemplate jmsTemplate;
>    public void sendMessage(final ResultCode data) {
> 
>        jmsTemplate.send(new MessageCreator(){
>            @Override
>            public Message createMessage(Session session) throws
> JMSException {
>                ObjectMessage objectMessage =
> session.createObjectMessage(data);
> 
> objectMessage.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY,600000);
>                return objectMessage;
>            }
>        });
>    }
> }
> =======Receiver=====
> @Component
> public class MessageReceiver {
> 
>    @JmsListener(destination = MessageConfig.DESTINATION_FB)
> 
>    public void receiveMessage(ResultCode data) {
>        System.out.println("Received <" + data.getInfo() + ">");
>    }
> 
> }
> 
> 
> Thanks for your reading
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/scheduler-message-deliver-immediately-tp4718568.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message