Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange


                try {
                    if (log.isDebugEnabled()) {
                        log.debug("Handling jms message " + message);
                    }
                    Context context = createContext();
                    MessageExchange exchange = toNMS(message, context);
                    // TODO: copy protocol messages
                    //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
                    pendingMessages.put(exchange.getExchangeId(), context);
                    channel.send(exchange);
                } catch (Throwable e) {
                    log.error("Error while handling jms message", e);
                }
            }
View Full Code Here


        if (logger.isTraceEnabled()) {
            logger.trace("Received: " + jmsMessage);
        }
        try {
            JmsContext context = marshaler.createContext(jmsMessage);
            MessageExchange exchange = marshaler.createExchange(context, getContext());
            configureExchangeTarget(exchange);
            if (synchronous) {
                try {
                    sendSync(exchange);
                } catch (Exception e) {
                    handleException(exchange, e, session, context);
                }
                if (exchange.getStatus() != ExchangeStatus.DONE) {
                    processExchange(exchange, session, context);
                }
            } else {
                if (stateless) {
                    exchange.setProperty(PROP_JMS_CONTEXT, context);
                } else {
                    store.store(exchange.getExchangeId(), context);
                }
                boolean success = false;
                try {
                    send(exchange);
                    success = true;
                } catch (Exception e) {
                    handleException(exchange, e, session, context);
                } finally {
                    if (!success && !stateless) {
                        store.load(exchange.getExchangeId());
                    }
                }
            }
        } catch (JMSException e) {
            throw e;
View Full Code Here

        return new Context(message);
    }

    public MessageExchange createExchange(JmsContext jmsContext, ComponentContext jbiContext) throws Exception {
        Context ctx = (Context) jmsContext;
        MessageExchange exchange = jbiContext.getDeliveryChannel().createExchangeFactory().createExchange(mep);
        NormalizedMessage inMessage = exchange.createMessage();
        populateMessage(ctx.message, inMessage);
        exchange.setMessage(inMessage, "in");
        return exchange;
    }
View Full Code Here

            mep = getMep(operation);
        }
        if (mep == null) {
            mep = endpoint.getDefaultMep();
        }
        MessageExchange exchange = createExchange(mep);
        exchange.setService((QName) context.getProperty(Context.SERVICE));
        exchange.setInterfaceName((QName) context.getProperty(Context.INTERFACE));
        exchange.setOperation((QName) context.getProperty(Context.OPERATION));
        if (context.getProperty(Context.ENDPOINT) != null) {
            ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
            QName serviceName = (QName) context.getProperty(Context.SERVICE);
            String endpointName = (String) context.getProperty(Context.ENDPOINT);
            ServiceEndpoint se = componentContext.getEndpoint(serviceName, endpointName);
            if (se != null) {
                exchange.setEndpoint(se);
            }
        }
        NormalizedMessage inMessage = exchange.createMessage();
        jbiMarshaler.toNMS(inMessage, context.getInMessage());
        exchange.setMessage(inMessage, "in");
        return exchange;
    }
View Full Code Here

    protected MessageExchange createExchange(URI mep) throws MessagingException {
        ComponentContext context = endpoint.getServiceUnit().getComponent().getComponentContext();
        DeliveryChannel channel = context.getDeliveryChannel();
        MessageExchangeFactory factory = channel.createExchangeFactory();
        MessageExchange exchange = factory.createExchange(mep);
        return exchange;
    }
View Full Code Here

        try {
            if (log.isDebugEnabled()) {
                log.debug("Received jms message " + message);
            }
            Context context = createContext();
            MessageExchange exchange = toNMS(message, context);
            if (!channel.sendSync(exchange)) {
                throw new IllegalStateException("Exchange has been aborted");
            }
            MessageProducer producer = null;
            Message response = null;
            try {
                response = fromNMSResponse(exchange, context, session);
                if (response != null) {
                    producer = session.createProducer(message.getJMSReplyTo());
                    if (endpoint.isUseMsgIdInResponse()) {
                        response.setJMSCorrelationID(message.getJMSMessageID());
                    } else {
                        response.setJMSCorrelationID(message.getJMSCorrelationID());
                    }
                    producer.send(response);
                }
            } finally {
                if (producer != null) {
                    producer.close();
                }
                if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                    exchange.setStatus(ExchangeStatus.DONE);
                    channel.send(exchange);
                }
            }
        } catch (Throwable e) {
            log.error("Error while handling jms message", e);
View Full Code Here

            createEndpointStats(container, endpoint);
        }
    }

    protected void onExchangeSent(ExchangeEvent event) {
        MessageExchange me = event.getExchange();
        // This is a new exchange sent by a consumer
        if (me.getStatus() == ExchangeStatus.ACTIVE
                && me.getRole() == Role.CONSUMER
                && me.getMessage("out") == null
                && me.getFault() == null
                && me instanceof MessageExchangeImpl) {
            MessageExchangeImpl mei = (MessageExchangeImpl) me;
            String source = (String) me.getProperty(JbiConstants.SENDER_ENDPOINT);
            if (source == null) {
                source = mei.getSourceId().getName();
                ComponentStats stats = componentStats.get(source);
                stats.incrementOutbound();
            } else {
View Full Code Here

            }
        }
    }
   
    protected void onExchangeAccepted(ExchangeEvent event) {
        MessageExchange me = event.getExchange();
        // This is a new exchange sent by a consumer
        if (me.getStatus() == ExchangeStatus.ACTIVE
                && me.getRole() == Role.PROVIDER
                && me.getMessage("out") == null
                && me.getFault() == null
                && me instanceof MessageExchangeImpl) {
            String source = EndpointSupport.getUniqueKey(me.getEndpoint());
            EndpointStats stats = endpointStats.get(source);
            stats.incrementInbound();
        }       
    }
View Full Code Here

    public void run() {
        try {
            while (running) {
                DeliveryChannel deliveryChannel = context.getDeliveryChannel();
                System.out.println("about to do an accept on deliveryChannel: " + deliveryChannel);
                MessageExchange messageExchange = deliveryChannel.accept();
                System.out.println("received me: " + messageExchange);
                onMessageExchange(messageExchange);
            }
        }
        catch (MessagingException e) {
View Full Code Here

     */
    public void run() {
        try {
            DeliveryChannel deliveryChannel = getDeliveryChannel();
            while (!stop.get()) {
                MessageExchange exchange = deliveryChannel.accept();
                if (exchange != null) {
                    try {
                        onMessageExchange(exchange);
                    } catch (MessagingException e) {
                        log.error("MessageExchange processing failed", e);
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.MessageExchange

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.