You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by allfonsiva <al...@aim.com> on 2006/09/26 14:34:13 UTC

Route for exchange

hi all,
 

i am trying to develop my own component using http. I activated my http
component as shown in the http-binding example. i build my client which
creates an xml and sends it to that http component. now that component has
get  xml and send to my specified component.

i don know how to route that message to another compoent..

can anyone help me out in this regard...

-- 
View this message in context: http://www.nabble.com/Route-for-exchange-tf2338092.html#a6505882
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Route for exchange

Posted by Thomas TERMIN <tt...@blue-elephant-systems.com>.
<http:endpoint service="bes:http-request-start"
               endpoint="http-endpointAsync"
               targetService="bes:request-start"
               targetEndpoint="endpointAsync"
               role="consumer"
          locationURI="http://localhost:8192/BESlocalAsyncRequest/"

          defaultMep="http://www.w3.org/2004/08/wsdl/in-out" />

the http consumer routes to the target service how you can see.


allfonsiva wrote:
> hi thomas
> 
> i tried working on it.its is working fine.
> 
> 
> the prob now i have is my i have to route the message got my the
> httpconnector to the destination service. i want to route it inside the
> httpconnector itself. but onmessage exchange is not working in case of it
> 
> 
> thanks
> 
> Siva
> 
> 
> tterm wrote:
>> Look at the following:
>>
>> servicemix.xml
>>
>> ...
>>
>> <sm:activationSpec destinationService="bes:remote-request-start"
>> 		   endpoint="LocalAsyncComponentOneProvider" 		
>>                    service="bes:LocalAsyncComponentOneService">
>>   <sm:component>
>>     <bean class="com.bes.LocalAsyncComponentOne">
>>     </bean>
>>   </sm:component>
>> </sm:activationSpec>
>>
>> ....
>>
>> You can see here that I declare a service componente
>> bes:LocalAsyncComponentOneService. The new message exchange will be
>> routed to the destination service bes:remote-request-start
>>
>> This is the code snippet of the component:
>>
>>
>> public class LocalAsyncComponentOne extends ComponentSupport implements
>>     MessageExchangeListener
>> {
>>   public void onMessageExchange(MessageExchange exchange)
>>       throws MessagingException
>>   {
>>
>> 	... other code here
>>
>>
>>        // Message Exchange with the destinationService here
>>       InOut inOutExchange = getExchangeFactory().createInOutExchange();
>>       NormalizedMessage newMessageForComponentTwo =
>> inOutExchange.createMessage();
>>
>>       newMessageForComponentTwo.setContent(
>>          inMessageFromClient.getContent());
>>       inOutExchange.setInMessage(newMessageForComponentTwo);
>>       inOutExchange.setProperty("exchangeID", exchange.getExchangeId());
>>
>>       // send to the destination
>>       send(inOutExchange);
>>
>>        ... other code here
>>
>>    }
>> }
>>
>> You don't have to set anything in the code then!
>>
>>
>>
>> allfonsiva wrote:
>>> hi thomas
>>>
>>> in my component i can able  to initiate all my components. my problem is
>>>
>>>
>>> i have to specify the route of message in the coding itself
>>>
>>> what are the thing i have to set for send my message to my destination?
>>>
>>> can you please explain me with a small snippet of code?
>>>
>>> thanks in advance
>>>
>>> Siva
>>>
>>>
>>> tterm wrote:
>>>> allfonsiva wrote:
>>>>> hi all,
>>>>>  
>>>>>
>>>>> i am trying to develop my own component using http. I activated my http
>>>>> component as shown in the http-binding example. i build my client which
>>>>> creates an xml and sends it to that http component. now that component
>>>>> has
>>>>> get  xml and send to my specified component.
>>>>>
>>>>> i don know how to route that message to another compoent..
>>>>>
>>>>> can anyone help me out in this regard...
>>>>>
>>>> But you can also use EIP patterns for routing. Look at servicemix.org
>>>> for more information on eip's.
>>>>
>>>> Thomas
>>>>
>>>>
>>
>>
> 


Re: Route for exchange

Posted by allfonsiva <al...@aim.com>.

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-for-exchange-tf2338092.html#a6520818
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Route for exchange

Posted by allfonsiva <al...@aim.com>.
Thanks for your help

i tiried working on it.

can anyone give me a snippet of code for setting that property in the
methods. because i don know what i have to set for interface  but i can able
to set endpoint and service. 

Thanks in advance

regards

Siva


-- 
View this message in context: http://www.nabble.com/Route-for-exchange-tf2338092.html#a6520612
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Route for exchange

Posted by Thomas TERMIN <tt...@blue-elephant-systems.com>.
yes but you have to set the target service for the http-consumer
component that the http request is routed to a target service

