You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by pratibhaG <pr...@in2m.com> on 2008/07/02 09:39:58 UTC

How to get original sevice name in dead letter channel?

I have following configuration:

exception(java.net.ConnectException.class)
    
.maximumRedeliveries(3).useExponentialBackOff().initialRedeliveryDelay(60000).backOffMultiplier(2.0)
    
.to("jbi:service:http://servicemix.in2m.com/samples/http/bean1Service?mep=in-out")
    
.to("jbi:service:service:http://servicemix.in2m.com/samples/http/errorHandler");

from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
	   
.to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out");

Here everything works fine. The flow is like this:
1)take a message from jmsconsumer.
2)give the mesage to myproviderservice.
3)If myproviderservice is DOWN, the message is retried for 3 times and then
sent to bean1service.

Now in bean1service I want to get the name of the service where the message
was suppossed to send ( the name of the service for which I got connection
refused error). How can I get this information? I tried to use
getServiceEndPoint() method but it returns me bean1Service. How can I get
MyProviderService ?

Please help.

Pratibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18231948.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
I tried this:
from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
        .intercept(new DelegateProcessor() {
                      public void process(Exchange exchange) {
                          try {
                        	  proceed(exchange);                        	  
                        	 
System.out.println("******************processor*****"+getProcessor());
                        	  
                          } catch (Exception e) {
  							e.printStackTrace();
  						  }
                      };
                 
}).to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out")
                 
.to("jbi:service:http://servicemix.in2m.com/samples/http/bean5Service?mep=in-out");
                  

inside process method it gave me following:

