Examples of TopicSubscriber


Examples of javax.jms.TopicSubscriber

        Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        AMQTopic topic = new AMQTopic((AMQConnection) conn, "testResubscribeWithChangedSelector");
        MessageProducer producer = session.createProducer(topic);
       
        // Create durable subscriber that matches A
        TopicSubscriber subA = session.createDurableSubscriber(topic,
                "testResubscribeWithChangedSelector",
                "Match = True", false);

        // Send 1 matching message and 1 non-matching message
        sendMatchingAndNonMatchingMessage(session, producer);

        Message rMsg = subA.receive(NEGATIVE_RECEIVE_TIMEOUT);
        assertNotNull(rMsg);
        assertEquals("Content was wrong",
                     "testResubscribeWithChangedSelector1",
                     ((TextMessage) rMsg).getText());
       
        rMsg = subA.receive(NEGATIVE_RECEIVE_TIMEOUT);
        assertNull(rMsg);
       
        // Disconnect subscriber
        subA.close();
       
        // Reconnect with new selector that matches B
        TopicSubscriber subB = session.createDurableSubscriber(topic,
                "testResubscribeWithChangedSelector","Match = False", false);

        //verify no messages are now recieved.
        rMsg = subB.receive(NEGATIVE_RECEIVE_TIMEOUT);
        assertNull("Should not have received message as the selector was changed", rMsg);

        // Check that new messages are received properly
        sendMatchingAndNonMatchingMessage(session, producer);
        rMsg = subB.receive(POSITIVE_RECEIVE_TIMEOUT);

        assertNotNull("Message should have been received", rMsg);
        assertEquals("Content was wrong",
                     "testResubscribeWithChangedSelector2",
                     ((TextMessage) rMsg).getText());
       
       
        rMsg = subB.receive(NEGATIVE_RECEIVE_TIMEOUT);
        assertNull("Message should not have been received",rMsg);
        session.unsubscribe("testResubscribeWithChangedSelector");
    }
View Full Code Here

Examples of org.apache.hedwig.client.data.TopicSubscriber

    public void consume(ByteString topic, ByteString subscriberId, MessageSeqId messageSeqId)
            throws ClientNotSubscribedException {
        if (logger.isDebugEnabled())
            logger.debug("Calling consume for topic: " + topic.toStringUtf8() + ", subscriberId: "
                         + subscriberId.toStringUtf8() + ", messageSeqId: " + messageSeqId);
        TopicSubscriber topicSubscriber = new TopicSubscriber(topic, subscriberId);
        // Check that this topic subscription on the client side exists.
        if (!topicSubscriber2Channel.containsKey(topicSubscriber)) {
            throw new ClientNotSubscribedException(
                "Cannot send consume message since client is not subscribed to topic: " + topic.toStringUtf8()
                + ", subscriberId: " + subscriberId.toStringUtf8());
View Full Code Here

Examples of org.apache.stratos.messaging.broker.subscribe.TopicSubscriber

    protected void activate(ComponentContext context) {
        try {
                
            // Start instance status event message listener
            TopicSubscriber subscriber = new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC);
            subscriber.setMessageListener(new InstanceStatusEventMessageListener());
            Thread tsubscriber = new Thread(subscriber);
            tsubscriber.start();

            // Start instance status message delegator
            InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.