Skip to content

Conversation

@artembilan
Copy link
Member

JIRA: https://jira.spring.io/browse/INT-2426

DO NOT MERGE YET

It's just an initial commit, like a PoC to review before further work.

@artembilan
Copy link
Member Author

Pushed the fix according to Travis complaint

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what you are doing here but when skipDuplicate is false this is really a transformer not a filter.

It makes me feel a bit queasy.

Maybe we can work around it with the namespace ?

<int:idempotent-consumer filter="true|false" />

rather than <idempotent-filter/> as mentioned in the JIRA.

@artembilan
Copy link
Member Author

Thanks for feedback. You confirmed my concerns.
Let me rework it to more appropriate solution.

@garyrussell
Copy link
Contributor

Actually, do we really need to use an MGS at all? We don't really need to store the whole message, just the key.

@artembilan
Copy link
Member Author

Yes, I thought about that too. But it might be really usefull for end application to analize messages in store for cases like Idempotent Receiver.

I'm working now under solution to retrieve message from group by filter...

@garyrussell
Copy link
Contributor

Yes, but remember the MGS has 3 tables; we really only need one table for this use case.

@garyrussell
Copy link
Contributor

Maybe a MetadataStore would be best (and provide a JDBC implementation). I really don't see much benefit in storing the entire message "just in case" someone wants to examine them.

@artembilan
Copy link
Member Author

OK. Let's implement it just with MetadataStore!
MGS option we can add on demand.

@artembilan
Copy link
Member Author

Pushed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a ConcurrentMetadataStore to support concurrency and clustered environments. Use putIfAbsent() for atomicity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.
Let me know if everything other is Ok and I'll add docs tomorrow

@garyrussell
Copy link
Contributor

All ok; except my previous comment about it not really being a filter when skipDuplicate is false.

@artembilan
Copy link
Member Author

except my previous comment about it not really being a filter when skipDuplicate is false.

Yes, as you see I renamed that option to the filter = true/false.
And right, in the Namespace it will be <idempotent-filter>.

@artembilan
Copy link
Member Author

<idempotent-receiver>.

@garyrussell
Copy link
Contributor

Perhaps it should be an advice rather than a discrete component.

Design a receiver to be an Idempotent Receiver--one that can safely receive the same message multiple times.

<request-handler-advice-chain>
    <idempotent-receiver filter="true/false" discard-channel="foo" />
</requestHandler-advice-chain>

Since we're adding behavior to an endpoint rather than defining a receiver as a component.

@artembilan
Copy link
Member Author

Hey! That's cool!
Having it is Advice we can come back to the selector as an alternative to the indempotent-key.
It allows end-user to have any custom filtering strategy and get gain from DUPLICATE header.

Thanks. Will do tomorrow!

JIRA: https://jira.spring.io/browse/INT-2426

Conflicts:
	spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java
* Move `Idempotent Filtering` logic to the `IdempotentReceiverInterceptor`, which should be applied as a regular
AOP `Advice` to the `MessageHandler#handleMessage`
* Provide an xml component `<idempotent-receiver>`
* Introduce `IdempotentReceiverAutoProxyCreator` to get deal with `IdempotentReceiverInterceptor` and `MessageHandler`s.
The `Proxying` logic is based on the mapping between interceptor and `consumer endpoint` `ids`
* Introduce `MetadataStoreSelector` along side with `MetadataKeyStrategy` and `ExpressionMetadataKeyStrategy` implementation
@artembilan
Copy link
Member Author

Pushed. See commit comments.
@snicoll, take a look, please, to the IdempotentReceiverAutoProxyCreator.
Is that a correct implementation to apply Advices beans to other beans?

Thank you help anyway!

@artembilan
Copy link
Member Author

The annotation support will be soon

Add `IdempotentReceiverIntegrationTests` in the JMX module to be sure that all proxying works well.
@artembilan
Copy link
Member Author

Pushed @IdempotentReceiver support.
There is still needed somehow to overcome this case:

@MessageEndpoint
class MyService {

    @ServiceActivator(inputChannel="testChannel")
    public Object service(Object payload) {
         ....
   }

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interceptor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also document that, if not set, the message will proceed with the duplicate message header.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I did in the class level JavaDocs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I see your point: copy/paste artefact 😄

* Rename `IdempotentReceiverAutoProxyCreatorInitializer`
* Add support for several `IRI` for the one `MH`
* Polishing JavaDocs
@artembilan
Copy link
Member Author

Pushed.
Since we can support several <idempotent-receiver> for one endpoint, I've changed @IdempotentReceiver to support several interceptors as well.

@artembilan
Copy link
Member Author

Pushed Docs

@garyrussell
Copy link
Contributor

Ready to merge after you review my doc polishing: garyrussell@6bff6b9

@garyrussell
Copy link
Contributor

More polish: garyrussell@48d4fe5

@garyrussell
Copy link
Contributor

Merged as ff2b15e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants