Forums de discussion

Echange de messages entre portlets par le Message Bus

thumbnail
Alix Boc, modifié il y a 9 années.

Echange de messages entre portlets par le Message Bus

New Member Publications: 11 Date d'inscription: 13/10/14 Publications récentes
Bonjour,

J'essaie de comprendre la configuration pour permettre l'échange de messages entre 2 portlets (d'un même portails) par le "message bus" .
Malgré mes lectures, je bloque sur certains concepts.

Je suis donc à la recherche d'un exemple simple mais complet qui permet l'échange entre 2 portlets différents.

ou d'un tutoriel qui explique pas à pas comment mettre en place cet échange.

Mes interrogations tournent surtout autour du fichier message-springs.xml.

voici mes sources déjà consultées :
->Liferay in action (chapitre 10.5)
->http://www.liferay.com/fr/documentation/liferay-portal/6.1/development/-/ai/lp-6-1-dgen09-using-message-bus-0
->https://www.liferay.com/fr/community/wiki/-/wiki/Main/Message+Bus

J'utilise liferay-portal-6.2-ce-ga2

Je vous remercie d'avance
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

Liferay Legend Publications: 14914 Date d'inscription: 02/09/06 Publications récentes
Alix I hope an english reply is okay...

When considering portlet to portlet communication via the message bus, you really are talking about instance to instance communication for the current user. Think of it like trying to send a message to the web content display portlet. It's not so much how do you send a message there, but it's more about whether the message is for every instance being seen by every user, or is it really something that is only for the current user. The Liferay message bus makes no such distinction, so if that's what you're looking for you'll need to include that kind of thing into your design.

As far as an example, the docs page at https://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/using-message-bus-liferay-portal-6-2-dev-guide-06-en shows how to use it, you're just going to set up your sender in one portlet and listener in another portlet, splitting your definitions of the senders bean xml in one plugin and the listeners bean xml in another.
thumbnail
Alix Boc, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

New Member Publications: 11 Date d'inscription: 13/10/14 Publications récentes
Thanks David,

I really want to send messages from a portlet to another one.
As i'm new with all these technos (Liferay, servlet, jsp, ...), i have some troubles sometimes.

I will split the definition between the two plugins and give you feedback.
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

Liferay Legend Publications: 14914 Date d'inscription: 02/09/06 Publications récentes
K, I'll still be here.

Note that the Liferay Message Bus (LMemoticon has some cases where it really is a good tool (i.e. sending email by pushing it on the LMB and a listener which actually talks to the SMTP server), but there are other cases where it is hard to make it fit.

For example, I built a system for mobile users to chat with an agent. Mobile messages would arrive on a separate server and route via JMS to the Liferay server where I had an MDB receive the message and my plan was to push them to the agent chat portlets using the LMB. Since each agent gets their own chat stream, I ended up dynamically creating destinations, one per logged in agent. The MDB would know which agent to forward the message to and would send it to the agent's LMB destination.

The point is that since there were multiple instances of this chat portlet (one per agent), I couldn't just send messages to some "agent.chat" destination because there is no way to selectively pull messages from the LMB that only apply to a particular chat portlet instance. It truly is a lightweight message bus, so you have to have a good handle on how you're going to handle these kinds of issues before you start, lest you find yourself in a deep hole and no clear way how to dig yourself out of it...
thumbnail
Alix Boc, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

New Member Publications: 11 Date d'inscription: 13/10/14 Publications récentes
Hi David,

I created a portlet to log activities of another portlet using the LMB (just for testing).

It works well, thanks for your help !
Darryl Kpizingui, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

Junior Member Publications: 82 Date d'inscription: 10/01/13 Publications récentes
David H Nebinger:

The point is that since there were multiple instances of this chat portlet (one per agent), I couldn't just send messages to some "agent.chat" destination because there is no way to selectively pull messages from the LMB that only apply to a particular chat portlet instance. It truly is a lightweight message bus, so you have to have a good handle on how you're going to handle these kinds of issues before you start, lest you find yourself in a deep hole and no clear way how to dig yourself out of it...


Hi David!

I am a bit curious about the issue you reported in your previous message regarding the LMB. Thought there are multiple versions of the portlet, you still can know to which portlet the message should be sent. The pattern solving those kind of problems is bing used for UDP or socket communications where we cannot create a socket per client for instance, or for posting a reply to a forum post when a user reply to from his/her email client.

For your chat agents, I guess you have a sort of singleton MAP or a way to get the correct channel. A kind of a container object that has a reference of all the available channel. In the message you receive from the LMB, you can have a kind of a key that can tells you where the message should go.

Isn't that a classic problem for asynchronous message system?
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: Echange de messages entre portlets par le Message Bus

Liferay Legend Publications: 14914 Date d'inscription: 02/09/06 Publications récentes
Darryl Kpizingui:
Isn't that a classic problem for asynchronous message system?


Certainly, and it's not that I couldn't solve it, it's the API for the LMB.

For example, the LMB does not have a "peek" operation to see what is ahead in the queue, so you can't peek forward to find a message that you want, you'd actually have to consume the message and then push it back and hope you don't consume it again.

Also there's no "filter" mechanism to only get records which apply to your instance, there are no headers that you could actually filter on, ...

The point that I was making is that the LMB is not like a full-fledged JMS system where these kinds of issues are easily handled. It is a much simplified version.

Yes, the chatting problem itself is better handled through another communication mechanism, but I was limited somewhat since in my case the messages were getting transferred around via JMS (there were listeners attached to the JMS stream that could pluck out and respond to messages that could deal with automated responses, etc).