Push clustered with JMS - <p:socket onMessage > not fired

UI Components for JSF
Post Reply
marc.bouvier.agipi
Posts: 4
Joined: 25 May 2016, 17:03

02 Aug 2016, 15:47

Hi,

I am trying to use Primefaces Push with JMSBroadcaster.
I am able to run my application and I can see JMSBroadcaster is activated and publishes the messages from the event bus to the JMS Topic.
However I cannot get <p:socket> "onMessage" to fire on my browser.

I have read this forum topic : http://forum.primefaces.org/viewtopic.php?f=10&t=36720 .

When I do not use maven dependency, org.atmosphere:atmosphere-jms I have a correct behaviour and messages are displayed to the screen.

Then, when I use maven dependency, org.atmosphere:atmosphere-jms , JMSBroadcaster::outgoingBroadcast(Object message) is fired and the message is properly sent to JMS topic. However the <p:socket> "onMessage" is not fired anymore.

I feel like org.atmosphere.plugin.jms.JMSFilter should be triggered somehow.

Am I missing something?
______________________________________________________________________

Here is how I configured Push in my application.

- I installed ActiveeMQ 5.13.4 on a remote server.


I added activeMQ jars on my tomcat server :
- lib/activemq-all-5.13.4.jar

I configured Tomcat to define Topic and ConnectionFactory
server.xml

Code: Select all

    <Resource name="jms/atmosphereFactory"
        auth="Container"
        type="org.apache.activemq.ActiveMQConnectionFactory"
        description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        brokerURL="tcp://adress_to_remote_activemq:61616?daemon=true"
        userName="admin" password="admin"
        useEmbeddedBroker="false"
        brokerName="localhost" />

    <Resource id="atmosphere" name="jms/atmosphere"
        auth="Container"
        type="org.apache.activemq.command.ActiveMQTopic"
        description="JMS Topic"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        userName="admin" password="admin"
        physicalName="ATMOSPHERE.TOPIC"
        />
context.xml

Code: Select all

    <ResourceLink global="jms/atmosphereFactory" name="jms/atmosphereFactory" type="org.apache.activemq.ActiveMQConnectionFactory" />
    <ResourceLink global="jms/atmosphere" name="jms/atmosphere" type="org.apache.activemq.command.ActiveMQTopic" />
pom.xml

Code: Select all

	   <dependency>
			<groupId>org.primefaces</groupId>
			<artifactId>primefaces</artifactId>
            <version>5.3</version>
		</dependency>
            <!-- Primefaces push -->
            <dependency>
                <groupId>org.atmosphere</groupId>
                <artifactId>atmosphere-runtime</artifactId>
                <version>2.4.0</version>
            </dependency>
            <dependency>
                <groupId>org.atmosphere</groupId>
                <artifactId>atmosphere-jms</artifactId>
                <version>2.4.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-client</artifactId>
                <version>5.13.4</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
                <version>1.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.management.j2ee</groupId>
                <artifactId>javax.management.j2ee-api</artifactId>
                <version>1.1.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.inject</groupId>
                <artifactId>javax.inject</artifactId>
                <version>1</version>
            </dependency>
Jsf page code

Code: Select all

 <p:socket widgetVar="notifySocket" channel="/demo/BOUVIERM" onMessage="handlerAction"/>
 <script type="text/javascript">
            //<![CDATA[
            function handlerAction(pushMessage) {
                alert(pushMessage);
            }
            //]]>
        </script>
This code is called to publish a message to a p:socket in a jsf page.

Code: Select all

   EventBus eventBus = EventBusFactory.getDefault().eventBus();
   eventBus.publish("/demo/BOUVIERM", "Hello world");
I created a topic called ATMOSPHERE.TOPIC
ActiveMQ administration panel
We can see that messages are created into the topic when
Image
Subscribers of the topic ATMOSPHERE.TOPIC
Image

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 48 guests