Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Clarification in Liferay Documentation - Using Message Bus ton dev October 9, 2012 7:45 PM
RE: Clarification in Liferay Documentation - Using Message Bus Programming Horro October 9, 2012 10:22 PM
RE: Clarification in Liferay Documentation - Using Message Bus Programming Horro October 9, 2012 10:33 PM
RE: Clarification in Liferay Documentation - Using Message Bus Harish Kumar October 9, 2012 10:22 PM
RE: Clarification in Liferay Documentation - Using Message Bus ton dev October 9, 2012 10:55 PM
RE: Clarification in Liferay Documentation - Using Message Bus Harish Kumar October 9, 2012 10:56 PM
RE: Clarification in Liferay Documentation - Using Message Bus ton dev October 9, 2012 11:41 PM
RE: Clarification in Liferay Documentation - Using Message Bus Harish Kumar October 9, 2012 11:47 PM
RE: Clarification in Liferay Documentation - Using Message Bus Programming Horro October 9, 2012 11:51 PM
RE: Clarification in Liferay Documentation - Using Message Bus ton dev October 10, 2012 1:43 AM
RE: Clarification in Liferay Documentation - Using Message Bus Harish Kumar October 10, 2012 3:05 AM
RE: Clarification in Liferay Documentation - Using Message Bus ton dev October 16, 2012 9:02 AM
RE: Clarification in Liferay Documentation - Using Message Bus Siby Mathew February 11, 2013 4:52 AM
RE: Clarification in Liferay Documentation - Using Message Bus Smilelws2010 lwz September 17, 2013 1:36 PM
RE: Clarification in Liferay Documentation - Using Message Bus Harish Kumar September 17, 2013 11:26 PM
ton dev
Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 7:45 PM
Answer

ton dev

Rank: New Member

Posts: 18

Join Date: February 8, 2012

Recent Posts

Written in Liferay Documentation 6.1 on using Message Bus,
Configuration of Message Bus is done using the following files:

WEB-INF/src/META-INF/messaging-spring.xml - Specifies your destinations, listeners, and their mappings to each other

WEB-INF/web.xml - Holds a listing of deployment descriptors for your plugin. Be sure to add messaging-spring.xml to your list of Spring configurations in this file.



How does messaging-spring.xml listed in web.xml?

I tried this

 1<?xml version="1.0" encoding="UTF-8"?>
 2<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 3  <display-name>MessageBus-portlet</display-name>
 4  <welcome-file-list>
 5    <welcome-file>index.html</welcome-file>
 6    <welcome-file>index.htm</welcome-file>
 7    <welcome-file>index.jsp</welcome-file>
 8    <welcome-file>default.html</welcome-file>
 9    <welcome-file>default.htm</welcome-file>
10    <welcome-file>default.jsp</welcome-file>
11  </welcome-file-list>
12  <jsp-config>
13      <taglib>
14          <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
15          <taglib-location>
16              /WEB-INF/tld/liferay-portlet.tld
17          </taglib-location>
18      </taglib>
19  </jsp-config>
20      
21      
22    <listener>
23    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
24  </listener>
25      
26      
27  <context-param>         
28      <param-name>contextConfigLocation</param-name>         
29      <param-value>/WEB-INF/classes/META-INF/messaging-spring.xml</param-value>    
30  </context-param>
31</web-app>


but tomcat logged

org.apache.catalina.core.standardcontext start severe error listenerstart


And when i removed
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>


tomcat logged

Container org.apache.catalina.core.ContainerBase... has not been started


I just want to try the Message Bus, and i cant invoke the listener when a send a messaeg using

1 Message message = new Message();
2        message.put("slogan", "Procurement");
3        MessageBusUtil.sendMessage("inkwell/slogan", message);


I'm developing in Liferay 6.0.5 Thanks for the help
Programming Horro
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 10:22 PM
Answer

Programming Horro

Rank: New Member

Posts: 3

Join Date: October 9, 2012

Recent Posts

Please read the documentation. It can be found here.
http://www.liferay.com/community/wiki/-/wiki/Main/Message+Bus
Harish Kumar
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 10:22 PM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

Hi Ton

I have tried this and its working fine for me.

