Package javax.jms

Examples of javax.jms.JMSConsumer


                for (int i = 0; i < count; i++) {
                    context.createProducer().send(destination, content);
                }

                // Create the JMS consumer
                JMSConsumer consumer = context.createConsumer(destination);
                // Then receive the same number of messages that were sent
                for (int i = 0; i < count; i++) {
                    String text = consumer.receiveBody(String.class, 5000);
                    log.info("Received message with content " + text);
                }
            }
        } catch (NamingException e) {
            log.severe(e.getMessage());
View Full Code Here


        int numMessages = 10;
        launcher.start(numThreads, numMessages);

        int receivedMessages = 0;
        try(JMSContext context = factory.createContext()) {
            JMSConsumer consumer = context.createConsumer(queue);
            Message m;
            do {
                m = consumer.receive(1000);
                if (m != null) {
                    receivedMessages++;
                }
            }
            while (m != null);
View Full Code Here

        assertNotNull(factory4);
        assertNotNull(factory5);
        assertNotNull(factory6);

        JMSContext context = factory3.createContext("guest", "guest", AUTO_ACKNOWLEDGE);
        JMSConsumer consumer = context.createConsumer(queue4);
        assertNotNull(consumer);
        consumer.close();
    }
View Full Code Here

            TemporaryQueue tempQueue = context.createTemporaryQueue();

            producerBean.sendToDestination(tempQueue, text);

            JMSConsumer consumer = context.createConsumer(tempQueue);
            String reply = consumer.receiveBody(String.class, adjust(2000));
            assertEquals(text, reply);
        }
    }
View Full Code Here

    }

    private String sendAndReceiveMessage(Destination destination, String text) {
            Destination replyTo = context.createTemporaryQueue();

            JMSConsumer consumer = context.createConsumer(replyTo);

            context.createProducer()
                    .setJMSReplyTo(replyTo)
                    .send(destination, text);

            return consumer.receiveBody(String.class, 5000);
    }
View Full Code Here

    @After
    public void tearDown() throws JMSException {
        // drain the queue to remove any pending messages from it
        try(JMSContext context = factory.createContext()) {
            JMSConsumer consumer = context.createConsumer(queue);
            Message m;
            do {
                m = consumer.receiveNoWait();
            }
            while (m != null);
        }
    }
View Full Code Here

     * wouldn't miss any message
     */
    @PostConstruct
    void createSubscription() {
        try (JMSContext jms = factory.createContext()) { // <1> This is factory with clientId specified
            JMSConsumer consumer = jms.createDurableConsumer(topic, Resources.SUBSCRIPTION); // <2> creates durable subscription on the topic
            consumer.close();
        }
    }
View Full Code Here

TOP

Related Classes of javax.jms.JMSConsumer

Copyright © 2018 www.massapicom. 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.