******************processor*****Pipeline[sendTo(Endpoint[service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out]),
sendTo(Endpoint[service:http://servicemix.in2m.com/samples/http/bean5Service?mep=in-out])]

Now suppose while sending  a message from consumer1 to MyProviderService bus
finds that MyProviderService is down. Then I want that I should get a
request message as well as servicenmae which is down in this case
MyProviderService.
How can I get it?
Please help. I am stuck.

Prtaibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18359578.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
It gives me the same that is 
{http://servicemix.in2m.com/samples/http}jmsConsumer1
 how can i get the other one?

pratibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18354227.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Guillaume Nodet <gn...@gmail.com>.
Have you tried retrieving the target endpoint ?
   me.getEndpoint().getServiceName()

On Tue, Jul 8, 2008 at 3:25 PM, pratibhaG <pr...@in2m.com> wrote:
>
> I did this:
> JbiExchange jbiexchange = (JbiExchange) exchange;
> MessageExchange me = jbiexchange.getMessageExchange();
> System.out.println("*************"+me.getProperty("org.apache.servicemix.senderEndpoint")+"****************");
>
> And I get the senderendPoint as
> {http://servicemix.in2m.com/samples/http}jmsConsumer1:consumer1
>
> But i want to get this:
> http://servicemix.in2m.com/samples/http/MyProviderService
> that is from where I am getting the response. In my process method I am
> gettting the out message but I am not able to understand which service has
> sent it.
> How can i get it.
>
> Pratibha
>
> --
> View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18339179.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
I did this:
JbiExchange jbiexchange = (JbiExchange) exchange;
MessageExchange me = jbiexchange.getMessageExchange();                         	                       	 
System.out.println("*************"+me.getProperty("org.apache.servicemix.senderEndpoint")+"****************");

And I get the senderendPoint as 
{http://servicemix.in2m.com/samples/http}jmsConsumer1:consumer1

But i want to get this:
http://servicemix.in2m.com/samples/http/MyProviderService
that is from where I am getting the response. In my process method I am
gettting the out message but I am not able to understand which service has
sent it. 
How can i get it.

Pratibha

-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18339179.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Gert Vanthienen <ge...@skynet.be>.
Pratibha,

You should cast the exchange to JbiExchange before you can access the 
getMessageExchange() method
 JbiExchange jbiexchange = (JbiExchange) exchange;
 MessageExchange me = jbiexchange.getMessageExchange();
 
Gert

pratibhaG wrote:
> The class of the exchange is org.apache.servicemix.camel.JbiExchange
> but if I do this 
> exchange.getMessageExchange(); 
>
> it gives me compile time error saying method is undefined.
>
> Am i doing something wrong?
>
> Pratibha
>   


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
The class of the exchange is org.apache.servicemix.camel.JbiExchange
but if I do this 
exchange.getMessageExchange(); 

it gives me compile time error saying method is undefined.

Am i doing something wrong?

Pratibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18337854.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Gert Vanthienen <ge...@skynet.be>.
Prathiba,

What is the type of the exchange variable in your DelegateProcessor 
then?  Could you do a System.out.println(exchange.getClass()); to check 
this in your process() method?

Regards,

Gert

pratibhaG wrote:
> I am still not able to get JBIExchange instance inside Camel. Please help me
> to get it so that I can use the information which I know
> I have following information.
> 1)From message MessageExchange instance I can get serviceName using method
> getService()
> 2)As you said I can get MessageExchange instance using
> JBIExchange.getMessageExchange() 
>
> I don't know how to get JBIExchange so that I can call getMessageExchange()
> on it. 
>
> please help.
>
> Pratibha
>   


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
I am still not able to get JBIExchange instance inside Camel. Please help me
to get it so that I can use the information which I know
I have following information.
1)From message MessageExchange instance I can get serviceName using method
getService()
2)As you said I can get MessageExchange instance using
JBIExchange.getMessageExchange() 

I don't know how to get JBIExchange so that I can call getMessageExchange()
on it. 

please help.

Pratibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18337465.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Gert Vanthienen <ge...@skynet.be>.
Prathiba,

At this point, in your interceptor, you're still working with a 
JBIExchange implementation for Exchange, which has the 
JBIExchange.getMessageExchange() method to access the underlying JBI 
Message exchange.  The JBI Message exchange will have the ServiceMix JBI 
property I mentioned before, so you can copy that to your message.  I 
would also suggest you copy it to the Camel Message instead of the 
Exchange (use exchange.getIn().setHeader() instead of 
exchange.setProperty()).

Regards,

Gert

pratibhaG wrote:
> I tried as per your suggestion like this:
>
> from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
>         .intercept(new DelegateProcessor() {
>                       public void process(Exchange exchange) {
>                           try {
>                         	  proceed(exchange);
>                         	 
> exchange.setProperty("serviceName","http://servicemix.in2m.com/samples/http/MyProviderService");
>                         	  ErrorEnrich.sendErrorToErrorHandler(exchange);
>                           } catch (Exception e) {
>   							e.printStackTrace();
>   						  }
>                       };
>                  
> }).to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out");
>                  
> But here I am manually setting the serviceName as the jbi service. i dont
> want this. 
>
> suppose I want to send the message to two sevices like this:
>
> from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
>         .intercept(new DelegateProcessor() {
>                       public void process(Exchange exchange) {
>                           try {
>                         	  proceed(exchange);
>                         	  ErrorEnrich.sendErrorToErrorHandler(exchange);
>                           } catch (Exception e) {
>   							e.printStackTrace();
>   						  }
>                       };
>                  
> }).to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService1?mep=in-out")
>                 
> .to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService2?mep=in-out");
>
> Then how can get the name of the sevice which causes error?Please help.
>
> Pratibha
>
>   


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
I tried as per your suggestion like this:

from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
        .intercept(new DelegateProcessor() {
                      public void process(Exchange exchange) {
                          try {
                        	  proceed(exchange);
                        	 
exchange.setProperty("serviceName","http://servicemix.in2m.com/samples/http/MyProviderService");
                        	  ErrorEnrich.sendErrorToErrorHandler(exchange);
                          } catch (Exception e) {
  							e.printStackTrace();
  						  }
                      };
                 
}).to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out");
                 
But here I am manually setting the serviceName as the jbi service. i dont
want this. 

suppose I want to send the message to two sevices like this:

from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
        .intercept(new DelegateProcessor() {
                      public void process(Exchange exchange) {
                          try {
                        	  proceed(exchange);
                        	  ErrorEnrich.sendErrorToErrorHandler(exchange);
                          } catch (Exception e) {
  							e.printStackTrace();
  						  }
                      };
                 
}).to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService1?mep=in-out")
                
.to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService2?mep=in-out");

Then how can get the name of the sevice which causes error?Please help.

Pratibha

-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18337002.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Gert Vanthienen <ge...@skynet.be>.
Pratibha,

The only thing I can think off right now is adding an 
interceptor/processor early on in the actual route that copies the 
information to the Camel message header instead of keeping it on the JBI 
MessageExchange

Gert

pratibhaG wrote:
> Is there a way to get JBIExchange instance inside Camel. 
> I tried this:
> exception(java.net.ConnectException.class)
>     
> .maximumRedeliveries(2).useExponentialBackOff().initialRedeliveryDelay(30000).backOffMultiplier(2.0)
>     	.process( new Processor() {
>     		public void process(Exchange exchange) {
>     			System.out.println("****************** exchange"+exchange);
>     			
>     		}
>     	}
>     	)
>     
> .to("jbi:service:http://servicemix.in2m.com/samples/http/bean1Service?mep=in-out")
>     
> .to("jbi:service:service:http://servicemix.in2m.com/samples/http/errorHandler");
>     	
> from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
> 	   
> .to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out");
>
> The print statement prints this:
> ****************** exchangeExchange[JbiMessage:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@62221d{properties:
> {org.apache.camel.Redelivered=true, org.apache.camel.RedeliveryCounter=2}}]
>
> How can I get the required information now? Please help. I am stuck
>
> pratibha 
>   


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
Is there a way to get JBIExchange instance inside Camel. 
I tried this:
exception(java.net.ConnectException.class)
    
.maximumRedeliveries(2).useExponentialBackOff().initialRedeliveryDelay(30000).backOffMultiplier(2.0)
    	.process( new Processor() {
    		public void process(Exchange exchange) {
    			System.out.println("****************** exchange"+exchange);
    			
    		}
    	}
    	)
    
.to("jbi:service:http://servicemix.in2m.com/samples/http/bean1Service?mep=in-out")
    
.to("jbi:service:service:http://servicemix.in2m.com/samples/http/errorHandler");
    	
from("jbi:service:http://servicemix.in2m.com/samples/http/jmsConsumer1")
	   
.to("jbi:service:http://servicemix.in2m.com/samples/http/MyProviderService?mep=in-out");

The print statement prints this:
****************** exchangeExchange[JbiMessage:
org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@62221d{properties:
{org.apache.camel.Redelivered=true, org.apache.camel.RedeliveryCounter=2}}]

How can I get the required information now? Please help. I am stuck

pratibha 
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18275668.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to get original sevice name in dead letter channel?

Posted by Gert Vanthienen <ge...@skynet.be>.
Pratibha,

In ServiceMix, this information is available as a property named 
'org.apache.servicemix.senderEndpoint' (cfr. 
org.apache.servicemix.JbiConstants.SENDER_ENDPOINT).  However, once 
you're in Camel, the information can not be accessed through the Camel 
Exchange directly.  If you have a JBIExchange instance inside Camel, you 
can use JBIExchange.getMessageExchange() to get to the underlying JBI 
MessageExchange to get to the information you want.

Regards,

Gert

pratibhaG wrote:
> Is it possible to get this information or not possible?
>
> Please help.
> Pratibha
>   


Re: How to get original sevice name in dead letter channel?

Posted by pratibhaG <pr...@in2m.com>.
Is it possible to get this information or not possible?

Please help.
Pratibha
-- 
View this message in context: http://www.nabble.com/How-to-get-original-sevice-name-in-dead-letter-channel--tp18231948p18256739.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.