Skip to content

SpringWolf UI send the payloadType with the name of the message when the payload is a String and produce a 400 BadRequest #752

@pcomp96

Description

@pcomp96

Describe the bug

I'm using spring integration with some jms adapter, I created the specification on my listener like in the code example.
When i try to publish a message from the SpringWolf UI , the client send this request body:

{
   "payload":"\"string\"",
   "payloadType":"XDataMessagePayload",
   "headers":{
      "x1":"xValue",
      "x2":"xValue"
   }

The payloadType is filled with the attribute name = "XDataMessagePayload" and not with the attribute payloadType = String.class setted in the annoation.
This produce a 400 BadRequest and a pubilsh failed error in the UI.


Dependencies and versions used
springboot version 3.2.3
springwolf-ui version 1.2.0
springwolf-core version 1.2.0
springwolf-jms version 1.2.0


Code example

Note: If I omit the attribute name="XDataMessagePayload" and have multiple messages with the same payloadType (String.class), in the UI the labels all appear the same as the last processed message.. 👎🏻

    @AsyncListener(
            operation = @AsyncOperation(
                    channelName = "queue-x-to-y-data",
                    description = "X send the data to Y over this channel", 
                    payloadType = String.class,
                    message = @AsyncMessage(
                            name = "XDataMessagePayload",
                            messageId = "XDataMessage",
                            description = "Example payload message that X send to Y",
                            title = "X Data to Y Message"
                    ),
                    headers = @Headers(
                            schemaName = "XToYDataHeaders",
                            values = {
                                    @Header(name = "header1", value = "X1", description = "X1 value"),
                                    @Header(name = "header2", value = "X2", description = "X2 value")
                            }
                    )
            ))
    @JmsAsyncOperationBinding
    public IntegrationFlow xDataToYListener(....){
              //Flow logic
             }

    @AsyncListener(
            operation = @AsyncOperation(
                    channelName = "queue-z-to-y-data",
                    description = "Z send the data to Y over this channel", 
                    payloadType = String.class,
                    message = @AsyncMessage(
                            name = "ZDataMessagePayload",
                            messageId = "ZDataMessage",
                            description = "Example payload message that Z send to Y",
                            title = "Z Data to Y Message"
                    ),
                    headers = @Headers(
                            schemaName = "ZToYDataHeaders",
                            values = {
                                    @Header(name = "header1", value = "Z1", description = "Z1 value"),
                                    @Header(name = "header2", value = "Z2", description = "Z2 value")
                            }
                    )
            ))
    @JmsAsyncOperationBinding
    public IntegrationFlow zDataToYListener(....){
              //Flow logic
             }

Stack trace and error logs

On the chrome console side :

Publishing to /springwolf/jms/publish with messageBinding {} and headers {"x1":"2021-07-01T00:00:00Z","x2":"24324234234"}: {"payload":"\"string\"","payloadType":"XDataMessagePayload ","headers":{"x1":"xValue","x2":"xValue"},"bindings":{}}
 
        POST http://localhost:8080/springwolf/jms/publish?topic=queue-x-to-y-data 400 (Bad Request)

On the backend side with the debug log enabled

INFO 20528 --- [nio-8080-exec-4] i.g.s.c.c.PublishingPayloadCreator       : Specified payloadType XDataMessagePayload is not a registered springwolf schema. Known payloadTypes: [XToYDataHeaders,"ZToYDataHeaders",java.lang.String]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions