Sfoglia il codice sorgente

minify footprint of scheduler

feature/kafka-integrator
Gabriele Zigurella 2 anni fa
parent
commit
19c27497cc
  1. 11
      liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/liferay-portlet.xml
  2. 4
      liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java
  3. 54
      liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeStartup.java
  4. 92
      liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusScheduler.java

11
liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/liferay-portlet.xml

@ -7,13 +7,12 @@
<portlet-name>schedulatore-portos-pratiche</portlet-name> <portlet-name>schedulatore-portos-pratiche</portlet-name>
<icon>/icon.png</icon> <icon>/icon.png</icon>
<scheduler-entry> <scheduler-entry>
<scheduler-description>dati pratiche</scheduler-description> <scheduler-description>quarkus bridge pratiche</scheduler-description>
<scheduler-event-listener-class>integratore.IntegratoreSchedulato</scheduler-event-listener-class> <scheduler-event-listener-class>portos.nextmind.quarkus.bridge.scheduler.QuarkusBridgeListener</scheduler-event-listener-class>
<trigger> <trigger>
<simple> <cron>
<simple-trigger-value>30</simple-trigger-value> <cron-trigger-value>0 */5 * ? * *</cron-trigger-value>
<time-unit>second</time-unit> </cron>
</simple>
</trigger> </trigger>
</scheduler-entry> </scheduler-entry>
<header-portlet-css>/css/main.css</header-portlet-css> <header-portlet-css>/css/main.css</header-portlet-css>

4
liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeListener.java → liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeScheduler.java

@ -6,9 +6,9 @@ import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener; import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException; import com.liferay.portal.kernel.messaging.MessageListenerException;
public class QuarkusBridgeListener implements MessageListener { public class QuarkusBridgeScheduler implements MessageListener {
Log _log = LogFactoryUtil.getLog(QuarkusBridgeListener.class); Log _log = LogFactoryUtil.getLog(QuarkusBridgeScheduler.class);
@Override @Override
public void receive(Message message) throws MessageListenerException { public void receive(Message message) throws MessageListenerException {

54
liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusBridgeStartup.java

@ -1,54 +0,0 @@
package portos.nextmind.quarkus.bridge.scheduler;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.scheduler.SchedulerEngineHelperUtil;
import com.liferay.portal.kernel.scheduler.SchedulerException;
import com.liferay.portal.kernel.scheduler.StorageType;
import com.liferay.portal.kernel.scheduler.Trigger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import portos.nextmind.quarkus.bridge.api.QuarkusBridgeMessageFactoryUtil;
public class QuarkusBridgeStartup implements ServletContextListener {
Log _log = LogFactoryUtil.getLog(QuarkusBridgeStartup.class);
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
_log.info("### Registering Quarkus Bridge");
QuarkusScheduler.registerScheduler();
Trigger trigger = QuarkusScheduler.registerTrigger();
String destinationName = QuarkusScheduler.getSchedulerendpoint();
Message[] messageTypes = QuarkusBridgeMessageFactoryUtil.registerMessages();
for(Message message : messageTypes){
try {
SchedulerEngineHelperUtil.addJob(trigger, StorageType.MEMORY_CLUSTERED,
"Quarkus Bridge Scheduler", destinationName, message,
QuarkusBridgeListener.class.getName(),
null, Integer.MAX_VALUE);
} catch (SchedulerException e) {
_log.error(e ,e);
return;
}
}
_log.info("### Setup finished for Quarkus Bridge");
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
_log.info("### Uninstalling Quarkus Bridge");
try {
QuarkusScheduler.deregisterScheduler();
SchedulerEngineHelperUtil.delete(QuarkusScheduler.getTriggerJobName(),
QuarkusScheduler.getTriggerGroupName(), StorageType.MEMORY_CLUSTERED);
} catch (SchedulerException e) {
_log.error(e, e);
return;
}
_log.info("### Quarkus Bridge successfully removed");
}
}

92
liferay-plugins-sdk-6.2/portlets/schedulatore-portos-pratiche-portlet/docroot/WEB-INF/src/portos/nextmind/quarkus/bridge/scheduler/QuarkusScheduler.java

@ -1,92 +0,0 @@
package portos.nextmind.quarkus.bridge.scheduler;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.messaging.MessageBusUtil;
import com.liferay.portal.kernel.messaging.ParallelDestination;
import com.liferay.portal.kernel.scheduler.CronTrigger;
import com.liferay.portal.kernel.scheduler.SchedulerException;
import com.liferay.portal.kernel.scheduler.Trigger;
import com.liferay.portal.kernel.scheduler.TriggerFactoryUtil;
import com.liferay.portal.kernel.scheduler.TriggerType;
public class QuarkusScheduler {
static Log _log = LogFactoryUtil.getLog(QuarkusScheduler.class);
private final static String SchedulerEndpoint = "portos_nextmind_quarkus_bridge_scheduler_REGISTRY";
private final static String TriggerJobName = "portos_nextmind_quarkus_bridge_scheduler_T_JOB";
private final static String TriggerGroupName = "portos_nextmind_quarkus_bridge_scheduler_T_GROUP";
private static CronTrigger QuarkusSchedulerTrigger;
public static CronTrigger getQuarkusSchedulerTrigger() {
if(QuarkusSchedulerTrigger == null){
_log.warn("### Trying to access Quarkus Bridge Scheduler Trigger before it's registered!!");
return null;
}
return QuarkusSchedulerTrigger;
}
public static String getSchedulerendpoint() {
return SchedulerEndpoint;
}
public static Boolean registerScheduler(){
try{
ParallelDestination destination = new ParallelDestination();
destination.setName(SchedulerEndpoint);
if ( !MessageBusUtil.hasMessageListener(SchedulerEndpoint)){
MessageBusUtil.addDestination(destination);
}
_log.debug("### Registering Quarkus Bridge Listener");
MessageBusUtil.registerMessageListener(SchedulerEndpoint, new QuarkusBridgeListener());
_log.debug("### Correctly Registered Quarkus Bridge Listener");
} catch (RuntimeException r){
_log.error(r ,r);
return false;
}
return true;
}
public static Boolean deregisterScheduler(){
try{
if (MessageBusUtil.hasMessageListener(SchedulerEndpoint)){
MessageBusUtil.removeDestination(SchedulerEndpoint);
}
_log.debug("### Removing Quarkus Bridge Listener");
MessageBusUtil.unregisterMessageListener(SchedulerEndpoint, new QuarkusBridgeListener());
_log.debug("### Correctly Removed Quarkus Bridge Listener");
} catch (RuntimeException r){
_log.error(r ,r);
return false;
}
return true;
}
public static Trigger registerTrigger() {
final String cronExpression = "0 */5 * ? * *";
try{
_log.debug("### Creating Quarkus Bridge Scheduler Trigger");
Trigger trigger = TriggerFactoryUtil.buildTrigger(
TriggerType.CRON,
TriggerJobName, TriggerGroupName,
null, null, cronExpression);
if(QuarkusSchedulerTrigger == null){
QuarkusSchedulerTrigger = (CronTrigger) trigger;
}
_log.debug("### Correctly Created Quarkus Bridge Scheduler Trigger");
}catch(RuntimeException r){
_log.error(r, r);
}catch(SchedulerException s){
_log.error(s, s);
}
return QuarkusSchedulerTrigger;
}
public static String getTriggerJobName() {
return TriggerJobName;
}
public static String getTriggerGroupName() {
return TriggerGroupName;
}
}
Caricamento…
Annulla
Salva