Following is only entry that I made to web.xml file

1
2<context-param>
3    <param-name>portalContextConfigLocation</param-name>
4    <param-value>/WEB-INF/classes/META-INF/messaging-spring.xml</param-value>
5</context-param>


Here is the messaging-spring.xml part -

 1
 2<?xml version="1.0" encoding="UTF-8"?>
 3<beans default-destroy-method="destroy" default-init-method="afterPropertiesSet" xmlns="http://www.springframework.org/schema/beans"
 4xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 5xsi:schemaLocation="http://www.springframework.org/schema/beans
 6http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
 7
 8    <bean id="messageListener.slogan_listener" class="com.harish.portlet.EmployeeListener" />
 9
10    <bean id="destination.slogan" class="com.liferay.portal.kernel.messaging.ParallelDestination">
11        <property name="name" value="inkwell/slogan" />
12    </bean>
13
14    <bean id="messagingConfigurator" class="com.liferay.portal.kernel.messaging.config.PluginMessagingConfigurator">
15        <property name="messageListeners">
16            <map key-type="java.lang.String" value-type="java.util.List">
17                <entry key="inkwell/slogan">
18                    <list value-type="com.liferay.portal.kernel.messaging.MessageListener">
19                        <ref bean="messageListener.slogan_listener" />
20                    </list>
21                </entry>
22            </map>
23        </property>
24        <property name="destinations">
25            <list>
26                <ref bean="destination.slogan"/>
27            </list>
28        </property>
29    </bean>
30</beans>


HTH
Programming Horro
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 10:33 PM
Answer

Programming Horro

Rank: New Member

Posts: 3

Join Date: October 9, 2012

Recent Posts

ton dev:
Programming Horro:
Please read the documentation. It can be found here.
http://www.liferay.com/community/wiki/-/wiki/Main/Message+Bus


Obviously, I have read the Documentation... please read my post



Obviously, I have read your post... please read the documentation
ton dev
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 10:55 PM
Answer

ton dev

Rank: New Member

Posts: 18

Join Date: February 8, 2012

Recent Posts

Harish Kumar:
Hi Ton

I have tried this and its working fine for me.

Following is only entry that I made to web.xml file

1
2<context-param>
3    <param-name>portalContextConfigLocation</param-name>
4    <param-value>/WEB-INF/classes/META-INF/messaging-spring.xml</param-value>
5</context-param>


Here is the messaging-spring.xml part -

 1
 2<?xml version="1.0" encoding="UTF-8"?>
 3<beans default-destroy-method="destroy" default-init-method="afterPropertiesSet" xmlns="http://www.springframework.org/schema/beans"
 4xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 5xsi:schemaLocation="http://www.springframework.org/schema/beans
 6http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
 7
 8    <bean id="messageListener.slogan_listener" class="com.harish.portlet.EmployeeListener" />
 9
10    <bean id="destination.slogan" class="com.liferay.portal.kernel.messaging.ParallelDestination">
11        <property name="name" value="inkwell/slogan" />
12    </bean>
13
14    <bean id="messagingConfigurator" class="com.liferay.portal.kernel.messaging.config.PluginMessagingConfigurator">
15        <property name="messageListeners">
16            <map key-type="java.lang.String" value-type="java.util.List">
17                <entry key="inkwell/slogan">
18                    <list value-type="com.liferay.portal.kernel.messaging.MessageListener">
19                        <ref bean="messageListener.slogan_listener" />
20                    </list>
21                </entry>
22            </map>
23        </property>
24        <property name="destinations">
25            <list>
26                <ref bean="destination.slogan"/>
27            </list>
28        </property>
29    </bean>
30</beans>


HTH


Is Hook used or portlet?? or ext??
Harish Kumar
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 10:56 PM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

In custom portlet
ton dev
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 11:41 PM
Answer

ton dev

Rank: New Member

Posts: 18

Join Date: February 8, 2012

Recent Posts

Sir Harish thanks for the help... the configurator was deployed and loaded

but i have a follow up question..

Does sending as message to a destination is as simple as this??


