esercizio e test usando jms e mdb

This commit is contained in:
2015-05-31 21:15:23 +02:00
parent b4e795d64a
commit 620edb5049
15 changed files with 517 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
package test4_jms_client;
import test4_jms.GeneralMessage;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* Created by Giovanni on 31/05/2015.
*/
public class client {
public static void main(String[] args) throws NamingException {
GeneralMessage gm = new GeneralMessage();
gm.s = "messaggio del caiser 2";
Context jndiContext = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory) jndiContext.lookup("jms/javaee7/ConnectionFactory");
Destination topic = (Destination) jndiContext.lookup("jms/javaee7/Topic");
try (JMSContext jmsContext = connectionFactory.createContext()) {
jmsContext.createProducer().setProperty("author", 0).send(topic,gm);
}
}
}