commercetools / commercetools-sdk-java-v2

The e-commerce SDK from commercetools for Java.
https://commercetools.github.io/commercetools-sdk-java-v2/javadoc/index.html
Apache License 2.0
34 stars 15 forks source link

MessageDeliveryPayload missing message content #516

Closed rochadio closed 10 months ago

rochadio commented 10 months ago

I'm trying to use MessageDeliveryPayload class as substitute of the "v1" MessageSubscriptionPayload class, but I'm having issues when trying to access the type of the message, or its content, as it doesn't have a "getMessage", or a "getType", as in the v1 class, and the notificationType of the message will always be "Message"..

So, e.g., im not really able to catch/listen for events that are of 'OrderStateTransition' type, and what content/state is sent in it.

Is it possible that we have the "getMessage" added to MessageDeliveryPayload interface also?

v1 MessageSubscriptionPayload getMessage: https://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/subscriptions/MessageSubscriptionPayload.html#getMessage--

v2 MessageDeliveryPayload : https://commercetools.github.io/commercetools-sdk-java-v2/javadoc/com/commercetools/api/models/subscription/MessageDeliveryPayload.html#MESSAGE

I've also tried to use the generic Message class, that I can catch and then convert into the desired OrderStateTransitionMessage class and get its content, but however is not possible to retrieve the projectKey from it..

Should it also be accessible in this Message type? Or is there any other way to do this?

Thanks!

jenschude commented 10 months ago

I released 17.2.0 today.

This includes helper methods comparable to v1 for the MessageDeliveryPayload class. See details in the test class:

https://github.com/commercetools/commercetools-sdk-java-v2/blob/072bc6034895c7779de18d1f6f257ba7c2908787/commercetools/commercetools-sdk-java-api/src/test/java/com/commercetools/MessagePayloadTest.java#L30-L59