You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mamouros <cs...@yahoo.gr> on 2013/09/11 12:42:24 UTC

How and where should I use doneUoW() for a consumer template?

I am using a consumer Template to get an exchange and then pass it on to a
producer Template.
As I saw from the docs for receive() "Important: See doneUoW(Exchange)" I
went and checked doneUoW().
Haven't though fully understand yet if I should call
consumer.doneUoW(exchange); and where? Will it be after line 1, 3 or 4?
Should I call it after line 6 too?
Do I need to call consumer.stop() at any point?


1  exchange = consumer.receive("smpp://" + username + "@" + destination +
":" + port + "?password=" + password , timeoutInMillis);
2  if(exchange != null) {
3      exchange = producer.send("bean:SmsReceiver?method=retrievePdus" ,
exchange);
4      producer.send("sql:update sms set status=:#sms_status,
sent=:#CamelSmppDoneDate, error_code=:#CamelSmppError where
sent_id=:#CamelSmppId?dataSource=dataSource" , exchange);
5  } else {
6      System.out.println("nullExchange");
7  }



--
View this message in context: http://camel.465427.n5.nabble.com/How-and-where-should-I-use-doneUoW-for-a-consumer-template-tp5739119.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How and where should I use doneUoW() for a consumer template?

Posted by mamouros <cs...@yahoo.gr>.
How about consumer.stop() and producer.stop(). Should I use them as
recommended and when, because I get the:

org.apache.camel.FailedToCreateProducerException: Failed to create Producer
for endpoint: Endpoint[smpp://........................
...
Caused by: java.io.IOException: Receive negative bind response: Negative
response 00000005 found

from SMPP Error Code Reference:
ESME_RALYBND   5   ESME already in bound state (example: sending a second
bind command during an existing SMPP session)

meaning that it tries to bind again running
consumer.receive("smpp://.......) but hasn't unbind from the previous bind
the previous consumer.receive("smpp://.......).
Does .stop() invokes void doStop() that invokes void closeSession() that
should do the unbinding?



--
View this message in context: http://camel.465427.n5.nabble.com/How-and-where-should-I-use-doneUoW-for-a-consumer-template-tp5739119p5739152.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How and where should I use doneUoW() for a consumer template?

Posted by Claus Ibsen <cl...@gmail.com>.
Yeah just done it when you no longer use it, eg after the producer, eg
after 4.

On Wed, Sep 11, 2013 at 12:42 PM, mamouros <cs...@yahoo.gr> wrote:
> I am using a consumer Template to get an exchange and then pass it on to a
> producer Template.
> As I saw from the docs for receive() "Important: See doneUoW(Exchange)" I
> went and checked doneUoW().
> Haven't though fully understand yet if I should call
> consumer.doneUoW(exchange); and where? Will it be after line 1, 3 or 4?
> Should I call it after line 6 too?
> Do I need to call consumer.stop() at any point?
>
>
> 1  exchange = consumer.receive("smpp://" + username + "@" + destination +
> ":" + port + "?password=" + password , timeoutInMillis);
> 2  if(exchange != null) {
> 3      exchange = producer.send("bean:SmsReceiver?method=retrievePdus" ,
> exchange);
> 4      producer.send("sql:update sms set status=:#sms_status,
> sent=:#CamelSmppDoneDate, error_code=:#CamelSmppError where
> sent_id=:#CamelSmppId?dataSource=dataSource" , exchange);
> 5  } else {
> 6      System.out.println("nullExchange");
> 7  }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-and-where-should-I-use-doneUoW-for-a-consumer-template-tp5739119.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen