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


Java Session.createDurableSubscriber方法代碼示例

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


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

示例1: createTopicConsumer

import javax.jms.Session; //導入方法依賴的package包/類
public MessageConsumer createTopicConsumer(String selector) throws JMSException {
	if (isQueue) {
		throw new IllegalArgumentException("Only for topic, not queue");
	}
	String consumerId = "consumer-" + UUID.randomUUID();
	topicConnection = startConnection(consumerId);
	Session session = topicConnection.createSession(isTransacted, Session.AUTO_ACKNOWLEDGE);
	Topic topic = session.createTopic(destinationName);
	if (isDurable) {
		if (selector != null) {
			return session.createDurableSubscriber(topic, consumerId, selector, true);
		} else {
			return session.createDurableSubscriber(topic, consumerId);
		}
	} else {
		if (selector != null) {
			return session.createConsumer(topic, selector);
		} else {
			return session.createConsumer(topic);
		}
	}
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:23,代碼來源:JmsClient.java

示例2: createConnectionAndReceiveMessage

import javax.jms.Session; //導入方法依賴的package包/類
public void createConnectionAndReceiveMessage(String clientId, String ipAddress) throws JMSException {
	Connection connection = connectionFactory.createConnection();
	connection.setClientID(clientId);
	connection.start();
	Session session = connection.createSession(false, AUTO_ACKNOWLEDGE);

	String selector = "s_id = 'Sample'";
	logger.info("selector : '" + selector + "'....");
	TopicSubscriber consumer = session.createDurableSubscriber(topic, "Sub1", selector, true);

	consumer.setMessageListener(topicMessageListener);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:13,代碼來源:Subscriber.java


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