Guillaume Nodet wrote:
> The target destination on an exchange can be set
> using the setEndpoint, setService or setInterfaceName
> methods.  You can set them explicitely from your code
> if you need, else they will be set by the container with
> the values configured on the activationSpec.
> 
> On 9/26/06, allfonsiva <al...@aim.com> wrote:
>>
>> hi thomas
>>
>> i tried working on it.its is working fine.
>>
>>
>> the prob now i have is my i have to route the message got my the
>> httpconnector to the destination service. i want to route it inside the
>> httpconnector itself. but onmessage exchange is not working in case of it
>>
>>
>> thanks
>>
>> Siva
>>
>>
>> tterm wrote:
>> >
>> > Look at the following:
>> >
>> > servicemix.xml
>> >
>> > ...
>> >
>> > <sm:activationSpec destinationService="bes:remote-request-start"
>> >                  endpoint="LocalAsyncComponentOneProvider"
>> >                    service="bes:LocalAsyncComponentOneService">
>> >   <sm:component>
>> >     <bean class="com.bes.LocalAsyncComponentOne">
>> >     </bean>
>> >   </sm:component>
>> > </sm:activationSpec>
>> >
>> > ....
>> >
>> > You can see here that I declare a service componente
>> > bes:LocalAsyncComponentOneService. The new message exchange will be
>> > routed to the destination service bes:remote-request-start
>> >
>> > This is the code snippet of the component:
>> >
>> >
>> > public class LocalAsyncComponentOne extends ComponentSupport implements
>> >     MessageExchangeListener
>> > {
>> >   public void onMessageExchange(MessageExchange exchange)
>> >       throws MessagingException
>> >   {
>> >
>> >       ... other code here
>> >
>> >
>> >        // Message Exchange with the destinationService here
>> >       InOut inOutExchange = getExchangeFactory().createInOutExchange();
>> >       NormalizedMessage newMessageForComponentTwo =
>> > inOutExchange.createMessage();
>> >
>> >       newMessageForComponentTwo.setContent(
>> >          inMessageFromClient.getContent());
>> >       inOutExchange.setInMessage(newMessageForComponentTwo);
>> >       inOutExchange.setProperty("exchangeID",
>> exchange.getExchangeId());
>> >
>> >       // send to the destination
>> >       send(inOutExchange);
>> >
>> >        ... other code here
>> >
>> >    }
>> > }
>> >
>> > You don't have to set anything in the code then!
>> >
>> >
>> >
>> > allfonsiva wrote:
>> >> hi thomas
>> >>
>> >> in my component i can able  to initiate all my components. my
>> problem is
>> >>
>> >>
>> >> i have to specify the route of message in the coding itself
>> >>
>> >> what are the thing i have to set for send my message to my
>> destination?
>> >>
>> >> can you please explain me with a small snippet of code?
>> >>
>> >> thanks in advance
>> >>
>> >> Siva
>> >>
>> >>
>> >> tterm wrote:
>> >>> allfonsiva wrote:
>> >>>> hi all,
>> >>>>
>> >>>>
>> >>>> i am trying to develop my own component using http. I activated
>> my http
>> >>>> component as shown in the http-binding example. i build my client
>> which
>> >>>> creates an xml and sends it to that http component. now that
>> component
>> >>>> has
>> >>>> get  xml and send to my specified component.
>> >>>>
>> >>>> i don know how to route that message to another compoent..
>> >>>>
>> >>>> can anyone help me out in this regard...
>> >>>>
>> >>> But you can also use EIP patterns for routing. Look at servicemix.org
>> >>> for more information on eip's.
>> >>>
>> >>> Thomas
>> >>>
>> >>>
>> >>
>> >
>> >
>> >
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Route-for-exchange-tf2338092.html#a6506800
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 


Re: Route for exchange

Posted by Guillaume Nodet <gn...@gmail.com>.
The target destination on an exchange can be set
using the setEndpoint, setService or setInterfaceName
methods.  You can set them explicitely from your code
if you need, else they will be set by the container with
the values configured on the activationSpec.

