Forums de discussion

Using method without ActionRequest and ActionResponse

practicante practicante, modifié il y a 9 années.

Using method without ActionRequest and ActionResponse

Junior Member Publications: 47 Date d'inscription: 19/07/13 Publications récentes
Hi
I have a method that receive two parameters an object of the type ActionRequest and ActionResponse

public void doSomething(ActionRequest, ActionResponse)
{
//logic
}
and works fine, but I want to excute this method in a schedule
something like this

public class Calendarizado implements MessageListener{
	 
	private static final Log LOGGER = LogFactoryUtil.getLog(Calendarizado.class);
		
		public void receive(Message arg0) throws MessageListenerException {
call 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?
thumbnail
Andew Jardine, modifié il y a 9 années.

RE: Using method without ActionRequest and ActionResponse

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
practicante,

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 --


public void processAction(ActionRequest actionRequest, ActionResponse actionResponse )
{
    // build your message to be sent to the listener
    Message message = new Message();
    message.put("key", ParamUtil.getString(actionRequest, "variable-name");

   // place it on the bus
   MessageBusUtil.sendSynchronousMessage( <destination>, message);
}
</destination>
thumbnail
Pankaj Kathiriya, modifié il y a 9 années.

RE: Using method without ActionRequest and ActionResponse

Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
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.