In Quartz, both job and trigger need to define a group name. What is the use of this group?

  java, question
JobDetail job = newJob(HelloJob.class).withIdentity("job1", "group1").build();
 Trigger trigger = newTrigger().withIdentity("trigger1", "group1").startAt(runTime).build();

The above code

  1. What is the use of “group1” for JobDetail? Under what circumstances does it need to be used?

  2. What’s the use of “group1” for Trigger? Under what circumstances does it need to be used?

The comment for the Schedule interface in the org.quartz package states:

* <p>
 * <code>Job</code> s and <code>Trigger</code> s have a name and group
 * associated with them, which should uniquely identify them within a single
 * <code>{@link Scheduler}</code>. The 'group' feature may be useful for
 * creating logical groupings or categorizations of <code>Jobs</code> s and
 * <code>Triggers</code>s. If you don't have need for assigning a group to a
 * given <code>Jobs</code> of <code>Triggers</code>, then you can use the
 * <code>DEFAULT_GROUP</code> constant defined on this interface.
 * </p>

It can be seen that group is used for classification, which is equivalent to a namespace.

In addition, what’s the use of analyzing group from equals? For example, do you judge whether two trigger or jobs are the same? For example, trigger, in the SimpleTriggerImpl class

    public boolean equals(Object o) {
        if(!(o instanceof Trigger))
            return false;
        Trigger other = (Trigger)o;

        return !(other.getKey() == null || getKey() == null) && getKey().equals(other.getKey());


So, this equals method is the equals method in the superclass Key, and here we use group:

 public boolean equals(Object obj) {
 if (this == obj)
 return true;
 if (obj == null)
 return false;
 if (getClass() !  = obj.getClass())
 return false;
 Key<T> other = (Key<T>) obj;
 if (group == null) {
 if ( !  = null)
 return false;
 } else if (!  group.equals(
 return false;
 if (name == null) {
 if ( !  = null)
 return false;
 } else if (!  name.equals(
 return false;
 return true;

Therefore, group is actually a classification, meaning command space.