Package org.apache.servicemix.nmr.api

Examples of org.apache.servicemix.nmr.api.Channel


        eip.setEndpoints(new EIPEndpoint[] { ep });
        eip.init(new ComponentContextImpl(reg, new SimpleComponentWrapper(eip),
                                          new HashMap<String, Object>()));
        eip.getLifeCycle().start();

        Channel channel = smx.createChannel();
        Exchange e = channel.createExchange(Pattern.InOnly);
        e.getIn().setBody("<hello/>");
        e.setTarget(smx.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "{uri:foo}bar:ep")));
        channel.sendSync(e);
        if (e.getError() != null) {
            throw e.getError();
        }
        assertEquals(Status.Done, e.getStatus());
    }
View Full Code Here


        IMocksControl control = EasyMock.createControl();
        ExchangeListener listener = control.createMock(ExchangeListener.class);
        control.makeThreadSafe(true);
        nmr.getListenerRegistry().register(listener, null);

        Channel channel = nmr.createChannel();
        Exchange e = channel.createExchange(Pattern.InOnly);
        e.setTarget(nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "zz")));

        listener.exchangeSent(same(e));
        listener.exchangeFailed(same(e));

        replay(listener);

        try {
            channel.send(e);
            fail("Exepected an exception to be thrown");
        } catch (ServiceMixException t) {
            // ok
        }
View Full Code Here

        final BlockingEndpoint blocking = new BlockingEndpoint(1);
        final Map<String, Object> props = ServiceHelper.createMap(Endpoint.NAME, "blocking");
        nmr.getEndpointRegistry().register(blocking, props);

        final CountDownLatch done = new CountDownLatch(1);
        final Channel channel = nmr.createChannel();
        final Exchange exchange = channel.createExchange(Pattern.InOnly);
        exchange.setTarget(nmr.getEndpointRegistry().lookup(props));
       
        Thread thread = new Thread(new Runnable() {
            public void run() {
                channel.sendSync(exchange);
                done.countDown();
            }
        });
        thread.start();
       
View Full Code Here

        smx.init();
        nmr = smx;
    }

    protected void sendExchange(Object content) {
        Channel client = nmr.createChannel();
        Exchange exchange = client.createExchange(Pattern.InOnly);
        exchange.setTarget(client.getNMR().getEndpointRegistry().lookup(
                ServiceHelper.createMap(Endpoint.NAME, RECEIVER_ENDPOINT_NAME)));
        exchange.setProperty("prop1", "value1");
        exchange.getIn().setBody(content);
        exchange.getIn().setHeader("prop1", "value2");
        exchange.getIn().setHeader("prop2", "value3");
        client.sendSync(exchange);

    }
View Full Code Here

         *
         * @param message the message to be sent.
         */
        public void prepare(Message message) throws IOException {
            // setup the message to be send back
            Channel dc = channel;
            message.put(Exchange.class, inMessage.get(Exchange.class));
            message.setContent(OutputStream.class, new NMRDestinationOutputStream(inMessage, dc));
        }       
View Full Code Here

    }

    public void process(Exchange exchange) throws Exception {
     
      NMR nmr = getEndpoint().getComponent().getNmr();
      Channel client = nmr.createChannel();
     
        org.apache.servicemix.nmr.api.Exchange e = client.createExchange(
            Pattern.fromWsdlUri(exchange.getPattern().getWsdlUri()));
       
        try {
          e.setTarget(nmr.getEndpointRegistry().lookup(
            ServiceHelper.createMap(org.apache.servicemix.nmr.api.Endpoint.NAME,
                getEndpoint().getEndpointName())));
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        e.getIn().setBody(exchange.getIn().getBody());
        e.getIn().setHeader(CxfConstants.OPERATION_NAME,
            exchange.getIn().getHeader(CxfConstants.OPERATION_NAME));
               
        client.sendSync(e);
        if (e.getPattern() != Pattern.InOnly) {
          if (e.getFault().getBody() != null) {
            exchange.getFault().setBody(e.getFault().getBody());
          } else
            exchange.getOut().setBody(e.getOut().getBody());
View Full Code Here

        waitOnContextCreation("org.apache.servicemix.examples.itests.cxf-nmr-osgi");
        Thread.sleep(5000);
        NMR nmr = getOsgiService(NMR.class);
        assertNotNull(nmr);
       
        Channel client = nmr.createChannel();
        Exchange e = client.createExchange(Pattern.InOut);
        for (Endpoint ep : nmr.getEndpointRegistry().getServices()) {
            e.setTarget(nmr.getEndpointRegistry().lookup(nmr.getEndpointRegistry().getProperties(ep)));
            e.getIn().setBody(new StringSource("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:sayHi xmlns:ns2=\"http://cxf.examples.servicemix.apache.org/\"><arg0>Bonjour</arg0></ns2:sayHi></soap:Body></soap:Envelope>"));
            boolean res = client.sendSync(e);
            assertTrue(res);
        }
   
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.nmr.api.Channel

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.