Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (c) 2010-2011. Axon Framework
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.axonframework.eventhandling.scheduling.quartz;
Quartz Job that publishes an event on an Event Bus. The event is retrieved from the JobExecutionContext. The Event Bus is fetched from the scheduler context.

Allard Buijze
public class FireEventJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(FireEventJob.class);

The key used to locate the event in the JobExecutionContext.
    public static final String EVENT_KEY = Event.class.getName();

The key used to locate the Event Bus in the scheduler context.
    public static final String EVENT_BUS_KEY = EventBus.class.getName();
The key used to locate the optional EventTriggerCallback in the scheduler context.
    public static final String TRIGGER_CALLBACK_KEY = EventTriggerCallback.class.getName();
    public void execute(JobExecutionContext contextthrows JobExecutionException {
        .debug("Starting job to publish a scheduled event");
        ApplicationEvent event = (ApplicationEventcontext.getJobDetail().getJobDataMap().get();
        try {
            EventBus eventBus = (EventBuscontext.getScheduler().getContext().get();
            EventTriggerCallback eventTriggerCallback = (EventTriggerCallbackcontext.getScheduler().getContext().get(
            if (eventTriggerCallback != null) {
            try {
            } catch (RuntimeException e) {
                if (eventTriggerCallback != null) {
                throw e;
            if (eventTriggerCallback != null) {
            .info("Job successfully executed. Scheduled Event has been published.");
        } catch (Exception e) {
            .warn("Exception occurred while executing a scheduled job");
            throw new JobExecutionException(e);
New to GrepCode? Check out our FAQ X