1MessageBusUtil.registerMessageListener("inkwell/slogan", new ConsoleListener());
2            System.out.println(MessageBusUtil.hasMessageListener("inkwell/slogan"));
3            Message message = new Message();
4            message.put("slogan", "Procurement");
5             MessageBusUtil.sendMessage(
6                    "inkwell/slogan", message);


Should this cade be placed in processAction or in JSP or in doView??
Harish Kumar
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 11:47 PM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

Yes, following lines of code in processAction method did the work

1
2Message msg = new Message();
3msg.put("slogan", "Hi, this is liferay message bus example");
4MessageBusUtil.sendMessage("inkwell/slogan", msg);
Programming Horro
RE: Clarification in Liferay Documentation - Using Message Bus
October 9, 2012 11:51 PM
Answer

Programming Horro

Rank: New Member

Posts: 3

Join Date: October 9, 2012

Recent Posts

Harish Kumar:
Yes, following lines of code in processAction method did the work

1
2Message msg = new Message();
3msg.put("slogan", "Hi, this is liferay message bus example");
4MessageBusUtil.sendMessage("inkwell/slogan", msg);



Mr Harsh Kumar, your code didn't work on my machine? But why?
ton dev
RE: Clarification in Liferay Documentation - Using Message Bus
October 10, 2012 1:43 AM
Answer

ton dev

Rank: New Member

Posts: 18

Join Date: February 8, 2012

Recent Posts

Sir Harish can you give me a source code of the portlet that you made that Message Bus is incorporated..

Thanks
Harish Kumar
RE: Clarification in Liferay Documentation - Using Message Bus
October 10, 2012 3:05 AM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

Sir ton, I have already posted the entire code, only thing pending is listener class.

 1
 2public class EmployeeListener implements MessageListener  {
 3
 4    @Override
 5    public void receive(Message msg) throws MessageListenerException {
 6       
 7        String slogan = msg.getString("slogan");
 8        System.out.println("Slogan Entered: " + slogan);
 9       
10    }
11}


HTH
ton dev
RE: Clarification in Liferay Documentation - Using Message Bus
October 16, 2012 9:02 AM
Answer

ton dev

Rank: New Member

Posts: 18

Join Date: February 8, 2012

Recent Posts

never forget to put service.xml, which i didnt include in WEB-INF, not until now...
I was able to output the message LOL

When I started trying the Message Bus, i jump right into chapter 10.5 of Liferay in Action MEAP..,

all the steps are written there except

adding

1<context-param>
2    <param-name>portalContextConfigLocation</param-name>
3    <param-value>/WEB-INF/classes/META-INF/messaging-spring.xml</param-value>
4</context-param> 


to web.xml

and adding a blank service.xml

1<?xml version="1.0" encoding="UTF-8"?>
2
3<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">


in WEB-INF.. along with portlet.xml etc
hope this helps
Siby Mathew
RE: Clarification in Liferay Documentation - Using Message Bus
February 11, 2013 4:52 AM
Answer

Siby Mathew

Rank: Expert

Posts: 267

Join Date: March 4, 2011

Recent Posts

Wow...thanks a lot ton !
The missing service.xml was my problem too... !

Note: The <context-param> step is present in 'Liferay In Action' (Page:281)

Thanks,
Siby
Smilelws2010 lwz
RE: Clarification in Liferay Documentation - Using Message Bus
September 17, 2013 1:36 PM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 160

Join Date: December 16, 2010

Recent Posts

HI Harish,

How do you do asynchronous mailing (invoke and forget type) using MessageBusUtil ?

Does selecting ParallelDestination makes it asynchronous or is it some other class?
<bean id="destination.slogan" class="com.liferay.portal.kernel.messaging.ParallelDestination">

And what should be the must have beans in the xml fine destination, messageListener and configurator?

Much appreciate your time and attention

Thanks
Smile
Harish Kumar
RE: Clarification in Liferay Documentation - Using Message Bus
September 17, 2013 11:26 PM
Answer

Harish Kumar

Rank: Expert

Posts: 473

Join Date: July 31, 2010

Recent Posts

Yes, in case of asynchronous (invoke and forget type) we have to use com.liferay.portal.kernel.messaging.ParallelDestination.

Message Bus API is now documented, so you can find details here