Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange


        }
        update();
    }

    public void fault(String content) throws Exception {
        MessageExchange me = this.exchange.getInternalExchange();
        if (me instanceof InOnly) {
            me.setError(new Exception(content));
            getChannel().send(me);
        } else {
            Fault fault = me.createFault();
            fault.setContent(new StringSource(content));
            me.setFault(fault);
            getChannel().sendSync(me);
        }
        update();
    }
View Full Code Here


public class SerializedMarshaler extends DefaultHttpConsumerMarshaler {

    private static Log log = LogFactory.getLog(SerializedMarshaler.class);

    public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
        MessageExchange me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
        NormalizedMessage in = me.createMessage();
        in.setContent(marshal(request.getInputStream()));
        me.setMessage(in, "in");
        return me;
    }
View Full Code Here

        }
        update();
    }

    public void answer(String content) throws Exception {
        MessageExchange me = this.exchange.getInternalExchange();
        NormalizedMessage out = me.createMessage();
        out.setContent(new StringSource(content));
        me.setMessage(out, "out");
        getChannel().sendSync(me);
        update();
    }
View Full Code Here

                } else if (context.getExchange().getOperation().getFaults().size() > 0) {
                    mep = MessageExchangeSupport.ROBUST_IN_ONLY;
                } else {
                    mep = MessageExchangeSupport.IN_ONLY;
                }
                MessageExchange me = factory.createExchange(mep);
                me.setInterfaceName((QName) context.getService().getProperty(JBI_INTERFACE_NAME));
                me.setOperation(context.getExchange().getOperation().getQName());
                me.setService((QName) context.getService().getProperty(JBI_SERVICE_NAME));
                me.setEndpoint((ServiceEndpoint) context.getService().getProperty(JBI_ENDPOINT));
                NormalizedMessage msg = me.createMessage();
                me.setMessage(msg, "in");
                if (Boolean.TRUE.equals(context.getService().getProperty(JBI_SECURITY_PROPAGATATION))) {
                    MessageExchange oldMe = JBIContext.getMessageExchange();
                    NormalizedMessage oldMsg = (oldMe != null) ? oldMe.getMessage("in") : null;
                    if (oldMsg != null) {
                        msg.setSecuritySubject(oldMsg.getSecuritySubject());
                    }
                }
                msg.setContent(getContent(context, message));
View Full Code Here

    private DeliveryChannel channel;

    public void onMessageExchange(MessageExchange exchange) throws MessagingException {
        if (exchange.getRole() == MessageExchange.Role.CONSUMER) {
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
                MessageUtil.transferOutToOut(exchange, io);
                io.setProperty("exchange", exchange);
                channel.send(io);
            } else if (exchange.getStatus() == ExchangeStatus.DONE) {
                MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
                io.setStatus(ExchangeStatus.DONE);
                channel.send(io);
            }
        } else {
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                MessageExchangeFactory factory = channel.createExchangeFactory();
                InOut io = factory.createInOutExchange();
                MessageUtil.transferInToIn(exchange, io);
                io.setService(new QName("echo"));
                io.setProperty("exchange", exchange);
                channel.send(io);
            } else if (exchange.getStatus() == ExchangeStatus.DONE) {
                // Do nothing
            }
        }
View Full Code Here

        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        PlainBean bean = (PlainBean) getBean("plainBean");
        MessageExchange answer = bean.getFoo();

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

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

        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        PlainBean bean = (PlainBean) getBean("plainBean");
        MessageExchange bar = bean.getBar();
        log.info("Bean's bar() method has been invoked: " + bar);

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

public class BPESpringComponentTest extends SpringTestSupport {
    private static transient Log log = LogFactory.getLog(BPESpringComponentTest.class);

    public void test() throws Exception {
        ServiceMixClient client = new DefaultServiceMixClient(jbi);
        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>1234341</ssn>"
                                + "<amount>100000.0</amount><duration>12</duration></getLoanQuoteRequest>"));
        long t0 = System.currentTimeMillis();
        client.sendSync(me);
        long t1 = System.currentTimeMillis();
        if (me.getError() != null) {
            throw me.getError();
        }
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        String out = new SourceTransformer().contentToString(me.getMessage("out"));
        log.info(out);
        log.info("Time: " + (t1 - t0));
        client.done(me);
    }
View Full Code Here

        bpe.getServiceUnitManager().start("loanbroker");

        //
        // Message for bank1 and bank2
        //
        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>1234341</ssn><amount>100000.0</amount><duration>12</duration>"
                                + "</getLoanQuoteRequest>"));
        long t0 = System.currentTimeMillis();
        client.sendSync(me);
        long t1 = System.currentTimeMillis();
        if (me.getError() != null) {
            throw me.getError();
        }
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        String out = new SourceTransformer().contentToString(me.getMessage("out"));
        log.info(out);
        log.info("Time: " + (t1 - t0));
        client.done(me);

        //
        // Message for bank3 and bank4
        //
        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>1234341</ssn><amount>50000.0</amount><duration>12</duration>"
                                + "</getLoanQuoteRequest>"));
        t0 = System.currentTimeMillis();
        client.sendSync(me);
        t1 = System.currentTimeMillis();
        if (me.getError() != null) {
            throw me.getError();
        }
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        out = new SourceTransformer().contentToString(me.getMessage("out"));
        log.info(out);
        log.info("Time: " + (t1 - t0));
        client.done(me);

        //
        // Message for bank5
        //
        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>1234341</ssn><amount>1200.0</amount><duration>12</duration>"
                                + "</getLoanQuoteRequest>"));
        t0 = System.currentTimeMillis();
        client.sendSync(me);
        t1 = System.currentTimeMillis();
        if (me.getError() != null) {
            throw me.getError();
        }
        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
        out = new SourceTransformer().contentToString(me.getMessage("out"));
        log.info(out);
        log.info("Time: " + (t1 - t0));
        client.done(me);
    }
View Full Code Here

    /**
     * Cancel all pending exchanges currently being handled by the DeliveryChannel
     */
    public void cancelPendingExchanges() {
        for (String id : exchangesById.keySet()) {
            MessageExchange exchange = exchangesById.get(id);
            synchronized (exchange) {
                exchange.notifyAll();  
            }
        }
    }
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.