Nirmal Fernando created STRATOS-111:
---------------------------------------
Summary: Implement new messaging component for topic pub/sub
Key: STRATOS-111
URL: https://issues.apache.org/jira/browse/STRATOS-111
Project: Stratos
Issue Type: New Feature
Affects Versions: 4.0.0 M1
Reporter: Nirmal Fernando
Assignee: Nirmal Fernando
Priority: Critical
Fix For: 4.0.0 M1
This is the initial API, let's build upon this. Please fire suggestions/issues,
if you have/faced any.
Artifact Info:
<groupId>org.apache.stratos</groupId>
<artifactId>org.apache.stratos.messaging</artifactId>
<version>3.0.0-SNAPSHOT</version>
Topic Publisher API
* You should create a
org.apache.stratos.messaging.broker.publish.TopicPublisher per a topic.
TopicPublisher aPublisher = new TopicPublisher(topic);
* You can publish any Java Object via the API and underlying implementation
would convert the Java Object to JSON format using Google gson (this is to
mandate the communication of Stratos via json).
Also you can set any message header in java.util.Properties.
aPublisher.publish(msgObject, headers);
PS: I've decided against throwing an exception from this message, since I don't
think it'll be of any use to the object which uses this class. Let me know if
you think otherwise.
* You should close the publisher once its work is done:
aPublisher.close();
Note: Please try to use the same TopicPublisher instance through out the life
time of your component.
Topic Subscriber API
* Topic Subscriber is an implementation of java.lang.Runnable interface and
there should be a org.apache.stratos.messaging.broker.subscribe.TopicSubscriber
per a topic.
TopicSubscriber aSubscriber = new TopicSubscriber(topic);
* You should have a class in your component which implements
javax.jms.MessageListener in order to receive the messages published to the
subjected topic and should set it in the topic Subscriber instance.
aSubscriber.setMessageListener(new TopologyListener());
* Once the two steps mentioned above are done, you should start the Subscriber
Thread.
Thread subscriber = new Thread(aSubscriber);
subscriber.start();
Note: Topic Connectors load the jms properties from the jndi.properties file,
please read the dev@stratos thread "Making Stratos independent of underlying
message broker" for more info.
--
This message was sent by Atlassian JIRA
(v6.1#6144)