當前位置: 首頁>>代碼示例>>Java>>正文


Java Session.createTemporaryTopic方法代碼示例

本文整理匯總了Java中javax.jms.Session.createTemporaryTopic方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.createTemporaryTopic方法的具體用法?Java Session.createTemporaryTopic怎麽用?Java Session.createTemporaryTopic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.Session的用法示例。


在下文中一共展示了Session.createTemporaryTopic方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testNoTemporaryTopicLeaksAfterConnectionClose

import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testNoTemporaryTopicLeaksAfterConnectionClose() throws Exception {
    JmsPoolConnection connection = null;
    MockJMSConnection pooledConnection = null;

    Session session = null;
    Topic tempTopic = null;

    for (int i = 0; i < 10; i++) {
        connection = (JmsPoolConnection) cf.createConnection();
        pooledConnection = (MockJMSConnection) connection.getConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        tempTopic = session.createTemporaryTopic();
        LOG.info("Created queue named: " + tempTopic.getTopicName());
        connection.close();
        assertEquals(0, pooledConnection.getConnectionStats().getActiveTemporaryTopicCount());
    }

    assertEquals(10, pooledConnection.getConnectionStats().getTotalTemporaryTopicsCreated());
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:21,代碼來源:JmsPoolConnectionTemporaryDestinationTest.java

示例2: testCreateTemporaryTopic

import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testCreateTemporaryTopic() throws Exception {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    TemporaryTopic topic = session.createTemporaryTopic();
    assertNotNull(topic);
    assertTrue(topic instanceof MockJMSTemporaryTopic);
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:9,代碼來源:JmsPoolSessionTest.java

示例3: testTemporaryTopicLeakAfterConnectionClose

import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testTemporaryTopicLeakAfterConnectionClose() throws Exception {
    Connection pooledConnection = null;
    Session session = null;
    Topic tempTopic = null;
    for (int i = 0; i < 2; i++) {
        pooledConnection = pooledFactory.createConnection();
        session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        tempTopic = session.createTemporaryTopic();
        LOG.info("Created topic named: " + tempTopic.getTopicName());
        pooledConnection.close();
    }

    assertEquals(0, countBrokerTemporaryTopics());
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:16,代碼來源:PooledConnectionFactoryWithTemporaryDestinationsTest.java

示例4: testConnectionDeletesOnlyItsOwnTempTopicsOnClose

import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testConnectionDeletesOnlyItsOwnTempTopicsOnClose() throws JMSException {
    JmsPoolConnection connection1 = (JmsPoolConnection) cf.createConnection();
    JmsPoolConnection connection2 = (JmsPoolConnection) cf.createConnection();

    assertSame(connection1.getConnection(), connection2.getConnection());

    final Set<TemporaryTopic> deleted = new HashSet<>();

    MockJMSConnection mockConnection = (MockJMSConnection) connection1.getConnection();
    mockConnection.addConnectionListener(new MockJMSDefaultConnectionListener() {

        @Override
        public void onDeleteTemporaryTopic(MockJMSTemporaryTopic queue) throws JMSException {
            deleted.add(queue);
        }
    });

    Session session1 = connection1.createSession();
    Session session2 = connection2.createSession();

    TemporaryTopic tempTopic1 = session1.createTemporaryTopic();
    TemporaryTopic tempTopic2 = session1.createTemporaryTopic();

    TemporaryTopic tempTopic3 = session2.createTemporaryTopic();
    TemporaryTopic tempTopic4 = session2.createTemporaryTopic();

    connection1.close();

    assertEquals(2, deleted.size());
    assertTrue(deleted.contains(tempTopic1));
    assertTrue(deleted.contains(tempTopic2));
    assertFalse(deleted.contains(tempTopic3));
    assertFalse(deleted.contains(tempTopic4));

    connection2.close();
    assertEquals(4, deleted.size());
    assertTrue(deleted.contains(tempTopic1));
    assertTrue(deleted.contains(tempTopic2));
    assertTrue(deleted.contains(tempTopic3));
    assertTrue(deleted.contains(tempTopic4));
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:43,代碼來源:JmsPoolConnectionTest.java


注:本文中的javax.jms.Session.createTemporaryTopic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。