Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1241 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  configurer Jboss pour JMS

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

configurer Jboss pour JMS

n°1174367
mars47058
Posté le 11-08-2005 à 10:37:20  profilanswer
 

salut !
je voudrais pouvoir utiliser Jms sur Jboss, mais voila, mon prog me renvoit l'erreur suivante:
 
Starting...
javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:707)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
 at javax.naming.InitialContext.lookup(Unknown Source)
 at com.xml.sax.Sender.main(Sender.java:24)
Caused by: java.rmi.RemoteException: Service unavailable.
 at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:158)
 at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:196)
 at $Proxy0.lookup(Unknown Source)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
 ... 3 more
Ending...

 
je débute avec Jboss, avec eclipse aussi, enfin bref, avec J2EE.
j'ai lu un article sur la configuration de Jboss mais, je desespère de trouver comment configuré le serveur !
 
que signifit "javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable"??
que parametre dois je modifier ?
 

Code :
  1. public class Sender {
  2.     public static void main(String[] args) {
  3.         System.out.println("Starting..." );
  4.         QueueConnectionFactory aQCF = null;
  5.         QueueConnection aQC = null;
  6.         QueueSession aQS = null;
  7.         QueueSender aSender  = null;
  8.         try {
  9.             InitialContext aIC = new InitialContext(Resource.getResources());
  10.             aQCF = (QueueConnectionFactory) aIC.lookup("ConnectionFactory" );
  11.             aQC = aQCF.createQueueConnection();
  12.             aQS = aQC.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  13.             Queue aQueue = (Queue) aIC.lookup("queue/A" );
  14.                    //ici, une queue qui tourne sur jboss  
  15.             aSender = aQS.createSender(aQueue);
  16.             aQC.start();
  17.             for (int i = 0; i < 10; i++) {
  18.                 aSender.send(aQS.createObjectMessage(new Integer(i)));
  19.             }
  20.         } catch (Exception e) {
  21.             e.printStackTrace();
  22.         } finally {
  23.             try {
  24.                 if (aSender != null) {
  25.                     aSender.close();
  26.                 }
  27.                 if (aQS != null) {
  28.                     aQS.close();
  29.                 }
  30.                 if (aQC != null) {
  31.                     aQC.stop();
  32.                     aQC.close();
  33.                 }
  34.             } catch (JMSException e) {
  35.                 e.printStackTrace();
  36.             }
  37.         }
  38.         System.out.println("Ending..." );
  39.     }
  40. }


 
 

Code :
  1. package com.xml.sax;
  2. import java.io.InputStreamReader;
  3. import javax.jms.JMSException;
  4. import javax.jms.MessageListener;
  5. import javax.jms.ObjectMessage;
  6. import javax.jms.QueueConnection;
  7. import javax.jms.QueueConnectionFactory;
  8. import javax.jms.QueueReceiver;
  9. import javax.jms.QueueSession;
  10. import javax.naming.InitialContext;
  11. import sun.misc.Queue;
  12. import com.sun.corba.se.internal.iiop.messages.Message;
  13. public abstract class Receiver {
  14.     protected void doAll() {
  15.         QueueConnectionFactory aQCF = null;
  16.         QueueConnection aQC = null;
  17.         QueueSession aQS = null;
  18.         QueueReceiver aQR  = null;
  19.         try {
  20.             InitialContext aIC = new InitialContext(Resource.getResources());
  21.             aQCF = (QueueConnectionFactory) aIC.lookup("ConnectionFactory" );
  22.             aQC = aQCF.createQueueConnection();
  23.             aQS = createQueueSession(aQC);
  24.             final QueueSession aQS1 = aQS;
  25.             Queue aQueue = (Queue) aIC.lookup("queue/A" );
  26.             aQR = aQS.createReceiver(aQueue);
  27.             MessageListener aML = new MessageListener() {
  28.                 public void onMessage(Message aMessage) {
  29.                     try {
  30.                         processMessage(aMessage, aQS1);
  31.                     } catch (JMSException e) {
  32.                         e.printStackTrace();
  33.                     }
  34.                 }
  35.             };
  36.            
  37.             aQR.setMessageListener(aML);
  38.             aQC.start();
  39.             InputStreamReader aISR = new InputStreamReader(System.in);
  40.             char aAnswer = ' ';
  41.             do {
  42.                 aAnswer = (char) aISR.read();
  43.                 if ((aAnswer == 'r') || (aAnswer == 'R')) {
  44.                     aQS.recover();
  45.                 }
  46.             } while ((aAnswer != 'q') && (aAnswer != 'Q'));
  47.         } catch (Exception e) {
  48.             e.printStackTrace();
  49.         } finally {
  50.             try {
  51.                 if (aQR != null) {
  52.                     aQR.close();
  53.                 }
  54.                 if (aQS != null) {
  55.                     aQS.close();
  56.                 }
  57.                 if (aQC != null) {
  58.                     aQC.stop();
  59.                     aQC.close();
  60.                 }
  61.             } catch (JMSException e) {
  62.                 e.printStackTrace();
  63.             }
  64.         }
  65.     }
  66.     protected void processMessage(Message aMessage, QueueSession aQS) throws JMSException {
  67.         if (aMessage instanceof ObjectMessage) {
  68.             ObjectMessage aOM = (ObjectMessage) aMessage;
  69.             System.out.print(aOM.getObject() + " " );
  70.             System.out.print(" message recieved " );
  71.         }
  72.     }
  73.     protected abstract QueueSession createQueueSession(
  74.         QueueConnection aQC
  75.     ) throws JMSException;
  76. }

mood
Publicité
Posté le 11-08-2005 à 10:37:20  profilanswer
 

n°1174762
mars47058
Posté le 11-08-2005 à 17:07:09  profilanswer
 

et bien voila, ca marche !
 
pour ceux qui cherchent encore une solution a leur problemes de jms :
 
http://wiki.jboss.org/wiki/attach? [...] lution.txt
 
et je partage l'avis du mec, y'a aucun tutoriel "clair" pour les débutant sur le net !!!
 
merci a lui !


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  configurer Jboss pour JMS

 

Sujets relatifs
[apache] comment configurer l'apparence par defaut ?Configurer Apache 1.3.33 avec SSL
configurer l'affichageaccess denied (java.util.PropertyPermission org.jboss.util.NestedThrow
comment configurer une bdd access sous builderRecherche interface web pour configurer connexion ldap
JBoss hiérarchie des répertoiresLicenece J2EE JBoss
Eclipse : plugin pour configurer programme externe[JAVA][JMS][JBOSS] The connection has already a clientID
Plus de sujets relatifs à : configurer Jboss pour JMS


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR