Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange


        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

        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312?code=abc");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_GET);
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "getPerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("GetPerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_POST);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "updatePerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("UpdatePerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_PUT);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "addPerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("AddPerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(e);
View Full Code Here

        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_DELETE);
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());

        assertEquals(new QName("http://example.org/Person", "deletePerson"), me.getOperation());
        Element e = DomUtil.getFirstChildElement(doc);
        assertEquals("http://example.org/Person", e.getNamespaceURI());
        assertEquals("DeletePerson", e.getLocalName());
       
        e = DomUtil.getFirstChildElement(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.