Package javax.jms

Examples of javax.jms.MessageListener


    public void startConsumerMonitor() throws JMSException {
        Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic broadcastTopic = broadcastSession.createTopic(getBroadcastDestinationName());
        Topic advisoryTopic = AdvisorySupport.getConsumerAdvisoryTopic((ActiveMQDestination) broadcastTopic);
        monitorMessageConsumer = broadcastSession.createConsumer(advisoryTopic);
        monitorMessageConsumer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                onConsumerMonitorMessage(message);
            }
        });
    }
View Full Code Here


            super.start();
            try {
                Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                Topic broadcastTopic = broadcastSession.createTopic(broadcastDestinationName);
                broadcastConsumer = broadcastSession.createConsumer(broadcastTopic, null, true);
                broadcastConsumer.setMessageListener(new MessageListener() {
                    public void onMessage(Message message) {
                        try {
                            Object obj = ((ObjectMessage) message).getObject();
                            if (obj instanceof EndpointEvent) {
                                EndpointEvent event = (EndpointEvent) obj;
View Full Code Here

    public void start() throws JBIException {
        if (started.compareAndSet(false, true)) {
            super.start();
            try {
                // Inbound broadcast
                MessageListener listener = new MessageListener() {
                    public void onMessage(Message message) {
                        try {
                            Object obj = ((ObjectMessage) message).getObject();
                            if (obj instanceof EndpointEvent) {
                                EndpointEvent event = (EndpointEvent) obj;
                                String container = ((InternalEndpoint) event.getEndpoint()).getComponentNameSpace().getContainerName();
                                if (!getBroker().getContainer().getName().equals(container)) {
                                    if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_REGISTERED) {
                                        onRemoteEndpointRegistered(event);
                                    } else if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED) {
                                        onRemoteEndpointUnregistered(event);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            LOGGER.error("Error processing incoming broadcast message", e);
                        }
                    }
                };
                broadcastConnector = new Connector(broadcastTopic, listener, false);
                broadcastConnector.start();

                listener = new MessageListener() {
                    public void onMessage(Message message) {
                        if (started.get()) {
                            onAdvisoryMessage(((ActiveMQMessage) message).getDataStructure());
                        }
                    }
View Full Code Here

                            consumer = _messageConsumerList.remove(0);
                            msg = consumer.receive0(0L);
                        }


                        MessageListener listener = consumer._messageListener;

                        MessageImpl message = consumer.createJMSMessage(msg, recoveredMessage);

                        if(message != null)
                        {
                            _currentConsumer = consumer;
                            _currentMessage = msg;
                            try
                            {
                                listener.onMessage(message);
                            }
                            finally
                            {
                                _currentConsumer = null;
                                _currentMessage = null;
View Full Code Here

        }
        resourceAdapter.start(bootstrapContext);
        activationSpec.setResourceAdapter(resourceAdapter);
        if (endpointFactory == null) {
            TransactionManager tm = (TransactionManager) getContext().getTransactionManager();
            endpointFactory = new SingletonEndpointFactory(new MessageListener() {
                public void onMessage(Message message) {
                    try {
                        JmsJcaConsumerEndpoint.this.onMessage(message, null);
                    } catch (JMSException e) {
                        throw new ListenerExecutionFailedException("Unable to handle message", e);
View Full Code Here

    public void startConsumerMonitor() throws JMSException {
        Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic broadcastTopic = broadcastSession.createTopic(getBroadcastDestinationName());
        Topic advisoryTopic = AdvisorySupport.getConsumerAdvisoryTopic((ActiveMQDestination) broadcastTopic);
        monitorMessageConsumer = broadcastSession.createConsumer(advisoryTopic);
        monitorMessageConsumer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                onConsumerMonitorMessage(message);
            }
        });
    }
View Full Code Here

            super.start();
            try {
                Session broadcastSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                Topic broadcastTopic = broadcastSession.createTopic(broadcastDestinationName);
                broadcastConsumer = broadcastSession.createConsumer(broadcastTopic, null, true);
                broadcastConsumer.setMessageListener(new MessageListener() {
                    public void onMessage(Message message) {
                        try {
                            Object obj = ((ObjectMessage) message).getObject();
                            if (obj instanceof EndpointEvent) {
                                EndpointEvent event = (EndpointEvent) obj;
View Full Code Here

    public void start() throws JBIException {
        if (started.compareAndSet(false, true)) {
            super.start();
            try {
                // Inbound broadcast
                MessageListener listener = new MessageListener() {
                    public void onMessage(Message message) {
                        try {
                            Object obj = ((ObjectMessage) message).getObject();
                            if (obj instanceof EndpointEvent) {
                                EndpointEvent event = (EndpointEvent) obj;
                                String container = ((InternalEndpoint) event.getEndpoint()).getComponentNameSpace().getContainerName();
                                if (!getBroker().getContainer().getName().equals(container)) {
                                    if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_REGISTERED) {
                                        onRemoteEndpointRegistered(event);
                                    } else if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED) {
                                        onRemoteEndpointUnregistered(event);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            log.error("Error processing incoming broadcast message", e);
                        }
                    }
                };
                broadcastConnector = new Connector(broadcastTopic, listener, false);
                broadcastConnector.start();

                listener = new MessageListener() {
                    public void onMessage(Message message) {
                        if (started.get()) {
                            onAdvisoryMessage(((ActiveMQMessage) message).getDataStructure());
                        }
                    }
View Full Code Here

            session.redispatch(this, unconsumedMessages);
        }
    }

    public void dispatch(MessageDispatch md) {
        MessageListener listener = this.messageListener;
        try {
            synchronized (unconsumedMessages.getMutex()) {
                if (clearDispatchList) {
                    // we are reconnecting so lets flush the in progress
                    // messages
                    clearDispatchList = false;
                    List<MessageDispatch> list = unconsumedMessages.removeAll();
                    if (!this.info.isBrowser()) {
                        for (MessageDispatch old : list) {
                            // ensure we don't filter this as a duplicate
                            session.connection.rollbackDuplicate(this, old.getMessage());
                        }
                    }
                }
                if (!unconsumedMessages.isClosed()) {
                    if (this.info.isBrowser() || !session.connection.isDuplicate(this, md.getMessage())) {
                        if (listener != null && unconsumedMessages.isRunning()) {
                            ActiveMQMessage message = createActiveMQMessage(md);
                            beforeMessageIsConsumed(md);
                            try {
                                boolean expired = message.isExpired();
                                if (!expired) {
                                    listener.onMessage(message);
                                }
                                afterMessageIsConsumed(md, expired);
                            } catch (RuntimeException e) {
                                if (session.isDupsOkAcknowledge() || session.isAutoAcknowledge()) {
                                    // Redeliver the message
View Full Code Here

     *
     * @return
     * @throws JMSException
     */
    public boolean iterate() {
        MessageListener listener = this.messageListener;
        if (listener != null) {
            MessageDispatch md = unconsumedMessages.dequeueNoWait();
            if (md != null) {
                try {
                    ActiveMQMessage message = createActiveMQMessage(md);
                    beforeMessageIsConsumed(md);
                    listener.onMessage(message);
                    afterMessageIsConsumed(md, false);
                } catch (JMSException e) {
                    session.connection.onAsyncException(e);
                }
                return true;
View Full Code Here

TOP

Related Classes of javax.jms.MessageListener

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.