-
1. Re: I need help about Messaging!
bershath27 Sep 18, 2007 2:02 AM (in response to changemylife)first, i believe you have to post this to the EJB3 queue , not here. hope someone's going to move this thread to the correct location.
where is the *destination* ?? to which destination are you publishing your messages ??
btw, why do you still use deployment descriptors and do this in such a tortures way ? haven't you heard of annotations ??
you can do the same as follows :
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
@MessageDriven (activationConfig = {
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
@ActivationConfigProperty(propertyName="destination", propertyValue="topic/SriLanka"),
})
@TransactionManagement (TransactionManagementType.BEAN)
public class LogMDB implements MessageListener {
public void onMessage(Message message) {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
System.out.println(textMessage.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
*note*
in this example, i'm publishing messages to the topic called, "SriLanka". as i've said earlier, you got that error for you haven't provided a destination(topic) name.
Tyronne Wickramarathne -
2. Re: I need help about Messaging!
changemylife Sep 18, 2007 6:05 AM (in response to changemylife)Hi !
Sorry, my English is not good. The first, thanks to reply. My work is very urgent and I'm beginner with MDB and JMS so I post any where to expect reply from some one. The second, I'm sorry because I locate incorrectly.
Thank you very much! -
3. Re: I need help about Messaging!
bershath27 Sep 18, 2007 6:46 AM (in response to changemylife)>>My work is very urgent and I'm beginner with MDB and JMS so I post any where to expect reply from some one.
you will be the one, who's going to get the benefit, when you first post your query to the correct queue :) you have to get to the *relevant* queue to get a *relevant* from the *relevant* experts.
let me know, if you have solve your problem.
thanks
Tyronne Wickramarathne -
4. Re: I need help about Messaging!
changemylife Sep 18, 2007 11:22 PM (in response to changemylife)Hi !
I edited my MDB, and it's Ok. My jbossmq-myqueues-service.xml is look like:<mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=myQueue"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> </mbean>
And I put it inside /deploy --> all things are Ok. but when I write a client that send some TextMessage :InitialContext jndiContext = getInitialContext( ); try { ConnectionFactory factory = (ConnectionFactory)jndiContext.lookup("ConnectionFactory"); Queue queueTmp= (Queue)jndiContext.lookup("queue/producerQueue"); Connection connect = factory.createConnection( ); Session session = connect.createSession(false,Session.AUTO_ACKNOWLEDGE); MessageProducer sender = session.createProducer(queueTmp); for(int i=0; i<10; i++){ TextMessage t = session.createTextMessage(); t.setText(new Timestamp(System.currentTimeMillis())+" JmsClientProducer Message "+i); sender.send(t); Thread.sleep(1000); } connect.close(); } catch (NamingException e) { ...... }
And my jndi.properties is look like:java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099
When I run client, I received some errors:javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI class loader disabled)] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) at javax.naming.InitialContext.lookup(Unknown Source) at thai.jms.client.JmsClient.main(JmsClient.java:33) Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.lang.ClassNotFoundException: org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI class loader disabled) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) ... 3 more
---> and error at line:ConnectionFactory factory = (ConnectionFactory)jndiContext.lookup("ConnectionFactory");
But inside my MDB, I were declared:@Resource(mappedName="ConnectionFactory") private ConnectionFactory connectionFactory;
I understand your suggestions.And althought, I posted my article not correct but I recognized your helps and can you continue guide some my remain problems ?
Thanks.
Catania. -
5. Re: I need help about Messaging!
changemylife Sep 19, 2007 4:20 AM (in response to changemylife)Hi all!
I solved my problem. I importedjbossall-client
into my project, all things ok.