Foros del Web » Programación para mayores de 30 ;) » Java »

Error con JMS

Estas en el tema de Error con JMS en el foro de Java en Foros del Web. Tengo este código para crear un productor y un receptor de mensajes JMS muy sencillo: import java.util.logging.Level; import java.util.logging.Logger; import javax.jms.*; import javax.naming.*; /** * ...
  #1 (permalink)  
Antiguo 25/09/2010, 15:27
 
Fecha de Ingreso: agosto-2004
Mensajes: 85
Antigüedad: 19 años, 8 meses
Puntos: 0
Error con JMS

Tengo este código para crear un productor y un receptor de mensajes JMS muy sencillo:

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.*;
import javax.naming.*;

/**
*
* @author Migue
*/
public class ProductorMensajesJMS {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
InitialContext contexto=null;
QueueConnectionFactory factoria=null;
QueueConnection conexion=null;
QueueSession sesion=null;
Queue cola=null;
QueueSender envioCola=null;
TextMessage mensaje=null;
try {
contexto=new InitialContext();
factoria = (QueueConnectionFactory) contexto.lookup("FactoriaCola");
cola=(Queue) contexto.lookup("Cola");
} catch (NamingException ex) {
Logger.getLogger(ProductorMensajesJMS.class.getNam e()).log(Level.SEVERE, null, ex);
}
try {
conexion = factoria.createQueueConnection();
sesion=conexion.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
envioCola=sesion.createSender(cola);
mensaje=sesion.createTextMessage();
mensaje.setText("Que pasa colega");
envioCola.send(mensaje);
} catch (JMSException ex) {
Logger.getLogger(ProductorMensajesJMS.class.getNam e()).log(Level.SEVERE, null, ex);
}

}
}


package receptormensajesjmssincrono;

import java.util.logging.*;
import javax.naming.*;
import javax.jms.*;
/**
*
* @author Migue
*/
public class ReceptorMensajesJMSSincrono {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
InitialContext contexto=null;
QueueConnectionFactory factoria=null;
QueueConnection conexion=null;
QueueSession sesion=null;
Queue cola=null;
QueueReceiver reciboCola=null;
TextMessage mensaje=null;
try {
contexto=new InitialContext();
factoria = (QueueConnectionFactory) contexto.lookup("FactoriaCola");
cola=(Queue) contexto.lookup("Cola");
} catch (NamingException ex) {
Logger.getLogger(ReceptorMensajesJMSSincrono.class .getName()).log(Level.SEVERE, null, ex);
}
try {
conexion = factoria.createQueueConnection();
sesion=conexion.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
reciboCola=sesion.createReceiver(cola);
mensaje=(TextMessage)reciboCola.receive();
System.out.println("El texto del mensaje es: "+mensaje.getText());
} catch (JMSException ex) {
Logger.getLogger(ReceptorMensajesJMSSincrono.class .getName()).log(Level.SEVERE, null, ex);
}

}

}


El receptor no capta el mensaje.
Cuando ejecuto el productor tengo esta salida en Glassfish, y
como veo que se paran los servicios no se si lo estoy haciendo bién:

25-sep-2010 23:19:24 com.sun.enterprise.transaction.JavaEETransactionMa nagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransacti onManagerJTSDelegate as the delegate
25-sep-2010 23:19:35 org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
25-sep-2010 23:19:35 org.hibernate.validator.engine.resolver.DefaultTra versableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATravers ableResolver.
25-sep-2010 23:19:35 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: SJSMQ JMS Resource Adapter starting: REMOTE
25-sep-2010 23:19:35 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: SJSMQ JMSRA Started:REMOTE
25-sep-2010 23:19:36 com.sun.messaging.jms.ra.ResourceAdapter stop
INFO: MQJMSRA_RA1101: SJSMQ JMSRA stopping...
25-sep-2010 23:19:36 com.sun.messaging.jms.ra.ResourceAdapter stop
INFO: MQJMSRA_RA1101: SJSMQ JMSRA stopped.
25-sep-2010 23:19:36 com.sun.enterprise.connectors.service.ResourceAdap terAdminServiceImpl sendStopToResourceAdapter
INFO: ra.stop-successful


una ayudita please.
  #2 (permalink)  
Antiguo 25/09/2010, 16:24
 
Fecha de Ingreso: agosto-2004
Mensajes: 85
Antigüedad: 19 años, 8 meses
Puntos: 0
Respuesta: Error con JMS

el codigo funciona perfecto. No se que le pasaría al servidor.

Etiquetas: jms
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:45.