createSession(paramA,paramB);
paramA 取值有 : true or false 表示是否支持事务
paramB 取值有:
Session.AUTO_ACKNOWLEDGE,Session.CLIENT_ACKNOWLEDGE,DUPS_OK_ACKNOWLEDGE,SESSION_TRANSACTED
createSession(paramA,paramB);
paramA是设置事务的,paramB设置acknowledgment mode
paramA设置为false时:paramB的值可为
Session.AUTO_ACKNOWLEDGE,Session.CLIENT_ACKNOWLEDGE,DUPS_OK_ACKNOWLEDGE其中一个。
paramA设置为true时:paramB的值忽略, acknowledgment mode被jms服务器设置为SESSION_TRANSACTED 。
Session.AUTO_ACKNOWLEDGE为自动确认,客户端发送和接收消息不需要做额外的工作。
Session.CLIENT_ACKNOWLEDGE为客户端确认。客户端接收到消息后,必须调用javax.jms.Message的acknowledge方法。jms服务器才会删除消息。
DUPS_OK_ACKNOWLEDGE允许副本的确认模式。一旦接收方应用程序的方法调用从处理消息处返回,会话对象就会确认消息的接收;而且允许重复确认。在需要考虑资源使用时,这种模式非常有效。
分享到:
相关推荐
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("testQueue"); MessageProducer producer = session.createProducer(queue); TextMessage ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); MessageProducer producer = session.createProducer(queue); TextMessage ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("HelloWorldQueue")) { MessageProducer producer = session.createProducer(queue); ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic("myTopic"); MessageProducer producer = session.createProducer(topic); TextMessage ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic1 = session.createTopic("topic1"); Topic topic2 = session.createTopic("topic2"); MessageProducer producer...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 创建目的地,这里可以是队列或主题,根据需求选择 Destination destination = session.createQueue("MailQueue"); // ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(session.createQueue("TestQueue")); TextMessage message = session....
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("MyQueue"); // 或 Topic topic = session.createTopic("MyTopic"); MessageProducer ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 获取队列目的地 Queue queue = (Queue) context.lookup("queue/testQueue"); // 创建消息生产者 MessageProducer ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 获取队列 Queue queue = (Queue) context.lookup("queueName"); // 创建消息生产者 MessageProducer producer = ...
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = session.createQueue("helloword-destination"); producer = session.createProducer(destination); ``` 最后,我们创建一个...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ``` ##### 会话(Session) `JMSSession`接口是一个单线程上下文,用于创建消息生产者、消费者以及消息本身。会话还可以提供事务...
session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { e.printStackTrace(); } } public void getMessage(String disname){ try { Queue queue = ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 创建队列 Queue queue = session.createQueue("MyQueue"); // 创建生产者 MessageProducer producer = session.createProducer...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); MessageProducer producer = session.createProducer(queue)) { TextMessage ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("MyQueue"); MessageProducer producer = session.createProducer(queue); TextMessage ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 获取或创建队列 Queue queue = session.createQueue("myQueue"); // 创建消息生产者 MessageProducer producer = session....
Queue queue = session.createQueue("exampleQueue"); // 创建Producer MessageProducer producer = session.createProducer(queue); // 创建TextMessage TextMessage message = session.createTextMessage(...
session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); // 创建主题 topic = (javax.jms.Topic) getInitialContext().lookup("InsertTopic"); // 创建消息生产者 producer = ...
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // 创建队列 Queue queue = session.createQueue("MyQueue"); // 创建生产者 MessageProducer producer = session.createProducer...