Package javax.jbi.messaging

Examples of javax.jbi.messaging.NormalizedMessage


        // Wait for notification
        Thread.sleep(150);

        receiver.getMessageList().assertMessagesReceived(1);
        NormalizedMessage msg = (NormalizedMessage) receiver.getMessageList().getMessages().get(0);
        Node node = new SourceTransformer().toDOMNode(msg);
        assertEquals("hello", node.getLocalName());

        // Wait for acks to be processed
        Thread.sleep(150);
View Full Code Here


        sendExchange("<foo bar='123'/>");
        MessageList list = receiverComponent.getMessageList();

        list.assertMessagesReceived(1);
        List messages = list.getMessages();
        NormalizedMessage message = (NormalizedMessage) messages.get(0);
        assertNotNull("null message!", message);
        log.info("Received: " + message);

        assertEquals("cheese header", 123, message.getProperty("cheese"));
    }
View Full Code Here

        // Create exchange for target
        MessageExchange tme = getExchangeFactory().createExchange(exchange.getPattern());
        // Now copy input to new exchange
        // We need to read the message once for finding routing target
        // so ensure we have a re-readable source
        NormalizedMessage in = MessageUtil.copyIn(exchange);
        MessageUtil.transferToIn(in, tme);
        // Retrieve target
        ExchangeTarget target = getDestination(tme);
        target.configureTarget(tme, getContext());
        // Send in to target
        sendSync(tme);
        // Send back the result
        if (tme.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else if (tme.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, tme.getError());
        } else if (tme.getFault() != null) {
            Fault fault = MessageUtil.copyFault(tme);
            done(tme);
            MessageUtil.transferToFault(fault, exchange);
            sendSync(exchange);
        } else if (tme.getMessage("out") != null) {
            NormalizedMessage out = MessageUtil.copyOut(tme);
            done(tme);
            MessageUtil.transferToOut(out, exchange);
            sendSync(exchange);
        } else {
            done(tme);
View Full Code Here

            // Put exchange to store
            store.store(exchange.getExchangeId(), exchange);
            // Now copy input to new exchange
            // We need to read the message once for finding routing target
            // so ensure we have a re-readable source
            NormalizedMessage in = MessageUtil.copyIn(exchange);
            MessageUtil.transferToIn(in, tme);
            // Retrieve target
            ExchangeTarget target = getDestination(tme);
            target.configureTarget(tme, getContext());
            // Send in to target
View Full Code Here

        try {
           
            // here use client api to test the injected context to invoke another endpoint
            ServiceMixClient client = new ServiceMixClientFacade(this.context);
            InOut exchange = client.createInOutExchange();
            NormalizedMessage message = exchange.getInMessage();
           
            message.setContent(new StringSource(
                    "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
                    + "  <part>"
                    + "    <add xmlns='http://apache.org/cxf/calculator/types'>"
                    + "      <arg0>1</arg0>"
                    + "      <arg1>2</arg1>"
View Full Code Here

                    String wsaAddress = getService().getNamespaceURI() + "/" + getService().getLocalPart() + "/"
                            + subscriptionEndpoint;
                    response.setSubscriptionReference(AbstractWSAClient.createWSA(wsaAddress));
                    StringWriter writer = new StringWriter();
                    jaxbContext.createMarshaller().marshal(response, writer);
                    NormalizedMessage out = exchange.createMessage();
                    out.setContent(new StringSource(writer.toString()));
                    exchange.setMessage(out, "out");
                    send(exchange);
                } else if (input instanceof Unsubscribe) {
                    subscription = null;
                    UnsubscribeResponse response = new UnsubscribeResponse();
                    StringWriter writer = new StringWriter();
                    jaxbContext.createMarshaller().marshal(response, writer);
                    NormalizedMessage out = exchange.createMessage();
                    out.setContent(new StringSource(writer.toString()));
                    exchange.setMessage(out, "out");
                    send(exchange);
                } else {
                    throw new Exception("Unkown request");
                }
View Full Code Here

        // lets send a request to be written to a file
        // which should then be polled
        for (int i = 0; i < NUMBER; i++) {
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("urn:test", "service"));
            NormalizedMessage message = me.getInMessage();
            message.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test" + i + ".xml");
            message.setContent(new StringSource("<hello>world</hello>"));
            client.sendSync(me);
        }

        Receiver receiver = (Receiver) getBean("receiver");
        receiver.getMessageList().assertMessagesReceived(NUMBER);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.servicemix.components.eip.RoutingRule#matches(javax.jbi.messaging.MessageExchange)
     */
    public boolean matches(MessageExchange exchange) {
        try {
            NormalizedMessage in = exchange.getMessage("in");
            Boolean match = (Boolean) evaluate(exchange, in);
            return Boolean.TRUE.equals(match);
        } catch (Exception e) {
            LOG.warn("Could not evaluate xpath expression", e);
            return false;
View Full Code Here

            done(exchange);
        }
    }
   
    private void processProvider(MessageExchange exchange) throws Exception {
        NormalizedMessage in = MessageUtil.copyIn(exchange);
        final String correlationId = getCorrelationID(exchange, in);
        if (correlationId == null || correlationId.length() == 0) {
            throw new IllegalArgumentException("Could not retrieve correlation id for incoming exchange");
        }
        // Load existing aggregation
View Full Code Here

    protected void sendAggregate(String correlationId,
                                 Object aggregation,
                                 boolean timeout) throws Exception {
        InOnly me = getExchangeFactory().createInOnlyExchange();
        target.configureTarget(me, getContext());
        NormalizedMessage nm = me.createMessage();
        me.setInMessage(nm);
        buildAggregate(aggregation, nm, me, timeout);
        closeAggregation(correlationId);
        if (isSynchronous()) {
            sendSync(me);
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.NormalizedMessage

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.