You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "johnbarleycorn_81@libero.it" <jo...@libero.it> on 2009/01/09 15:59:22 UTC

How to set a timeout for an InOut exchange

Dear all,

I'll be very grateful if someone could help me.
I'm using Servicemix 3.2.1, I used inside a cxf-se an InOut
exchange to communicate with a bean-se. 
My exchange must receive a response in a few time.
Could you tell me how can I set the timeout that wait for the response to be longer than the default and to be a choosen value, please?
I thank you in advance for your help.
Best Regards,
Anna.

PS: Here I have reported the code and the exception so you can confirm that I need to set a longer timeout:

CODE:
ClientFactory factory = (ClientFactory) new InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME);
ServiceMixClient client = factory.createClient();
Destination destination = client.createDestination("service:http://myproject.com/components/communicationManager");
InOut inOutExchange = destination.createInOutExchange();
NormalizedMessage message = inOutExchange.getInMessage();
inOutExchange.getInMessage().setContent(new StringSource("aRequest"));
		
logger.info("Target sends!");
client.sendSync(inOutExchange);
				
System.err.println(new SourceTransformer().contentToString(inOutExchange.getOutMessage()));
logger.info("Target receives!");
			
SourceTransformer sourceTransformer = new SourceTransformer();
String stringReturnMessage = sourceTransformer.toString(inOutExchange.getOutMessage().getContent());
logger.info("Target received: " + stringReturnMessage);

EXCEPTION:
9-gen-2009 14.57.57 org.apache.cxf.transport.jbi.JBIDestinationOutputStream commitOutputMessage
GRAVE: error sending Out message
org.apache.servicemix.jbi.ExchangeTimeoutException: Exchange has timed out: InOut[
  id: ID:192.168.32.32-11ebbae1faa-4:4
  status: Error
  role: provider
  interface: {http://myproject.com/NDTWS/}TargetWSImpl
  service: {http://myproject.com/NDTWS/}TargetWSImplService
  endpoint: TargetWSImplPort
  operation: {http://myproject.com/NDTWS/}doLogin
  in: "aResponse"]







Re: How to set a timeout for an InOut exchange

Posted by Freeman Fang <fr...@gmail.com>.
johnbarleycorn_81@libero.it wrote:
> Dear all,
>
> I'll be very grateful if someone could help me.
> I'm using Servicemix 3.2.1, I used inside a cxf-se an InOut
> exchange to communicate with a bean-se. 
> My exchange must receive a response in a few time.
> Could you tell me how can I set the timeout that wait for the response to be longer than the default and to be a choosen value, please?
> I thank you in advance for your help.
> Best Regards,
> Anna.
>
> PS: Here I have reported the code and the exception so you can confirm that I need to set a longer timeout:
>
> CODE:
> ClientFactory factory = (ClientFactory) new InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME);
> ServiceMixClient client = factory.createClient();
> Destination destination = client.createDestination("service:http://myproject.com/components/communicationManager");
> InOut inOutExchange = destination.createInOutExchange();
> NormalizedMessage message = inOutExchange.getInMessage();
> inOutExchange.getInMessage().setContent(new StringSource("aRequest"));
> 		
> logger.info("Target sends!");
> client.sendSync(inOutExchange);
> 				
>   
here you can use
client.sendSync(inOutExchange, your_timeout_value);// the timeout is in ms
Freeman
> System.err.println(new SourceTransformer().contentToString(inOutExchange.getOutMessage()));
> logger.info("Target receives!");
> 			
> SourceTransformer sourceTransformer = new SourceTransformer();
> String stringReturnMessage = sourceTransformer.toString(inOutExchange.getOutMessage().getContent());
> logger.info("Target received: " + stringReturnMessage);
>
> EXCEPTION:
> 9-gen-2009 14.57.57 org.apache.cxf.transport.jbi.JBIDestinationOutputStream commitOutputMessage
> GRAVE: error sending Out message
> org.apache.servicemix.jbi.ExchangeTimeoutException: Exchange has timed out: InOut[
>   id: ID:192.168.32.32-11ebbae1faa-4:4
>   status: Error
>   role: provider
>   interface: {http://myproject.com/NDTWS/}TargetWSImpl
>   service: {http://myproject.com/NDTWS/}TargetWSImplService
>   endpoint: TargetWSImplPort
>   operation: {http://myproject.com/NDTWS/}doLogin
>   in: "aResponse"]
>
>
>
>
>
>
>
>