Multiple schedule jobs using the same Listener DXP 7.0

Jamie Sammons, modified 4 Years ago. New Member Post: 1 Join Date: 7/16/21 Recent Posts

Hello everyone! I have a requirement on which users should be able to schedule jobs, as of now I have already managed to create a schedule job dynamically, but as soon as other one is created the previous stop working. I'm using the same listener since the job is exactly the same just some parameters change from execution to execution but in general its the same action. Here's a snippet of my code:

@Reference
EnvioNotificacionMessageListener envioNotificacion;

...

String listenerClass = EnvioNotificacionMessageListener.class.getName();

 

    Trigger jobTrigger = _triggerFactory.createTrigger(

        "Schedule Job Notificacion " + notificacion.getIdNotificacion(),

        listenerClass, new Date(), fechaFin, "0 * * ? * * *");

 

    SchedulerEntryImpl schedulerEntryImpl = new SchedulerEntryImpl();

        schedulerEntryImpl.setEventListenerClass(listenerClass);

        schedulerEntryImpl.setTrigger(jobTrigger);

       

        Message message = new Message();

        message.put("idNotificacion", notificacion.getIdNotificacion());

             

        SchedulerEngineHelperUtil.schedule(jobTrigger, StorageType. PERSISTED,

        "Trabajo", DestinationNames. SCHEDULER_DISPATCH, message, 10);

              

        SchedulerEngineHelperUtil.register(envioNotificacion,

        schedulerEntryImpl, DestinationNames. SCHEDULER_DISPATCH);

 

Hope you could help me to figure out what I need to change to finish this, thanks in advance!