The messaging library supports messaging between portlets in different web applications, but this requires some configuration and extra work as discussed in the Cross-Context documentation.
If you put all your communicating portlets into the same webapp, you will not need this.
Provided here is an example implementation of a remote MessageStore (an EJB) and corresponding client, with two example portlet applications for testing it.
The EJB (messaging-example-ejb-1.0.jar) needs to be hosted on an appropriate server: install instructions are provided below for JBoss and Geronimo. These instructions assume that this server will be separate from the one on which the portal & portlets are installed (e.g. you have separately downloaded a JBoss installer and a Jetspeed+Tomcat installer), although they could be the same. The portlet webapp using messaging then needs to be configured to connect to the EJB server using the correct JNDI client properties (set in PortletMessaging.properties), and provided with any necessary EJB client libraries in its WEB-INF/lib.
Here are the 'bare' portlet webapps - with no EJB client libraries added - for if you are using a different EJB server version than those I've tried:
Both of these messaging webapps contain the same portlets; their names are marked with "A" and "B" so you can tell which app they are from.
You can test out cross-context messaging most easily with the test portlets Portlet1 and Portlet2: try adding Portlet1A and Portlet2B to the same page, to see how they can communicate.
You can also use the MessageReader portlet as a debug output to see which messages are visible in that webapp - both MessageReaderA and MessageReaderB should see the same messages.
Installing on JBoss
I've tested this with JBoss 3.2.7 and 4.0.2. The following instructions will not work with 4.0.3, but apparently this problem has been fixed with 4.0.4 (not tried).
(probably necessary) Change the HTTP port (8080) of JBoss's Tomcat
so that it doesn't conflict with a separate Portal install on the same machine.
Edit jboss/server/default/deploy/jbossweb-tomcat5X.sar/server.xml and modify the "HTTP/1.1 Connector on port 8080" to Connector port="7070"
Use the 'bare' webapps messaging-webapp-A.war and messaging-webapp-B.war. Modify both the WARs containing the messaging portlets - either before deploying them to the portal, or after they've been deployed and you can edit the decompressed webapp (restart the portal after making changes if you do this).
The provided messaging webapps have already been configured to use the correct MessageStore and SessionIDRetriever; they just need to be configured to connect to JBoss.
In both WEB-INF/classes/message/PortletMessaging.properties, ensure that the JBoss settings are uncommented and the Geronimo ones are commented or removed.
Copy jboss/client/jbossall-client.jar to both the messaging webapps' WEB-INF/lib/.
Start up JBoss and your Portal server, and try out the portlets!
jboss/bin/run
Problems
Have a look in jboss/server/default/log/ for clues... the EJB will output debug messages when it is accessed by the portlets.
There may also be errors in the portal's log if there is a problem connecting to the EJB. If you're running Tomcat from tomcat/bin/startup.bat in Windows, and errors are only going to the console, not log files, try running it as a windows service instead: "service.bat install" then start the "Apache Tomcat" service.
Create the database table that the EJB will use to store the messages, in SystemDatabase:
CREATE TABLE MessageStoreTable(SESSION_ID VARCHAR(255),STORE BLOB)
With Geronimo running, go to the web console: http://localhost:7070/console (system/manager). (use the correct HTTP port)
Navigate to Misc -> Embedded DB -> DB Manager.
Use DB: SystemDatabase
Add the SQL to the text area: CREATE TABLE MessageStoreTable(SESSION_ID VARCHAR(255),STORE BLOB)
Try deploying from the console, in geronimo/bin; you'll be able to see the error messages that way:
java -jar deployer.jar --user system --password manager --syserr deploy D:\messaging-example-ejb-1.0.jar
Use the 'bare' webapps messaging-webapp-A.war and messaging-webapp-B.war. Modify both the WARs containing the messaging portlets - either before deploying them to the portal, or after they've been deployed and you can edit the decompressed webapp (restart the portal after making changes if you do this).
The provided messaging webapps have already been configured to use the correct MessageStore and SessionIDRetriever; they just need to be configured to connect to JBoss.
In both WEB-INF/classes/message/PortletMessaging.properties, ensure that the Geronimo settings are uncommented and the JBoss ones are commented or removed.
Copy all required client libraries to both the messaging webapps' WEB-INF/lib/. You can get these from geronimo/repository. For Geronimo 1.0, these are:
Start up Geronimo and your Portal server, and try out the portlets!
geronimo/bin/startup
Problems
Have a look in geronimo/var/log/ for clues... the EJB will output debug messages when it is accessed by the portlets.
There may also be errors in the portal's log if there is a problem connecting to the EJB. If you're running Tomcat from tomcat/bin/startup.bat in Windows, and errors are only going to the console, not log files, try running it as a windows service instead: "service.bat install" then start the "Apache Tomcat" service.