使用相同的名称和组创建多个相同的作业 - Quartz

时间:2015-12-07 16:43:40

标签: java scheduler jobs

您好我在Liferay上创建了创建作业的portlet,当我启动此portlet时,创建具有相同名称和组的作业。创建具有相同名称和组的新作业时,创建不应该失败吗? 我现在的问题是我有多个工作做同样的事情。

我用这种方法创建作业:

   public void pruebaTrigger() throws Exception{


    JobDetail job = JobBuilder.newJob(SimpleJob.class)
    .withIdentity("dummyJobName", "group1").build();


    Trigger trigger = TriggerBuilder
    .newTrigger()
    .withIdentity("dummyTriggerName", "group1")
    .withSchedule(
        CronScheduleBuilder.cronSchedule("0 0/1 * 1/1 * ? *"))
    .build();

    //schedule it
    Scheduler scheduler = new StdSchedulerFactory().getScheduler();
    scheduler.start();
    scheduler.scheduleJob(job, trigger);

}

另一个问题是:如何阻止实际工作的工作?

感谢您的信息, 问候。

1 个答案:

答案 0 :(得分:0)

library(shiny)
library(shinydashboard)
library(dplyr)

ui <- dashboardPage(dashboardHeader(dropdownMenuOutput("notificationMenu")), 
                    dashboardSidebar(sidebarMenu(menuItem("Page 1", tabName = "page1"),
                                                 menuItem("Page 2", tabName = "page2"))),
                    dashboardBody(tabItems(
                      tabItem(tabName = "page1", h4("This is Page 1")),
                      tabItem(tabName = "page2", 
                              textInput("text", "Enter News:", "New News."),
                              actionButton("save", "Save")))))

server <- function(input, output, session){
  raw_news <- reactiveValues()

  # Intial Header News: 1 Message from Admin
  raw_news$news <- data_frame(from = "Admin", text = "this is a message")

  # The notifications in header
  output$notificationMenu <- renderMenu({
    raw_news <- raw_news$news

    dropdownMenu(
      messageItem(raw_news$from[1], raw_news$text[1])
    )
  })

  # save a new notification
  observeEvent(input$save, {
    raw_news$news <- data.frame(from = "User", text = input$text)
  }) 
}

shinyApp(ui = ui, server = server)