They are in the base class of the HttpConnector.
See [1]. You could just modify the exchange after
it has been created.
[1]
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpInOutBinding.java?revision=426415&view=markup
On 9/27/06, allfonsiva <[EMAIL PROTECTED]> wrote:
hi gnodet,
can you please explain me with a small code snippet.
Where can i found that processInOnly and processInOut method?
gnodet wrote:
>
> The destination must be set on the JBI exchange for each
> exchange sent by the component. You need to override
> the processInOut and processInOnly methods,
> or implements a custom HttpMarshaler.
>
> On 9/27/06, allfonsiva <[EMAIL PROTECTED]> wrote:
>>
>> hi
>>
>> i am uisng the same http client. the only change is that the http
>> component
>> alone making the routing to destination service. so i tried with the
>> following code.......
>>
>> This is my http connector code.....
>>
>>
>> package ss.servicemix.components.http;
>>
>> import javax.jbi.JBIException;
>> import javax.jbi.component.ComponentContext;
>> import javax.jbi.messaging.InOnly;
>> import javax.jbi.messaging.MessageExchange;
>> import javax.jbi.messaging.InOut;
>> import javax.jbi.messaging.MessagingException;
>> import javax.jbi.messaging.NormalizedMessage;
>> import javax.jbi.servicedesc.ServiceEndpoint;
>> import javax.xml.namespace.QName;
>>
>>
>>
>> import org.apache.servicemix.MessageExchangeListener;
>> import org.apache.servicemix.components.util.ComponentSupport;
>> import org.apache.servicemix.jbi.resolver.EndpointChooser;
>> import org.apache.servicemix.jbi.resolver.EndpointResolver;
>> import org.apache.servicemix.jbi.resolver.InterfaceNameEndpointResolver;
>> import org.apache.servicemix.jbi.resolver.NullEndpointFilter;
>> import org.apache.servicemix.jbi.resolver.ServiceAndEndpointNameResolver;
>> import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
>> import org.apache.servicemix.jbi.resolver.URIResolver;
>> import org.mortbay.jetty.Connector;
>> import org.mortbay.jetty.Server;
>> import org.mortbay.jetty.bio.SocketConnector;
>> import org.mortbay.jetty.handler.ContextHandler;
>> import org.mortbay.jetty.servlet.ServletHandler;
>> import org.mortbay.jetty.servlet.ServletHolder;
>> import org.mortbay.jetty.servlet.ServletMapping;
>> import org.mortbay.thread.BoundedThreadPool;
>> import org.apache.servicemix.jbi.container.ActivationSpec;
>> import org.apache.servicemix.jbi.container.SubscriptionSpec;
>> import org.apache.servicemix.jbi.jaxp.SourceTransformer;
>> import org.apache.servicemix.jbi.messaging.PojoMarshaler;
>>
>> /**
>> * An embedded Servlet engine to implement a HTTP connector
>> *
>> * @version $Revision: 410091 $
>> */
>> public class HttpConnector extends HttpInOutBinding implements
>> MessageExchangeListener {
>> private Connector listener = new SocketConnector();
>>
>> /**
>> * The maximum number of threads for the Jetty SocketListener.
>> It's
>> set
>> * to 256 by default to match the default value in Jetty.
>> */
>> private int maxThreads = 256;
>> private transient EndpointResolver destinationResolver;
>>
>> private Server server;
>> private String host;
>> private int port;
>>
>>
>>
>>
>>
>>
>> /**
>> * Constructor
>> *
>> * @param host
>> * @param port
>> */
>> public HttpConnector(String host, int port) {
>> this.host = host;
>> this.port = port;
>> }
>>
>> /*public HttpConnector() {
>>
>>
>> }
>> */
>> /**
>> * Constructor
>> *
>> * @param listener
>> */
>> public HttpConnector(Connector listener) {
>> this.listener = listener;
>> }
>>
>>
>>
>> /********This i added inside the code***********************/
>>
>> public static final QName SERVICE =
>> new QName("http://servicemix.org/example/", "http");
>> public static final String ENDPOINT = "http";
>>
>> private EndpointResolver resolver;
>> private String[] resolverElements;
>>
>> public HttpConnector()
>> {
>>
>>
>> }
>>
>> public EndpointResolver getResolver()
>> {
>> return resolver;
>> }
>>
>> public void setResolver(EndpointResolver resolver)
>> {
>> System.out.println("xml resolver111111111------->"+resolver);
>> this.resolver = resolver;
>>
>> }
>> public void setResolverElements(String[] resolverElements)
>> {
>> this.resolverElements = resolverElements;
>> resolver = new ServiceNameEndpointResolver(new
>> QName(resolverElements[0],resolverElements[1]));
>>
>> }
>>
>> public void settingdestination() throws JBIException{
>>
>> ComponentContext context1 = getContext();
>> try {
>> InOnly exchange =
>> context1.getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
>> ServiceEndpoint destination =null;
>>
>>
>> if (resolver != null)
>> {System.out.println("destination--->"+destination);
>> System.out.println("resolver---->"+resolver);
>> destination = resolver.resolveEndpoint(getContext(),
>> exchange,
>>
>> NullEndpointFilter.getInstance());
>>
>> }
>> if (destination != null)
>> {
>> // lets explicitly specify the destination - otherwise
>> // we'll let the container choose for us
>> System.out.println("destination"+destination);
>> exchange.setEndpoint(destination);
>> }
>>
>> exchange.setService(new
>> QName("http://servicemix.org/example/",
>> "receiver"));
>> exchange.setInterfaceName(new
>> QName("http://servicemix.org/example/", "receiver"));
>> } catch (MessagingException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>>
>> }
>>
>>
>> /**************************************************************************/
>>
>> /**
>> * Called when the Component is initialized
>> *
>> * @param cc
>> * @throws JBIException
>> */
>> public void init(ComponentContext cc) throws JBIException {
>> super.init(cc);
>> //should set all ports etc here - from the naming context I guess
>> ?
>> if (listener == null) {
>> listener = new SocketConnector();
>> }
>> listener.setHost("localhost");
>> listener.setPort(8555);
>> server = new Server();
>> BoundedThreadPool btp = new BoundedThreadPool();
>> btp.setMaxThreads(getMaxThreads());
>> server.setThreadPool(btp);
>>
>> }
>>
>> /**
>> * start the Component
>> *
>> * @throws JBIException
>> */
>> public void start() throws JBIException {
>> server.setConnectors(new Connector[] { listener });
>> ContextHandler context = new ContextHandler();
>> context.setContextPath("/");
>> ServletHolder holder = new ServletHolder();
>> holder.setName("jbiServlet");
>> holder.setClassName(BindingServlet.class.getName());
>> ServletHandler handler = new ServletHandler();
>> handler.setServlets(new ServletHolder[] { holder });
>> System.out.println("inside server");
>> ServletMapping mapping = new ServletMapping();
>> mapping.setServletName("jbiServlet");
>> mapping.setPathSpec("/*");
>> handler.setServletMappings(new ServletMapping[] { mapping });
>> context.setHandler(handler);
>> server.setHandler(context);
>> context.setAttribute("binding", this);
>> try {
>>
>> settingdestination();
>>
>> server.start();
>>
>> }
>> catch (Exception e) {
>> throw new JBIException("Start failed: " + e, e);
>> }
>> }
>>
>>
>>
>>
>>
>> /**
>> * stop
>> */
>> public void stop() throws JBIException {
>> try {
>> if (server != null) {
>> server.stop();
>> }
>> }
>> catch (Exception e) {
>> throw new JBIException("Stop failed: " + e, e);
>> }
>> }
>>
>> /**
>> * shutdown
>> */
>> public void shutDown() throws JBIException {
>> super.shutDown();
>> server = null;
>> }
>>
>>
>> // Properties
>>
>> //-------------------------------------------------------------------------
>> public int getPort() {
>> return port;
>> }
>>
>> public void setPort(int port) {
>> this.port = port;
>> }
>>
>> public Server getServer() {
>> return server;
>> }
>>
>> public void setServer(Server server) {
>> this.server = server;
>> }
>>
>> public String getHost() {
>> return host;
>> }
>>
>> public void setHost(String host) {
>> this.host = host;
>> }
>>
>> public int getMaxThreads() {
>> return maxThreads;
>> }
>>
>> public void setMaxThreads(int maxThreads) {
>> this.maxThreads = maxThreads;
>> }
>> public void onMessageExchange(MessageExchange exchange) throws
>> MessagingException {
>> // As we send in-only MEPS, we will only
>> // receive DONE or ERROR status
>> System.out.println("inside on message exchange");
>>
>> try{
>>
>> SourceTransformer sourceTransformer= new SourceTransformer();
>> NormalizedMessage message = exchange.getMessage("in");
>>
>>
System.out.println("%%%%%%%%%%%%%%%%%%"+sourceTransformer.toString(message.getContent()));
>>
>>
>> }
>> catch(Exception e){}
>> done(exchange);
>>
>> }
>> }
>>
>>
>> when i start the server there is no error when i build my http client im
>> getting the following error..
>>
>> :INFO: jetty 6.0.0beta17
>> :INFO: Started SocketConnector @ localhost:8555
>> :WARN: EXCEPTION
>> javax.servlet.ServletException: Failed to process JBI request:
>> javax.jbi.messaging.MessagingException: Could not find route for
>> exchange:
>> MessageExchange[
>> id: ID:AD0063-TRNG1-1265-1159335121209-2:1
>> status: Active
>> role: provider
>> in: <?xml version="1.0" encoding="UTF-8"?><ns1:getQuote
>> xmlns:ns1="urn:xmethods-delayed-quotes"
>> xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
>> se:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>> <symbol xsi:type="xsd:string">IBM</symbol>
>> </ns1:getQuote>
>> ] for service: null and interface: null
>> at
>> ss.servicemix.components.http.BindingServlet.doPost(BindingServlet.java:78)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:615)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>> at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:423)
>> at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:355)
>> at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:567)
>> at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
>> at org.mortbay.jetty.Server.handle(Server.java:248)
>> at
>> org.mortbay.jetty.HttpConnection.handlerRequest(HttpConnection.java:360)
>> at
>>
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:628)
>> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:611)
>> at
>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:197)
>> at
>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:288)
>> at
>>
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:180)
>> at
>>
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
>>
>>
>>
>>
>> --
>> View this message in context:
>>
http://www.nabble.com/Route-not-found-for-exchange-error-tf2343562.html#a6523146
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context:
http://www.nabble.com/Route-not-found-for-exchange-error-tf2343562.html#a6523640
Sent from the ServiceMix - User mailing list archive at Nabble.com.
--
Cheers,
Guillaume Nodet