Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Christian Perez
Using method without ActionRequest and ActionResponse
June 5, 2014 4:24 PM

Christian Perez

Rank: Junior Member

Posts: 47

Join Date: July 19, 2013

Recent Posts

I have a method that receive two parameters an object of the type ActionRequest and ActionResponse
2public void doSomething(ActionRequest, ActionResponse)
and works fine, but I want to excute this method in a schedule
something like this
 2public class Calendarizado implements MessageListener{
 4    private static final Log LOGGER = LogFactoryUtil.getLog(Calendarizado.class);
 6        public void receive(Message arg0) throws MessageListenerException {
 7call doSomething(param, param);

but at this point I donde have any request or any response, can I make my own response and request in the class Calendarizado?

or can I convert some data in request Object?
Andrew Jardine
RE: Using method without ActionRequest and ActionResponse
June 5, 2014 5:15 PM

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1222

Join Date: December 22, 2010

Recent Posts


I think the MessageListener is the handler for the event -- or more accurately the message placed onto the bus. I think what you are probably looking to do is retrieve the "message data" from the actionRequest in your processAction method, construct a Message object and place it on the bus for it to get to the Listener. If the message contains everything the Listener needs to process, then you shouldn't need the actionRequest in the Listener class. So, something like --

 2public void processAction(ActionRequest actionRequest, ActionResponse actionResponse )
 4    // build your message to be sent to the listener
 5    Message message = new Message();
 6    message.put("key", ParamUtil.getString(actionRequest, "variable-name");
 8   // place it on the bus
 9   MessageBusUtil.sendSynchronousMessage( <destination>, message);
Pankaj Kathiriya
RE: Using method without ActionRequest and ActionResponse
June 5, 2014 5:40 PM

Pankaj Kathiriya

Rank: Liferay Master

Posts: 718

Join Date: August 4, 2010

Recent Posts

Scheduler jobs are something thats runs offline(without any browser request which leads request-response life cycle) as per interval defined without any request-response cycle. You cant define or make use of actionRequest or actionResponse in scheduler method.