Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange$Role


        if (!(exchange instanceof InOnly)
            && !(exchange instanceof RobustInOnly)) {
            fail(exchange, new UnsupportedOperationException("Use an InOnly or RobustInOnly MEP"));
        } else {
            NormalizedMessage in = MessageUtil.copyIn(exchange);
            MessageExchange me = getExchangeFactory().createExchange(exchange.getPattern());
            target.configureTarget(me, getContext());
            MessageUtil.transferToIn(in, me);
            if (filter.matches(me)) {
                sendSync(me);
                if (me.getStatus() == ExchangeStatus.ERROR && reportErrors) {
                    fail(exchange, me.getError());
                } else if (me.getStatus() == ExchangeStatus.DONE) {
                    done(exchange);
                } else if (me.getFault() != null && reportErrors) {
                    Fault fault = MessageUtil.copyFault(me);
                    done(me);
                    MessageUtil.transferToFault(fault, exchange);
                    sendSync(exchange);
                }
View Full Code Here


                fail(exchange, new UnsupportedOperationException("Use an InOnly or RobustInOnly MEP"));
            } else if (exchange.getFault() != null) {
                done(exchange);
            } else {
                NormalizedMessage in = MessageUtil.copyIn(exchange);
                MessageExchange me = getExchangeFactory().createExchange(exchange.getPattern());
                target.configureTarget(me, getContext());
                MessageUtil.transferToIn(in, me);
                if (filter.matches(me)) {
                    send(me);
                }
View Full Code Here

   
    protected MessageExchange toNMS(Message message, Context ctx) throws Exception {
        SoapMessage soap = endpoint.getMarshaler().toSOAP(message);
        ctx.setInMessage(soap);
        ctx.setProperty(Message.class.getName(), message);
        MessageExchange exchange = soapHelper.onReceive(ctx);
        // TODO: copy protocol messages
        //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
        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 (!(exchange instanceof InOnly)) {
                throw new UnsupportedOperationException("JCA consumer endpoints can only use InOnly MEP");
            }
            exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, transactionManager.getTransaction());
            pendingMessages.put(exchange.getExchangeId(), context);
            if (endpoint.isSynchronous()) {
                channel.sendSync(exchange);
                process(exchange);
            } else {
                BaseLifeCycle lf = (BaseLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle();
View Full Code Here

        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        ListenerBean bean = (ListenerBean) getBean("listenerBean");
        MessageExchange answer = bean.getLastExchange();

        log.info("Bean's process() method has been invoked: " + answer);

        assertNotNull("Bean's process() method should bave been invoked", answer);
    }
View Full Code Here

        client.done(exchange);

        assertExchangeWorked(exchange);

        ListenerBean bean = (ListenerBean) getBean("listenerBean");
        MessageExchange answer = bean.getLastExchange();

        log.info("Bean's process() method has been invoked: " + answer);

        assertNotNull("Bean's process() method should bave been invoked", answer);
    }
View Full Code Here

        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
        bpe.getServiceUnitManager().start("loanbroker");

        MessageExchange me = client.createInOutExchange();
        me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
        me.setOperation(new QName("getLoanQuote"));
        me.getMessage("in").setContent(new StringSource(
                                "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
                                + "<ssn>234341</ssn></getLoanQuoteRequest>"));
        client.sendSync(me);
        if (me.getError() != null) {
            throw me.getError();
        }
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        assertNotNull(me.getFault());
        client.done(me);
    }
View Full Code Here

        File path = new File(new URI(url.toString()));
        path = path.getParentFile();
        bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
        bpe.getServiceUnitManager().start("loanbroker");

        MessageExchange me = client.createInOutExchange();
        me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
        me.setOperation(new QName("getLoanQuote"));
        me.getMessage("in").setContent(new StringSource(
                                "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
                                + "<ssn></ssn></getLoanQuoteRequest>"));
        client.sendSync(me);
        assertEquals(ExchangeStatus.ERROR, me.getStatus());
        assertNotNull(me.getError());
    }
View Full Code Here

            BPEEndpoint endpoint = BPEEndpoint.getCurrent();
            BPEComponent component = (BPEComponent) endpoint.getServiceUnit().getComponent();
            DeliveryChannel channel = ((BPELifeCycle) component.getLifeCycle()).getContext().getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            // TODO: need to configure mep
            MessageExchange me = factory.createExchange(this.mep);
            me.setInterfaceName(interfaceName);
            me.setService(serviceName);
            if (endpointName != null) {
                ServiceEndpoint ep = component.getComponentContext().getEndpoint(serviceName, endpointName);
                me.setEndpoint(ep);
            }
            // TODO: set endpoint
            me.setOperation(operationName);
            NormalizedMessage nm = me.createMessage();
            me.setMessage(nm, "in");
            nm.setContent(inputSource);
            boolean res = channel.sendSync(me);
            if (!res) {
                throw new ActionSystemException("Timeout on sending message");
            }
            if (me.getStatus() == ExchangeStatus.ACTIVE) {
                if (me.getFault() != null) {
                    Document fault;
                    try {
                        fault = transformer.toDOMDocument(me.getFault());
                        me.setStatus(ExchangeStatus.DONE);
                    } catch (Exception e) {
                        me.setError(e);
                        throw new ActionSystemException(e);
                    } finally {
                        channel.send(me);
                    }
                    Element e = fault.getDocumentElement();
                    // Try to determine fault name
                    String faultName = e.getLocalName();
                    String partName = BPEComponent.PART_PAYLOAD;
                    QName elemName = new QName(e.getNamespaceURI(), e.getLocalName());
                    if (wsdlOperation != null) {
                        for (Iterator itFault = wsdlOperation.getFaults().values().iterator(); itFault.hasNext();) {
                            Fault f = (Fault) itFault.next();
                            Part p = (Part) f.getMessage().getParts().values().iterator().next();
                            if (elemName.equals(p.getTypeName())) {
                                faultName = f.getName();
                                partName = p.getName();
                            }
                        }
                    }
                    BPRuntimeException bpre = new BPRuntimeException(faultName, "");
                    bpre.setNameSpace(e.getNamespaceURI());
                    /* We must use a type that implements BPE's IFormattableValue interface
                     * since otherwise the value will get wrapped in a CannedFormattableValue
                     * which has undesireable side effects. 
                     */
                    DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(fault);
                    bpre.addPartMessage(partName, documentFormattableValue);
                    throw bpre;
                } else {
                    try {
                        nm = me.getMessage("out");
                        if (nm != null) {
                            /* We must use a type that implements BPE's IFormattableValue interface
                             * since otherwise the value will get wrapped in a CannedFormattableValue
                             * which has undesireable side effects. 
                             */
                            Document out = transformer.toDOMDocument(nm);
                            DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(out);
                            output.put(outputPartName, documentFormattableValue);
                        }
                        me.setStatus(ExchangeStatus.DONE);
                    } catch (Exception e) {
                        me.setError(e);
                        throw new ActionSystemException(e);
                    } finally {
                        channel.send(me);
                    }
                }
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                // Extract error
                Exception error = me.getError();
                throw new BPRuntimeException("Unknown", error);
            }
        } catch (MessagingException e) {
            throw new ActionSystemException(e);
        }
View Full Code Here

        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        AnnotatedBean bean = (AnnotatedBean) getBean("annotatedBean");
        MessageExchange answer = bean.getMyExchangeMethod();

        log.info("Bean's myExchangeMethod() method has been invoked: " + answer);

        assertNotNull("Bean's myExchangeMethod() method should bave been invoked", answer);
    }
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.MessageExchange$Role

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.