2
votes

The scenario is inbound jms adapter -> service activators (db search, business logic, inserts or updates)

<int-jms:message-driven-channel-adapter id="swiftAdapterInput" channel="mt950"
        connection-factory="connectionFactory" destination-name="${integration.swift.jms.queue.from}" pub-sub-domain="false"
        auto-startup="false" error-channel="errorChannel" transaction-manager="transactionManager" acknowledge="transacted" />

<int:service-activator input-channel="errorChannel" ref="errorHandler" />

<bean id="errorHandler" class="nest.integration.utils.error.ErrorHandler" />


<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

When the exception was thrown during my servcie activators my errorHandler works fine but the exception was at the end(after commit), for example db unique constrat exception the message does not go to error-channel but rollbacked to jms queue only.

But I need my errorHander in this case also because I need to send email exception etc.

Tanks at advance Best wishes, Tamas

1
What is the Exception you get? - msrd0
Please turn on DEBUG for the org.springframework.integration category and show here logs on the matter - Artem Bilan
The debug was active. No debug message about error-channel. - ltom74
WARN MessageListenerContainer#1-7 org.springframework.jms.listener.DefaultMessageListenerContainer Setup of JMS message listener invoker failed for destination 'Consumer.Lime.VirtualTopic.SWIFT.Interface.Test1' - trying to recover. Cause: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: ORA-00001: a(z) (NEST.LIME_MT950_DETAIL_PK) egyediségre vonatkozó megszorítás nem tel - ltom74
The exception is ok pk unique constarit, but I want to handle this in errorHandler to send a email etc. - ltom74

1 Answers

0
votes

I think your issue that you must rallback TX in your errorHandler, but don't commit.

That's why you get egyediségre vonatkozó megszorítás nem tel from DefaultMessageListenerContainer, because that DB error is caused on commit.

See here: Exceptions in Spring Integration: How to log but not intercept