Examples of TopicConnectionFactory


Examples of javax.jms.TopicConnectionFactory

        this.joramAdapter.createQueueCF("QCF");
        this.joramAdapter.createTopicCF("TCF");

        // Create connection factories  that will be used by a pure JMS Client
        ConnectionFactory jcf = null;
        TopicConnectionFactory jtcf = null;
        QueueConnectionFactory jqcf = null;

        String name = CONN_FACT_NAME;
        try {
            jcf = TcpConnectionFactory.create(this.host, this.port);
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

      }
   }

   public void testInvalidSelectorOnSubscription() throws Exception
   {
      TopicConnectionFactory cf = (TopicConnectionFactory)ic.lookup("/ConnectionFactory");
      TopicConnection c =  cf.createTopicConnection();
      c.setClientID("something");
      try
      {
         TopicSession s = c.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         Topic topic = (Topic)ic.lookup("/topic/Topic");
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

    * @throws Exception
    */
   public void testRemoveAllMessages() throws Exception
   {
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicRemoveAllMessages");
     
      try
      {
         Topic topic = (Topic)ic.lookup("/topic/TopicRemoveAllMessages");
  
         TopicConnection conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer prod = s.createProducer(topic);
         prod.setDeliveryMode(DeliveryMode.PERSISTENT);
  
         // Create 1 durable subscription and 1 non-durable subscription
         s.createDurableSubscriber(topic, "Durable1");
         s.createSubscriber(topic);
        
         // Send 1 message
         prod.send(s.createTextMessage("First one"));        
        
         ObjectName destObjectName =
            new ObjectName("jboss.messaging.destination:service=Topic,name=TopicRemoveAllMessages");
        
         int count = ((Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount")).intValue();
        
         assertEquals(2, count);
        
         // Start the connection for delivery
         conn.start();
        
         // Remove all messages from the topic
        
         //Need to pause since delivery may still be in progress
         Thread.sleep(2000);
        
         ServerManagement.invoke(destObjectName, "removeAllMessages", null, null);
  
         count = ((Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount")).intValue();
        
         assertEquals(0, count);
                 
         // Now close the connection
         conn.close();
        
         Thread.sleep(1000);
        
         count = ((Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount")).intValue();
        
         assertEquals(0, count);
        
         // Connect again to the same topic
         conn = cf.createTopicConnection();
         conn.setClientID("Client1");
         s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         prod = s.createProducer(topic);
         prod.setDeliveryMode(DeliveryMode.PERSISTENT);
  
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

   }
 
   public void testMessageCount() throws Exception
   {
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicGetAllMessageCount");
     
      ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "enableMessageCounters", null, null);
     
      TopicConnection conn = null;
     
     
      try
      {                 
         Topic topic = (Topic)ic.lookup("/topic/TopicGetAllMessageCount");
  
         conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer prod = s.createProducer(topic);
         prod.setDeliveryMode(DeliveryMode.PERSISTENT);
  
         // Create 1 durable subscription and 2 non-durable subscription
         s.createDurableSubscriber(topic, "SubscriberA");
        
         s.createSubscriber(topic);
         s.createSubscriber(topic);
        
         //Send a couple of messages
         TextMessage tm1 = s.createTextMessage("message1");
         TextMessage tm2 = s.createTextMessage("message2");
        
         prod.send(tm1);
         prod.send(tm2);
  
         // There should be 3 subscriptions
         ObjectName destObjectName =
            new ObjectName("jboss.messaging.destination:service=Topic,name=TopicGetAllMessageCount");
        
         Integer count = (Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount");
         assertEquals(6, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "DurableMessageCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "NonDurableMessageCount");
         assertEquals(4, count.intValue());
                 
         // Now disconnect
         conn.close();
        
         // Only the durable should survive
         count = (Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "DurableMessageCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "NonDurableMessageCount");
         assertEquals(0, count.intValue());
        
         // Now connect again and restore the durable subscription
         conn = cf.createTopicConnection();
         conn.setClientID("Client1");
         s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer cons = s.createDurableSubscriber(topic, "SubscriberA");
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount");
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

  

   public void testSubscriptionsCount() throws Exception
   {
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicSubscriptionsCount");
     
      TopicConnection conn = null;
           
      try
      {
         Topic topic = (Topic)ic.lookup("/topic/TopicSubscriptionsCount");
  
         conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

         // Create 2 durable subscription and 4 non-durable subscription
         s.createDurableSubscriber(topic, "SubscriberA");
         s.createDurableSubscriber(topic, "SubscriberB");
        
         s.createSubscriber(topic);
         s.createSubscriber(topic);
         s.createSubscriber(topic);
         s.createSubscriber(topic);
  
         // There should be 6 subscriptions
         ObjectName destObjectName =
            new ObjectName("jboss.messaging.destination:service=Topic,name=TopicSubscriptionsCount");
        
         Integer count = (Integer)ServerManagement.getAttribute(destObjectName, "AllSubscriptionsCount");
         assertEquals(6, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "DurableSubscriptionsCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "NonDurableSubscriptionsCount");
         assertEquals(4, count.intValue());
        
               
         // Now disconnect
         conn.close();
        
         // Only the durable should survive
         count = (Integer)ServerManagement.getAttribute(destObjectName, "AllSubscriptionsCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "DurableSubscriptionsCount");
         assertEquals(2, count.intValue());
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "NonDurableSubscriptionsCount");
         assertEquals(0, count.intValue());
        
        
         // Now connect again and restore the durable subscription
         conn = cf.createTopicConnection();
         conn.setClientID("Client1");
         s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         s.createDurableSubscriber(topic, "SubscriberA");
        
         count = (Integer)ServerManagement.getAttribute(destObjectName, "AllSubscriptionsCount");
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

  
   public void testListSubscriptions() throws Exception
   {
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicSubscriptionList");
      Topic topic = (Topic)ic.lookup("/topic/TopicSubscriptionList");

      TopicConnection conn = null;
     
      try
      {
         conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

  

   public void testListSubscriptionsAsHTML() throws Exception
   {
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicSubscriptionList");
      Topic topic = (Topic)ic.lookup("/topic/TopicSubscriptionList");

      TopicConnection conn = null;
     
      try
      {
         conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

  
 
   public void testListMessages() throws Exception
   {  
      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
      TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
      ServerManagement.deployTopic("TopicMessageList");
     
      TopicConnection conn = null;
     
      try
      {
         Topic topic = (Topic)ic.lookup("/topic/TopicMessageList");
  
         conn = cf.createTopicConnection();
  
         conn.setClientID("Client1");
  
         TopicSession s = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer prod = s.createProducer(topic);
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

   }
  
   public void testTopicConnectionConsumerWrongTemporaryDestination() throws Exception
   {
      InitialContext ctx = getInitialContext();
      TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
      Topic topic = null;
      TopicConnection connection = factory.createTopicConnection();
      try
      {
         TopicSession s = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         topic = s.createTemporaryTopic();
         TopicConnection connection2 = factory.createTopicConnection();
         try
         {
            connection2.createConnectionConsumer(topic, "", MockServerSessionPool.getServerSessionPool(), 1);
            fail("Expected an error listening to a temporary destination from a different connection");
         }
View Full Code Here

Examples of javax.jms.TopicConnectionFactory

      assertNotNull(topic);

      // Subscribe to a topic and validate the subscription shows up in the list op
      InitialContext ctx = super.getInitialContext();
      Topic topicDest = (Topic) ctx.lookup("testCreateTopic");
      TopicConnectionFactory tcf = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
      TopicConnection tc = tcf.createTopicConnection();
      tc.start();
      TopicSession ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageConsumer mc = ts.createConsumer(topicDest);
      MessageProducer mp = ts.createProducer(topicDest);
      Message helloMsg = ts.createTextMessage("Hello from testCreateTopic");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.