<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: @schedule in spring-boot does not work in Java instance in sap cloud platform in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/schedule-in-spring-boot-does-not-work-in-java-instance-in-sap-cloud/qaa-p/486049#M85989</link>
    <description>&lt;P&gt;I found the solution. It seems that in log information defined in code is not contained in HCP's log file. But the schedule function works fine.&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 07:05:45 GMT</pubDate>
    <dc:creator>ziyi_jiang</dc:creator>
    <dc:date>2017-05-12T07:05:45Z</dc:date>
    <item>
      <title>@schedule in spring-boot does not work in Java instance in sap cloud platform</title>
      <link>https://community.sap.com/t5/technology-q-a/schedule-in-spring-boot-does-not-work-in-java-instance-in-sap-cloud/qaq-p/486048</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I found that In SAP Cloud Platform, using spring-boot version 1.3.5 if I want to have a scheduled task using @schedule annotation, it doesn't work in HCP. &lt;/P&gt;&lt;P&gt;However, the same code works in localhost using my own computer.&lt;/P&gt;&lt;P&gt;I'm wondering whether there is anything wrong with my code or configuration file in the project or HCP simply doesn't support schedule in Spring-boot?&lt;/P&gt;&lt;P&gt;Here are the code snippets:&lt;/P&gt;&lt;P&gt;Main function:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;package com.sap.job;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class Application {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class);
    }
}


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Scheduled Job&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;package com.sap.job;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTasks {
	private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	@Scheduled(fixedRate = 10000)
	public void updateDateAvailable() throws ParseException {
		log.info("The time is now {}", dateFormat.format(new Date()));
		long time = System.currentTimeMillis();
		Date date = new Date();
		long minus = 86400000L;
		long endTime = new Date().getTime();
		long startTime = endTime-minus;
		log.info("endTime："+endTime);
		log.info("startTime:"+startTime);
		log.info("date:"+date.toString());
	}	
}

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The result is that I cannot find any log in HCP.&lt;/P&gt;&lt;P&gt;Also trying to insert a record to DB in a schedule doesn't work while it works in localhost.&lt;/P&gt;&lt;P&gt;Has anyone met the issue before? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 05:14:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/schedule-in-spring-boot-does-not-work-in-java-instance-in-sap-cloud/qaq-p/486048</guid>
      <dc:creator>ziyi_jiang</dc:creator>
      <dc:date>2017-05-12T05:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: @schedule in spring-boot does not work in Java instance in sap cloud platform</title>
      <link>https://community.sap.com/t5/technology-q-a/schedule-in-spring-boot-does-not-work-in-java-instance-in-sap-cloud/qaa-p/486049#M85989</link>
      <description>&lt;P&gt;I found the solution. It seems that in log information defined in code is not contained in HCP's log file. But the schedule function works fine.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 07:05:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/schedule-in-spring-boot-does-not-work-in-java-instance-in-sap-cloud/qaa-p/486049#M85989</guid>
      <dc:creator>ziyi_jiang</dc:creator>
      <dc:date>2017-05-12T07:05:45Z</dc:date>
    </item>
  </channel>
</rss>

