Tuesday, September 28, 2010

Liferay 6- Scheduler Engine design change


In Liferay 5.2.x, we had com.liferay.portal.kernel.job.IntervalJob as a Quartz scheduler job, which needs to be implemented for different jobs we need for Quartz trigger execution.

In Liferay 6, the design pf scheduler engine has been changed and introduced combination with JMS. I have prepared the small class cum collaboration diagram, which can help understanding how we need to make triggers now onwards.


Basically, they made use of messaging with Quartz. The Job class for liferay is now fixed which is com.liferay.portal.scheduler.job.MessageSenderJob .


Now we have a com.liferay.portal.kernel.messaging.MessageListener which is to be implemented for different job handling.

The schedulerEnginUtil class will register the listener with perticular queue destination and schedules new trigger as per the SchedulerEntry details with MessageSenderJob. When trigger fired, this Job class will eventually sends message to queue, which will eventually go to the listener.

This time, not as like previous scheduler, they have given exposure to Message which can contain some payload data if needed for job execution. This is very helpful sometimes.

By default the method schedule(SchedulerEntry schedulerEntry, ClassLoader classLoader)from SchedulerEngineUtil sends null Message. So, we might need to copy and pass some payload object if needed.

Tuesday, September 7, 2010

Liferay Struts Portlet: Usage of SessionErrors class...

This is very common issues we come across when we want to change portal code with extension environment. Mostly we do is, copying the code from portal to ext and making new struts portlet.

And for sending errors to pages, we use SessionErrors.add(...) method, which will eventually forward to default error.jsp file. So you will never find what is happening. Simple thing, to make this working fine, is...

- Make new empty page named error.jsp in your portlet.
- Make new Struts-config and tiles-def entry of your new JSP in ext.
- From your render method, forward to the new file when you have SessionErrors filled with errors like,

 if (!SessionErrors.isEmpty(req)) {
  return mapping.findForward("portlet.portlet_name.error");
 }
 

See this link to understand the detailed problem...