On 9/26/06, allfonsiva <al...@aim.com> wrote:
>
> hi thomas
>
> i tried working on it.its is working fine.
>
>
> the prob now i have is my i have to route the message got my the
> httpconnector to the destination service. i want to route it inside the
> httpconnector itself. but onmessage exchange is not working in case of it
>
>
> thanks
>
> Siva
>
>
> tterm wrote:
> >
> > Look at the following:
> >
> > servicemix.xml
> >
> > ...
> >
> > <sm:activationSpec destinationService="bes:remote-request-start"
> >                  endpoint="LocalAsyncComponentOneProvider"
> >                    service="bes:LocalAsyncComponentOneService">
> >   <sm:component>
> >     <bean class="com.bes.LocalAsyncComponentOne">
> >     </bean>
> >   </sm:component>
> > </sm:activationSpec>
> >
> > ....
> >
> > You can see here that I declare a service componente
> > bes:LocalAsyncComponentOneService. The new message exchange will be
> > routed to the destination service bes:remote-request-start
> >
> > This is the code snippet of the component:
> >
> >
> > public class LocalAsyncComponentOne extends ComponentSupport implements
> >     MessageExchangeListener
> > {
> >   public void onMessageExchange(MessageExchange exchange)
> >       throws MessagingException
> >   {
> >
> >       ... other code here
> >
> >
> >        // Message Exchange with the destinationService here
> >       InOut inOutExchange = getExchangeFactory().createInOutExchange();
> >       NormalizedMessage newMessageForComponentTwo =
> > inOutExchange.createMessage();
> >
> >       newMessageForComponentTwo.setContent(
> >          inMessageFromClient.getContent());
> >       inOutExchange.setInMessage(newMessageForComponentTwo);
> >       inOutExchange.setProperty("exchangeID", exchange.getExchangeId());
> >
> >       // send to the destination
> >       send(inOutExchange);
> >
> >        ... other code here
> >
> >    }
> > }
> >
> > You don't have to set anything in the code then!
> >
> >
> >
> > allfonsiva wrote:
> >> hi thomas
> >>
> >> in my component i can able  to initiate all my components. my problem is
> >>
> >>
> >> i have to specify the route of message in the coding itself
> >>
> >> what are the thing i have to set for send my message to my destination?
> >>
> >> can you please explain me with a small snippet of code?
> >>
> >> thanks in advance
> >>
> >> Siva
> >>
> >>
> >> tterm wrote:
> >>> allfonsiva wrote:
> >>>> hi all,
> >>>>
> >>>>
> >>>> i am trying to develop my own component using http. I activated my http
> >>>> component as shown in the http-binding example. i build my client which
> >>>> creates an xml and sends it to that http component. now that component
> >>>> has
> >>>> get  xml and send to my specified component.
> >>>>
> >>>> i don know how to route that message to another compoent..
> >>>>
> >>>> can anyone help me out in this regard...
> >>>>
> >>> But you can also use EIP patterns for routing. Look at servicemix.org
> >>> for more information on eip's.
> >>>
> >>> Thomas
> >>>
> >>>
> >>
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Route-for-exchange-tf2338092.html#a6506800
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: Route for exchange

Posted by allfonsiva <al...@aim.com>.
hi thomas

i tried working on it.its is working fine.


the prob now i have is my i have to route the message got my the
httpconnector to the destination service. i want to route it inside the
httpconnector itself. but onmessage exchange is not working in case of it


thanks

Siva


tterm wrote:
> 
> Look at the following:
> 
> servicemix.xml
> 
> ...
> 
> <sm:activationSpec destinationService="bes:remote-request-start"
> 		   endpoint="LocalAsyncComponentOneProvider" 		
>                    service="bes:LocalAsyncComponentOneService">
>   <sm:component>
>     <bean class="com.bes.LocalAsyncComponentOne">
>     </bean>
>   </sm:component>
> </sm:activationSpec>
> 
> ....
> 
> You can see here that I declare a service componente
> bes:LocalAsyncComponentOneService. The new message exchange will be
> routed to the destination service bes:remote-request-start
> 
> This is the code snippet of the component:
> 
> 
> public class LocalAsyncComponentOne extends ComponentSupport implements
>     MessageExchangeListener
> {
>   public void onMessageExchange(MessageExchange exchange)
>       throws MessagingException
>   {
> 
> 	... other code here
> 
> 
>        // Message Exchange with the destinationService here
>       InOut inOutExchange = getExchangeFactory().createInOutExchange();
>       NormalizedMessage newMessageForComponentTwo =
> inOutExchange.createMessage();
> 
>       newMessageForComponentTwo.setContent(
>          inMessageFromClient.getContent());
>       inOutExchange.setInMessage(newMessageForComponentTwo);
>       inOutExchange.setProperty("exchangeID", exchange.getExchangeId());
> 
>       // send to the destination
>       send(inOutExchange);
> 
>        ... other code here
> 
>    }
> }
> 
> You don't have to set anything in the code then!
> 
> 
> 
> allfonsiva wrote:
>> hi thomas
>> 
>> in my component i can able  to initiate all my components. my problem is
>> 
>> 
>> i have to specify the route of message in the coding itself
>> 
>> what are the thing i have to set for send my message to my destination?
>> 
>> can you please explain me with a small snippet of code?
>> 
>> thanks in advance
>> 
>> Siva
>> 
>> 
>> tterm wrote:
>>> allfonsiva wrote:
>>>> hi all,
>>>>  
>>>>
>>>> i am trying to develop my own component using http. I activated my http
>>>> component as shown in the http-binding example. i build my client which
>>>> creates an xml and sends it to that http component. now that component
>>>> has
>>>> get  xml and send to my specified component.
>>>>
>>>> i don know how to route that message to another compoent..
>>>>
>>>> can anyone help me out in this regard...
>>>>
>>> But you can also use EIP patterns for routing. Look at servicemix.org
>>> for more information on eip's.
>>>
>>> Thomas
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Route-for-exchange-tf2338092.html#a6506800
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Route for exchange

Posted by Thomas TERMIN <tt...@blue-elephant-systems.com>.
Look at the following:

servicemix.xml

...

<sm:activationSpec destinationService="bes:remote-request-start"
		   endpoint="LocalAsyncComponentOneProvider" 		
                   service="bes:LocalAsyncComponentOneService">
  <sm:component>
    <bean class="com.bes.LocalAsyncComponentOne">
    </bean>
  </sm:component>
</sm:activationSpec>

....

You can see here that I declare a service componente
bes:LocalAsyncComponentOneService. The new message exchange will be
routed to the destination service bes:remote-request-start

This is the code snippet of the component:


public class LocalAsyncComponentOne extends ComponentSupport implements
    MessageExchangeListener
{
  public void onMessageExchange(MessageExchange exchange)
      throws MessagingException
  {

	... other code here


       // Message Exchange with the destinationService here
      InOut inOutExchange = getExchangeFactory().createInOutExchange();
      NormalizedMessage newMessageForComponentTwo =
inOutExchange.createMessage();

      newMessageForComponentTwo.setContent(
         inMessageFromClient.getContent());
      inOutExchange.setInMessage(newMessageForComponentTwo);
      inOutExchange.setProperty("exchangeID", exchange.getExchangeId());

      // send to the destination
      send(inOutExchange);

       ... other code here

   }
}

You don't have to set anything in the code then!



allfonsiva wrote:
> hi thomas
> 
> in my component i can able  to initiate all my components. my problem is
> 
> 
> i have to specify the route of message in the coding itself
> 
> what are the thing i have to set for send my message to my destination?
> 
> can you please explain me with a small snippet of code?
> 
> thanks in advance
> 
> Siva
> 
> 
> tterm wrote:
>> allfonsiva wrote:
>>> hi all,
>>>  
>>>
>>> i am trying to develop my own component using http. I activated my http
>>> component as shown in the http-binding example. i build my client which
>>> creates an xml and sends it to that http component. now that component
>>> has
>>> get  xml and send to my specified component.
>>>
>>> i don know how to route that message to another compoent..
>>>
>>> can anyone help me out in this regard...
>>>
>> But you can also use EIP patterns for routing. Look at servicemix.org
>> for more information on eip's.
>>
>> Thomas
>>
>>
> 


Re: Route for exchange

Posted by allfonsiva <al...@aim.com>.
hi thomas

in my component i can able  to initiate all my components. my problem is


i have to specify the route of message in the coding itself

what are the thing i have to set for send my message to my destination?

can you please explain me with a small snippet of code?

thanks in advance

Siva


tterm wrote:
> 
> allfonsiva wrote:
>> hi all,
>>  
>> 
>> i am trying to develop my own component using http. I activated my http
>> component as shown in the http-binding example. i build my client which
>> creates an xml and sends it to that http component. now that component
>> has
>> get  xml and send to my specified component.
>> 
>> i don know how to route that message to another compoent..
>> 
>> can anyone help me out in this regard...
>> 
> But you can also use EIP patterns for routing. Look at servicemix.org
> for more information on eip's.
> 
> Thomas
> 
> 

-- 
View this message in context: http://www.nabble.com/Route-for-exchange-tf2338092.html#a6506333
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Route for exchange

Posted by Thomas TERMIN <tt...@blue-elephant-systems.com>.
allfonsiva wrote:
> hi all,
>  
> 
> i am trying to develop my own component using http. I activated my http
> component as shown in the http-binding example. i build my client which
> creates an xml and sends it to that http component. now that component has
> get  xml and send to my specified component.
> 
> i don know how to route that message to another compoent..
> 
> can anyone help me out in this regard...
> 
But you can also use EIP patterns for routing. Look at servicemix.org
for more information on eip's.

Thomas

Re: Route for exchange

Posted by Thomas TERMIN <tt...@blue-elephant-systems.com>.
allfonsiva wrote:
> hi all,
>  
> 
> i am trying to develop my own component using http. I activated my http
> component as shown in the http-binding example. i build my client which
> creates an xml and sends it to that http component. now that component has
> get  xml and send to my specified component.
> 
> i don know how to route that message to another compoent..
> 
> can anyone help me out in this regard...
> 
You have the targetService and targetEndpoint in the http:endpoint
component.

And you have the destinationService and destinationEndpoint for the
service components.