Posts

Showing posts with the label messageListener

Executing the BackGround Task

In Liferay we can exceute the background task asynchrously. The Background Task framework allows the developers to create and manage any kind of tasks that need to be run in a separated thread without the need of knowing anything about JAVA threading or concurrency Here the code ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Map taskContextMap = null; String taskName = null; String servletContextNames [] = new String[1] ; Portlet portlet = PortletLocalServiceUtil.getPortletById(request.getAttribute(WebKeys.PORTLET_ID).toString()); servletContextNames[0] = portlet.getContextName(); try { BackgroundTaskLocalServiceUtil.addBackgroundTask(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), taskName, servletContextNames,TestBackgroundTaskExecutor.class, taskContextMap,new ServiceContext()); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } ...

Creating scheduler in Liferay

  To create scheduler in liferay is easy just adding an entry in liferay-portal.xml and adding your custom logic in do receive method. 1.Add the following entry in liferay-portlet.xml after icon tag and before instansable tag.    " <scheduler-description> " tag you can give your custom description   " <scheduler-event-listener-class> " tag write your custom class where you write your custom scheduler  logic. " cron trigger class " tag , it identifies at what scheduler runs , here scheduler runs at 12 clock at sunday.             <scheduler-entry>            <scheduler-description>scheduler entry</scheduler-description>              <scheduler-event-listener-class>                 com.sample.scheduler.Sch...