you may want to rollback immediately after the log messages  in the catch
block and not at the end.

On Tue, Sep 9, 2014 at 7:51 AM, Ahmed Vila <[email protected]> wrote:

> Hi Group,
>
> We've implemented custom Flume Sink.
> We do some DB lookups for sanity checks within it and bunch of stuff in
> order to slightly prepare data for insertion into the postgresql via copy
> command.
>
> It gets the channel, transaction and it executes begin() method.
> Of course, there is try-catch-finally block wrapper that ensures commit or
> rollback methods are called and finally transaction is closed.
>
> Sometimes it happens that there is an exception due to transaction.begin
> called before transaction.commit or rollback.
>
> I don't see it possible unless there are two threads take the same
> transaction.
>
> Another possible reason might be short code in the catch block that could
> prevent call to the transaction.rollback and transaction.close.
> However, it doesn't throw an exception within catch block as it would
> emerge in logs.
>
>
>
> This is relevant part of the code:
> @Override
> public Status process() throws EventDeliveryException {
> Channel channel = getChannel();
> Transaction transaction = channel.getTransaction();
> ...
> try {
> transaction.begin();
> event = channel.take();
> ...
> transaction.commit();
> } catch (Exception ex) {
> LOG.error("Problem with sink", ex);
> LOG.error("Exception: " + ex.toString());
>
> LOG.info("Start source...");
> this.cacheDBPool.clear();
> CommandExecutor.execUnStopCmd(this.flumeFolderLogs);
>
> transaction.rollback();
> } finally {
> transaction.close();
> }
>
> return result;
> }// end method
>
>
>
> Thanks in advance
>
>
> --
>
> Best regards,
> Ahmed Vila
>
> ---------------------------------------------------------------------
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. This email contains confidential information. It should
> not be copied, disclosed to, retained or used by, any party other than the
> intended recipient. Any unauthorised distribution, dissemination or copying
> of this E-mail or its attachments, and/or any use of any information
> contained in them, is strictly prohibited and may be illegal. If you are
> not an intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender directly via email. Any
> emails that you send to us may be monitored by systems or persons other
> than the named communicant for the purposes of ascertaining whether the
> communication complies with the law and company policies.

-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.

Reply via email to