You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Barath <ba...@gmail.com> on 2007/11/01 11:44:01 UTC

to add normalized message to MessageExchange-----

Hi,

i build one BC which listen to http://localhost:9090/ (using jetty server)
and if any client requested, it ll send a hello world to browser. i am using
servlet for this. its working fine.

now i am tring to retrive a parameter from the request and normalize it and
put it in  message exchange and send to Myendpoint.java 's process method.

but i dono how to do that.
can u give any code explanation for the same.?

My class structure is

1 . MyBootstrap.java  -- which listen to http:\\localhost:9090\ and calls
Servlet.java. 
2 . Servlet.java -- doGet method calls join.java 's start method. 
3 . join.java -- start method should call process method of Myendpoint.java
with MessageExchange as parameter.

I tried this code but dono how to initialize MessageExchangeFactory.

----------------------------8<-----------------------------------
	    MyEndpoint endpoint= new MyEndpoint();
	    InOut exchange;
	    NormalizedMessage nm;
	    MessageExchangeFactory exchangeFactory=
		        
      		try
		{
		exchange = exchangeFactory.createInOutExchange();
		nm = exchange.createMessage();
		nm.setContent(new StringSource(inp));
		exchange.setInMessage(nm);
		endpoint.process(exchange);
		}		
		catch( Exception ex)
		{
			System.out.println(ex);
			ex.printStackTrace();
		}
---------------------------------------8<----------------------------------------
Advanced Thanks,
Barath
-- 
View this message in context: http://www.nabble.com/to-add-normalized-message-to-MessageExchange------tf4730489s12049.html#a13526388
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: to add normalized message to MessageExchange-----

Posted by Daryl Richter <ng...@comcast.net>.
Barath-

I realized that I totally missed your main point.  You get the  
MessageExchangeFactory from the channel like so:

channel.createExchangeFactory()


On Nov 1, 2007, at 6:44 AM, Barath wrote:

>
> Hi,
>
> i build one BC which listen to http://localhost:9090/ (using jetty  
> server)
> and if any client requested, it ll send a hello world to browser. i  
> am using
> servlet for this. its working fine.
>
> now i am tring to retrive a parameter from the request and  
> normalize it and
> put it in  message exchange and send to Myendpoint.java 's process  
> method.
>
> but i dono how to do that.
> can u give any code explanation for the same.?
>
> My class structure is
>
> 1 . MyBootstrap.java  -- which listen to http:\\localhost:9090\ and  
> calls
> Servlet.java.
> 2 . Servlet.java -- doGet method calls join.java 's start method.
> 3 . join.java -- start method should call process method of  
> Myendpoint.java
> with MessageExchange as parameter.
>
> I tried this code but dono how to initialize MessageExchangeFactory.
>
> ----------------------------8<-----------------------------------
> 	    MyEndpoint endpoint= new MyEndpoint();
> 	    InOut exchange;
> 	    NormalizedMessage nm;
> 	    MessageExchangeFactory exchangeFactory=
> 		
>       		try
> 		{
> 		exchange = exchangeFactory.createInOutExchange();
> 		nm = exchange.createMessage();
> 		nm.setContent(new StringSource(inp));
> 		exchange.setInMessage(nm);
> 		endpoint.process(exchange);
> 		}		
> 		catch( Exception ex)
> 		{
> 			System.out.println(ex);
> 			ex.printStackTrace();
> 		}
> ---------------------------------------8<----------------------------- 
> -----------
> Advanced Thanks,
> Barath
> -- 
> View this message in context: http://www.nabble.com/to-add- 
> normalized-message-to-MessageExchange------ 
> tf4730489s12049.html#a13526388
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>

--
Daryl
http://itsallsemantics.com

"We want great men who, when fortune frowns, will not be discouraged."
     -- Colonel Henry Knox, 1776






Re: to add normalized message to MessageExchange-----

Posted by Daryl Richter <ng...@comcast.net>.
On Nov 1, 2007, at 6:44 AM, Barath wrote:

>
> Hi,
>
> i build one BC which listen to http://localhost:9090/ (using jetty  
> server)
> and if any client requested, it ll send a hello world to browser. i  
> am using
> servlet for this. its working fine.
>
> now i am tring to retrive a parameter from the request and  
> normalize it and
> put it in  message exchange and send to Myendpoint.java 's process  
> method.
>
> but i dono how to do that.
> can u give any code explanation for the same.?
>
> My class structure is
>
> 1 . MyBootstrap.java  -- which listen to http:\\localhost:9090\ and  
> calls
> Servlet.java.
> 2 . Servlet.java -- doGet method calls join.java 's start method.
> 3 . join.java -- start method should call process method of  
> Myendpoint.java
> with MessageExchange as parameter.
>
> I tried this code but dono how to initialize MessageExchangeFactory.
>
> ----------------------------8<-----------------------------------
> 	    MyEndpoint endpoint= new MyEndpoint();
> 	    InOut exchange;
> 	    NormalizedMessage nm;
> 	    MessageExchangeFactory exchangeFactory=
> 		
>       		try
> 		{
> 		exchange = exchangeFactory.createInOutExchange();
> 		nm = exchange.createMessage();

Here you also need to tell it where to go via exchange.setService()  
and, optionally, .setEndpoint().

> 		nm.setContent(new StringSource(inp));
> 		exchange.setInMessage(nm);
> 		endpoint.process(exchange);

Don't call endpoint.process.  You want to do this following instead:

channel.send( exchange ) or channel.sendSync( exchange )

That will get the message to your endpoint.

Make sure you have declared:

     @Resource
     private DeliveryChannel     channel;

In your bean class to have access to the channel.

HTH.


> 		}		
> 		catch( Exception ex)
> 		{
> 			System.out.println(ex);
> 			ex.printStackTrace();
> 		}
> ---------------------------------------8<----------------------------- 
> -----------
> Advanced Thanks,
> Barath
> -- 
> View this message in context: http://www.nabble.com/to-add- 
> normalized-message-to-MessageExchange------ 
> tf4730489s12049.html#a13526388
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>

--
Daryl
Email *my = [ daryl at: @"eddl" dot: @"us" ];
Weblog *blog = @”http://itsallsemantics.com”;