[SOLVED] Push between multiple webapps?

UI Components for JSF
FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

05 Mar 2014, 22:32

I have a chat application that is based on the p:poll component. I think it would be major improvement to refactor it to use p:push.

But the main issue is that this chat is made between two different webapps. webapp1 is used by the company clients and webapp2 is used by the company attendants. Each webapp has its own theme and authentication rules, so I don't pretend merging them in a single webapp.

Since the p:socket automatically appends the current context, is there a way to pass the full URL? The idea is to have the same channel in both webapps, but webapp1 would broadcast to webapp2 and vice versa.

Thanks in advance,
Phillip
Last edited by FkJ on 19 May 2014, 14:09, edited 1 time in total.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

05 Mar 2014, 23:38

Start by reading all of the following:

primefaces.PUSH_SERVER_URL with different urls

[solved] Problem with Apache 2 proxy

Push not working inside GF Virtual Server web app

Multiple push applications on one web server instance

also, Andy recommended some time ago that you may want to use a JMS server in a 'middle tier' that will accept requests from multiple webapps, and push to appropriate/connected clients.

after you implement this and meet your requirement, please share your implementation here. thanks. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

11 Mar 2014, 11:46

Thanks for the links, but from what I understood they refer to different issues.

JMS would be an option, but I never worked with it before, so I'd like to try something simpler before.

Since both webapps are on the same server, I think that if I could pass the context name to the push method it would work:

Code: Select all

	public void sendMessage()
	{
		// ...
		// persist message on database
		// ...
		
		PushContext pushContext = PushContextFactory.getDefault().getPushContext();
		pushContext.push("/webapp1/<<common channel id>>", "<<some notification>>");
		pushContext.push("/webapp2/<<common channel id>>", "<<some notification>>");
	}
Is there a parameter to allow me to do this?

Thanks

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

11 Mar 2014, 12:03

JMS, and I recommend tomee, since you're using tomcat. I started using JMS via ActiveMQ (bundled with tomee+).

Do the 2 web apps communicate or share same database?

Search Google for atmosphere wiki broadcaster, because your code and understanding is not correct.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

11 Mar 2014, 12:37

smithh032772 wrote:Do the 2 web apps communicate or share same database?
They use the same database.
smithh032772 wrote:Search Google for atmosphere wiki broadcaster, because your code and understanding is not correct.
I was actually reading it when I received the notification of new post here :D .

I'm taking a look at the PushServlet code to see if I figure out something.

I'll post this question in the Atmosphere group too.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

11 Mar 2014, 14:03

Good. You may want to allow both apps to receive REST requests, and then use PrimeFaces Push on each app to push messages.

Please share your code/implementation here, afterwards.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

12 Mar 2014, 19:26

FkJ wrote:I'll post this question in the Atmosphere group too.
The Atmosphere Framework > Push between multiple webapps?
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

12 Mar 2014, 20:31

Yeah.

I'm trying to figure out how push rules work before replying there.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

12 Mar 2014, 20:47

FkJ wrote:I'm trying to figure out how push rules work before replying there.
click this, and read that, entirely, especially the code/email that I embedded in the 'code' tags. There, you will see how someone else use 'push rule'. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

FkJ
Posts: 183
Joined: 08 Jan 2010, 19:16

19 May 2014, 14:09

Got it working with JMS: ActiveMQ + a simple web listener to read messages from the topic.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 43 guests