|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
DWR with JMSI realized that it is a feature of the upcoming DWR3 release, but in the meantime, has anyone had success linking DWR to JMS? If so, would you be willing to share how you completed this. Thanks Ken |
|
|
RE: DWR with JMSI have used DWR in this jms message monitoring tool for TIBCO EMS or ActiveMQ https://anderstool.dev.java.net/ Regards, Anders Date: Mon, 12 Oct 2009 11:25:30 -0500 From: kenyoung@... To: users@... Subject: [dwr-user] DWR with JMS I realized that it is a feature of the upcoming DWR3 release, but in the meantime, has anyone had success linking DWR to JMS? If so, would you be willing to share how you completed this. Thanks Ken Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. |
|
|
Re: DWR with JMSWhere did you hear/see this was a feature in the upcoming 3.0 release?
On Mon, Oct 12, 2009 at 10:34 AM, Anders Viklund <viklund_anders@...> wrote:
|
|
|
Re: DWR with JMSHi Ken,
I did it using Spring and dwr 2.0.6 and reverse Ajax (be aware that the way you browse Session in DWR change between version 2 and 3) : here is the spring file : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans> <bean id="jndiTemplateJms"
class="org.springframework.jndi.JndiTemplate"> <property name="environment">
<props> <prop key="java.naming.factory.initial">
${expresPresentation.jms.evenement.java.naming.factory.initial} </prop>
<prop key="java.naming.provider.url"> ${expresPresentation.jms.evenement.java.naming.provider.url}
</prop> </props>
</property> </bean> <bean id="jmsTopicConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate">
<ref bean="jndiTemplateJms" /> </property>
<property name="jndiName"> <value>${expresPresentation.jms.evenement.topicConnectionFactory}</value>
</property> </bean> <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate"> <ref bean="jndiTemplateJms" />
</property> <property name="jndiName">
<value>${expresPresentation.jms.evenement.topic}</value> </property>
</bean> <bean id="queueUpdateJms" class="fr.rs2i.ima.expres.jms.QueueUpdate"/>
<!-- and this is the message listener container -->
<bean id="listenerContainer" class="org.springframework.jms.listener.SimpleMessageListenerContainer">
<property name="connectionFactory" ref="jmsTopicConnectionFactory" /> <property name="messageListener" ref="queueUpdateJms" />
<property name="destination" ref="destination" /> </bean> </beans>
and the java code: package fr.rs2i.ima.expres.jms;
import java.io.ByteArrayInputStream;
import java.text.SimpleDateFormat; import java.util.Collection;
import java.util.Date; import java.util.Iterator;
import javax.jms.JMSException; import javax.jms.Message;
import javax.jms.MessageListener; import javax.jms.TextMessage;
import javax.servlet.ServletContext; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.TransformerException;
import org.apache.log4j.Logger; import org.apache.xpath.XPathAPI;
import org.directwebremoting.ScriptBuffer; import org.directwebremoting.ScriptSession;
import org.directwebremoting.ServerContext; import org.directwebremoting.ServerContextFactory;
import org.springframework.web.context.ServletContextAware; import org.w3c.dom.Document;
import org.w3c.dom.Node; import fr.rs2i.ima.expres.ajax.bean.QueueUpdateNotification;
import fr.rs2i.swFramework.exception.ServiceException; import fr.rs2i.swFramework.exception.SysServiceException;
public class QueueUpdate implements MessageListener, ServletContextAware
{ private ServletContext servletContext = null;
public final static String pageName="/ImaExpresPresentation/private/accueil.do"; private static Logger logger = Logger.getLogger(QueueUpdate.class); private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
private DocumentBuilder documentBuilder = null; public QueueUpdate() {
if(logger.isDebugEnabled()) logger.debug( "QueueUpdate() constructor Start" );
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware (false);
factory.setValidating (false); factory.setIgnoringElementContentWhitespace (false);
try { documentBuilder = factory.newDocumentBuilder();
} catch(Exception e) {
logger.error("error while getting a documentBuilder(xml)",e); }
if(logger.isDebugEnabled()) logger.debug( "QueueUpdate() DocumentFactoryBuilder initialisation done." );
} public void onMessage( Message message )
{ if(logger.isDebugEnabled()) logger.debug( "QueueUpdate.onMessage: new Message recieved null?"+(message==null));
QueueUpdateNotification queueUpdateNotification = new QueueUpdateNotification();
String messageBody = null;
String idPrestataire = null; String referenceDossier = null;
String typeEvenement = null; queueUpdateNotification.setDateSurvenance(dateFormat.format( new Date() ));
String idAffaire = ""; try { messageBody = ((TextMessage)message).getText();
if(logger.isDebugEnabled())
logger.debug( "QueueUpdate.onMessage: new Message text Body :\n"+messageBody+"\nEndOfMessageBody"); Document document = documentBuilder.parse( new ByteArrayInputStream(messageBody.getBytes()));
idPrestataire = this.getValue(document, "/evenement/donnees-metier/donnee-metier[@id='code-prestataire']");
referenceDossier = this.getValue(document, "/evenement/donnees-metier/donnee-metier[@id='reference-dossier']");
idAffaire = this.getValue(document, "/evenement/id-metier"); typeEvenement = this.getValue(document, "/evenement/type-evenement");
queueUpdateNotification.setCodePrestatire ( idPrestataire );
queueUpdateNotification.setIdAffaire ( idAffaire ); queueUpdateNotification.setReferenceDossier ( referenceDossier );
queueUpdateNotification.setTypeEvenement ( typeEvenement ); if(logger.isDebugEnabled()) logger.debug( "QueueUpdate.onMessage: extracted data : idPrestataire='"+idPrestataire+"', referenceDossier='"+referenceDossier+"', idAffaire='"+idAffaire+"', typeEvenement='"+typeEvenement+"'");
}
catch ( JMSException e ) { logger.error( "Error while getText of message", e );
} catch ( Exception e ) {
logger.error( "Error while parsing message "+messageBody, e ); }
ServerContext serverContext = ServerContextFactory.get( servletContext );
Collection sessions = serverContext.getScriptSessionsByPage( pageName ); if(logger.isDebugEnabled()) logger.debug( "QueueUpdate.onMessage: number sessions.size()="+sessions.size());
Iterator iterator = sessions.iterator();
ScriptBuffer scriptBuffer = new ScriptBuffer("notifyUpdate(");
scriptBuffer.appendData (queueUpdateNotification ); scriptBuffer.appendScript (");");
while(iterator.hasNext()) {
ScriptSession session = (ScriptSession)iterator.next(); String idPrestataireSessionScript = (String )session.getAttribute( "idPrestataire" );
String isPageEnCours = (String )session.getAttribute( "isPageEnCours" ); if(logger.isDebugEnabled()) logger.debug( "QueueUpdate.onMessage: sessions.iteration, idPrestataireSessionScript='"+idPrestataireSessionScript+"', isPageEnCours='"+isPageEnCours+"'");
if(idPrestataireSessionScript != null &&
idPrestataireSessionScript.equals(idPrestataire)) {//Evenement a destination du prestataire de cette session
if( isPageEnCours.equals( "true" ))
{//le prestataire est sur la page encours if(typeEvenement.equals("CREATION_DOSSIER_WORKFLOW") /*||typeEvenement.equals("COLLABORATEUR_AFFECTE")*/)
{//l'evenement est une création ou une affecation => ca concerne la page encours -> update session.addScript( scriptBuffer );
if(logger.isDebugEnabled())
logger.debug( "QueueUpdate.onMessage: sessions.iteration, sending script to client on pageEnCours, idPrestataireSessionScript='"+idPrestataireSessionScript+"', isPageEnCours='"+isPageEnCours+"'");
} } else
{//le prestataire est sur la page en gestion //IMA-239 : désactive la notification pour les préfacture générée
if(false && typeEvenement.equals("PREFACTURE_GENEREE")) {//l'evenement est une préfacture générée => ca concerne la page en gestion -> update
session.addScript( scriptBuffer ); if(logger.isDebugEnabled())
logger.debug( "QueueUpdate.onMessage: sessions.iteration, sending script to client on pageEnGestion, idPrestataireSessionScript='"+idPrestataireSessionScript+"', isPageEnCours='"+isPageEnCours+"'");
} } }
} if(logger.isDebugEnabled()) logger.debug( "QueueUpdate.onMessage: EndOfMethode");
} public String getValue( Node node, String xPathExpression ) throws ServiceException {
try { Node child = XPathAPI.selectSingleNode( node, xPathExpression );
if ( child != null && child.getFirstChild() != null )
return child.getFirstChild().getNodeValue(); return ""; }
catch ( TransformerException e ) {
throw new SysServiceException( e ); }
} public void setServletContext( ServletContext servletContext )
{ this.servletContext = servletContext;
} }
On Mon, Oct 12, 2009 at 18:25, Ken Young <kenyoung@...> wrote: is a feature of the upcoming DWR3 release, but in the meantime, has anyone had success linking DWR to JMS? If so, would you be willing to share how you completed this. |
|
|
Re: DWR with JMShttp://cometdaily.com/2008/03/21/developing-for-comet/ Ken On 10/12/09 11:38 AM, "David Marginian" <david@...> wrote: Where did you hear/see this was a feature in the upcoming 3.0 release? |
|
|
Re: DWR with JMSThanks Ken On 10/12/09 11:34 AM, "Anders Viklund" <viklund_anders@...> wrote: Hi Ken, |
|
|
Re: DWR with JMShttp://slurm.dojotoolkit.org/bamboo/
On Tue, Oct 20, 2009 at 5:49 AM, Ken Young <kenyoung@...> wrote:
|
|
|
RE: DWR with JMSDate: Mon, 19 Oct 2009 22:49:32 -0500 From: kenyoung@... To: users@... Subject: Re: [dwr-user] DWR with JMS Thanks Ken On 10/12/09 11:34 AM, "Anders Viklund" <viklund_anders@...> wrote: Hi Ken, Keep your friends updated— even when you’re not signed in. |
|
|
Re: DWR with JMSKen On 10/20/09 6:34 AM, "Anders Viklund" <viklund_anders@...> wrote: I haven't put the source there yet, but I can send you parts of the code to you if you like. |
|
|
RE: DWR with JMSCLIENT SIDE: dashboard.gsp //Trigger the server side jms subscriber from the client jQuery(document).ready(function() { Subscriber.trigger(); }); // Function called by the server side jms subscriber function updateSomeElement(messageText){ if(isIE){ someElement.innerText=messageText; } else{ someElement.innerHTML=messageText; } } -------- -------- -------- -------- -------- -------- SERVER SIDE: Subscriber.groovy TopicConnectionFactory factory = new com.tibco.tibjms.TibjmsTopicConnectionFactory(connectionString) TopicConnection connection = factory.createTopicConnection(userName,password) TopicSession session = connection.createTopicSession(false,com.tibco.tibjms.Tibjms.NO_ACKNOWLEDGE) javax.jms.Topic topic = session.createTopic(topicName) javax.jms.Message message def currentPage TopicSubscriber subscriber //This function is called from the web page synchronized void trigger() { currentPage = WebContextFactory.get().getCurrentPage() def s = new Subscriber() def subscriberThread = new Thread(s).start() } void run() { subscriber = session.createSubscriber(topic) connection.start() //Listen for jms messages while(true){ try{ message = subscriber.receive() // send jms message content to the web page Browser.withPage(currentPage){ org.directwebremoting.ui.ScriptProxy.addFunctionCall("updateSomeElement",message.getText())) } catch(...) } Date: Tue, 20 Oct 2009 09:59:51 -0500 From: kenyoung@... To: users@... Subject: Re: [dwr-user] DWR with JMS Ken On 10/20/09 6:34 AM, "Anders Viklund" <viklund_anders@...> wrote: I haven't put the source there yet, but I can send you parts of the code to you if you like. Keep your friends updated— even when you’re not signed in. |
|
|
Re: DWR with JMSOn 10/20/09 2:40 PM, "Anders Viklund" <viklund_anders@...> wrote: Here is the very basics of the message monitor: |
| Free embeddable forum powered by Nabble | Forum Help |