RE: How to configure and use Asynchronous Bus in Liferay 7 plugin ?

pulkit tiwari, modified 8 Years ago. New Member Posts: 14 Join Date: 6/6/17 Recent Posts
Hi guys,
I am converting a liferay 6.2 plugin project to liferay 7 plugin project. In this project we have used Asynchronous Bus , which is configured in messaging-sping.xml . Now in my liferay 7 plugin project, whenever i am trying push Message into MessageBusUtil, it is throwing a NullPointer Exception.
StackTrace:-
java.lang.NullPointerException
at com.liferay.portal.kernel.messaging.BaseAsynchronousDestination.send(BaseDestination.java:173)
at com.liferay.portal.messaging.internal,DefaultMessageBus.sendMessage(DefaultMessageBus.java:232)
at com.liferay.portal.kernel.messaging.MessageBusUtil.sendMessage(MessageBusUtil.java:92)
at DemoLR7.DemoLR7PortletViewController.question(DemoLR7PortletViewController.java:66)

Code:-
Message message=new Message();
message.put("test","Checking Async Message Service");
MessageBusUtil.sendMessage("liferay/asyncbus/destination",message);

messaging-spring.xml:-
(Main Part)

<bean id="liferay.async.bus" class="com.healthplan.pe.events.handlers.AsyncMessageListenerImpl"/>

<bean id="liferay.async.bus.destination" class="com.liferay.portal.kernel.messaging.SerialDestination" >
<property name="name" value="liferay/asyncbus/destination" />
</bean>

<bean id="messagingConfigurator" class="com.liferay.portal.kernel.messaging.config.PluginMessagingConfigurator" >
<property name="messagingListeners">
<map key-type="java.lang.String" value-type="java.util.List">
<entry key="liferay/asyncbus/destination">
<list value-type="com.liferay.portal.kernel.messaging.MessageListener">
<ref bean="liferay.async.bus" />
</list>
</entry>
</map>
</property>
<property name="destinations">
<list>
<ref bean="liferay.async.bus.destination" />
</list>
</property>
</bean>

AsyncMessagingListenerImpl.java code:-
public class AsyncMessagingListenerImpl implements MessageListener{
@Override
public void receive(Message message) throws MessageListenerException{
System.out.println("Received Message::-"+message.getString("test") );
}
}

Web.xml:-
<context-param>
<param-name>portalContextConfigLocation</param-name>
<param-value>/WEB-INF/spring-context/messaging-spring.xml</param-value>
</context-param>

I need your help on this. Any kind of advice,solution,another approach will be a lot of help to me.
thumbnail
Manish Kumar Jaiswal, modified 7 Years ago. Regular Member Posts: 153 Join Date: 11/25/08 Recent Posts
Hi Pulkit Did you find a solution for this issue , can you please share some code snippet about how to achieve this is Liferay DXP .

Thanks
Manish
ronak vora, modified 5 Years ago. Junior Member Posts: 25 Join Date: 9/26/18 Recent Posts
Same here i'm creating message bus for Liferay 7.1.2 CE, if anyone can help....?
 Thanks in advance
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts