Package javax.jms

Examples of javax.jms.ConnectionFactory


  public static void main(String[] args) throws Exception {
    System.out.println("Subscribes and listens to the topic...");

    ictx = new InitialContext();
    Topic topic = (Topic) ictx.lookup("topic");
    ConnectionFactory tcf = (ConnectionFactory) ictx.lookup("tcf");
    ictx.close();

    Connection cnx = tcf.createConnection();
    Session session = cnx.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, "durable");
    subscriber.setMessageListener(new MsgListener());

    cnx.start();
View Full Code Here


 
  static Context ictx = null;

  public static void main(String[] args) throws Exception {
   
    ConnectionFactory cf = null;
    Topic dest = null;

    if (args.length != 1)
     throw new Exception("Bad number of argument");

    ictx = new InitialContext();
    try {
      if (args[0].equals("-")) {
        // Choose a connection factory and the associated topic depending of
        // the location property.
        cf = (ConnectionFactory) ictx.lookup("clusterCF");
        dest = (Topic) ictx.lookup("clusterTopic");
      } else {
        cf = (ConnectionFactory) ictx.lookup("cf" + args[0]);
        dest = (Topic) ictx.lookup("topic" + args[0]);
        System.setProperty("location", "server" + args[0]);
      }
    } finally {
      ictx.close();
    }

    Connection cnx = cf.createConnection("anonymous", "anonymous");
    Session session = cnx.createSession(true, 0);
    MessageProducer pub = session.createProducer(dest);

    String location = System.getProperty("location");
    if (location != null)
View Full Code Here

  public static void main(String[] arg) throws Exception {
    System.out.println();
    System.out.println("Publishes messages on topic...");

    ConnectionFactory cf = HATcpConnectionFactory.create("hajoram://localhost:2560,localhost:2561,localhost:2562");
    ((HATcpConnectionFactory) cf).getParameters().connectingTimer = 30;

    AdminModule.connect(cf, "root", "root");

    Topic topic = Topic.create(0,"topic");

    AdminModule.disconnect();


    Connection cnx = cf.createConnection("anonymous", "anonymous");
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer pub = sess.createProducer(topic);

    TextMessage msg = sess.createTextMessage();
View Full Code Here

  public static void main(String[] args) throws Exception {
    System.out.println("Trace1");

    ictx = new InitialContext();
    Queue queue = (Queue) ictx.lookup("receiveMailQueue");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    System.out.println("Trace2");

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer cons = sess.createConsumer(queue);

    System.out.println("Listens to the MailQueue...");
    System.out.println("hit a key to stop.");
View Full Code Here

    System.out.println("Listens to the collector queue...");

    ictx = new InitialContext();
    Queue queue = (Queue) ictx.lookup("queue");
    // Topic topic = (Topic) ictx.lookup("topic");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer recv = sess.createConsumer(queue);
    // MessageConsumer subs = sess.createConsumer(topic);

    recv.setMessageListener(new MsgListener("Collector Queue listener"));
View Full Code Here

 
  public static void main(String[] args) throws Exception {
    System.out.println("Monitoring administration...");

    javax.naming.Context jndiCtx = new javax.naming.InitialContext();
    ConnectionFactory cf = (ConnectionFactory) jndiCtx.lookup("cf");
   
    AdminModule.connect(cf, "root", "root");
   
    Properties topicProps = new Properties();
    topicProps.put("acquisition.className", "org.objectweb.joram.mom.dest.MonitoringAcquisition");
View Full Code Here

    System.out.println();
    System.out.println("Listens to the monitoring topic...");

    Context ictx = new InitialContext();
    Topic topic = (Topic) ictx.lookup("MonitoringTopic");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer subs = sess.createConsumer(topic);

    subs.setMessageListener(new MonitorMsgListener());
View Full Code Here

  public static void main(String[] args) throws Exception {
    System.out.println("Listens to the dead message queue...");

    Context ictx = new InitialContext();
    Queue dmq = (Queue) ictx.lookup("dmq");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection("anonymous", "anonymous");

    Session session = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(dmq);

    cnx.start();
View Full Code Here

  public static void main(String[] args) throws Exception {
    Context ictx = new InitialContext();
    Queue queue1 = (Queue) ictx.lookup("queue1");
    Queue queue2 = (Queue) ictx.lookup("queue2");
//    Queue queue3 = (Queue) ictx.lookup("queue3");
    ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
    ictx.close();

    Connection cnx = cf.createConnection();
    Session prodSession = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Session consSession = cnx.createSession(true, 0);
   
    MessageProducer producer = prodSession.createProducer(null);
    MessageConsumer consumer = consSession.createConsumer(queue1);
View Full Code Here

        TopicConnectionFactory factory = TopicTcpConnectionFactory.create(hostName, serverPort);
        setFactoryParameters((AbstractConnectionFactory) factory, (ManagedConnectionFactoryImpl) mcf);
        ((AbstractConnectionFactory) factory).setIdentityClassName(identityClass);
        return factory.createTopicConnection(userName, password);
      } else {
        ConnectionFactory factory = TcpConnectionFactory.create(hostName, serverPort);
        setFactoryParameters((AbstractConnectionFactory) factory, (ManagedConnectionFactoryImpl) mcf);
        ((AbstractConnectionFactory) factory).setIdentityClassName(identityClass);
        return factory.createConnection(userName, password);
      }
    } catch (IllegalStateException exc) {
      throw new CommException("Could not access the JORAM server: " + exc);
    } catch (JMSSecurityException exc) {
      throw new SecurityException("Invalid user identification: " + exc);
View Full Code Here

TOP

Related Classes of javax.jms.ConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.