9 Nisan 2018 Pazartesi

Java - AQjmsTopicPublisher Arayüzü

constructor
Şöyle yaparız.
Connection con = ...;
TopicConnection tc_conn =AQjmsTopicConnectionFactory.createTopicConnection(con);
tc_conn.start();
TopicSession jms_sess = tc_conn.createTopicSession(true, Session.SESSION_TRANSACTED);
Topic queueTopic= ((AQjmsSession )jms_sess).getTopic("JMSUSER","AQ_QUEUE5");
AQjmsTopicPublisher publisherAq = (AQjmsTopicPublisher)jms_sess.
  .createPublisher(queueTopic);
publish metodu - BytesMessage 
Şöyle yaparız.
BytesMessage messAll = jms_sess.createBytesMessage();
messAll.writeUTF("Message for all subscribers");
publisherAq.publish(messAll);

con.commit();
tc_conn.close();
con.close();         
publish metodu - BytesMessage + AQjmsAgent
Şöyle yaparız.
BytesMessage messOnlyForGreen = jms_sess.createBytesMessage();
messOnlyForGreen.writeUTF("Message only for green");

publisherAq.publish(messOnlyForGreen, new AQjmsAgent[]{new AQjmsAgent("GREEN", null)} );
con.commit();
tc_conn.close();
con.close();             

Hiç yorum yok:

Yorum Gönder