Repository: quarkusio/quarkus
Issue: Consuming multiple media types from a resource method does not work

### Describe the bug

Consuming multiple media types from a JAX-RS resource method does not work with RR:

```
@Path("postMultiMediaTypeConsumer")
    @Consumes({"application/soap+xml", MediaType.TEXT_XML})
    @POST
    public Response postMultiMediaTypeConsumer() throws Exception {
        return Response.ok().build();
    }
```

The reason why it does not work is that [MediaTypeMapper](https://github.com/quarkusio/quarkus/blob/main/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java#L38) is only resolving the first media type from the resource method.

### Expected behavior

Resolve a JAX-RS method when multiple consume media types are set.

### Actual behavior

RR fails to resolve multiple consume media types and only resolves the first one.

### How to Reproduce?

```
@Path("postMultiMediaTypeConsumer")
    @Consumes({"application/soap+xml", MediaType.TEXT_XML})
    @POST
    public Response postMultiMediaTypeConsumer() throws Exception {
        return Response.ok().build();
    }
```

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java
independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java
independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java

diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java
index 480d342920c..383b95b3931 100644
--- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java
+++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java
@@ -28,6 +28,9 @@
  */
 public class MediaTypeMapper implements ServerRestHandler {
 
+    private static final MediaType[] DEFAULT_MEDIA_TYPES = new MediaType[] { MediaType.WILDCARD_TYPE };
+    private static final List<MediaType> DEFAULT_MEDIA_TYPES_LIST = List.of(DEFAULT_MEDIA_TYPES);
+
     final Map<MediaType, Holder> resourcesByConsumes;
     final List<MediaType> consumesTypes;
 
@@ -35,20 +38,17 @@ public MediaTypeMapper(List<RuntimeResource> runtimeResources) {
         resourcesByConsumes = new HashMap<>();
         consumesTypes = new ArrayList<>();
         for (RuntimeResource runtimeResource : runtimeResources) {
-            MediaType consumesMT = runtimeResource.getConsumes().isEmpty() ? MediaType.WILDCARD_TYPE
-                    : runtimeResource.getConsumes().get(0);
-            if (!resourcesByConsumes.containsKey(consumesMT)) {
-                consumesTypes.add(consumesMT);
-                resourcesByConsumes.put(consumesMT, new Holder());
-            }
-            MediaType[] produces = runtimeResource.getProduces() != null
-                    ? runtimeResource.getProduces().getSortedOriginalMediaTypes()
-                    : null;
-            if (produces == null) {
-                produces = new MediaType[] { MediaType.WILDCARD_TYPE };
+            List<MediaType> consumesMediaTypes = getConsumesMediaTypes(runtimeResource);
+            for (MediaType consumedMediaType : consumesMediaTypes) {
+                if (!resourcesByConsumes.containsKey(consumedMediaType)) {
+                    consumesTypes.add(consumedMediaType);
+                    resourcesByConsumes.put(consumedMediaType, new Holder());
+                }
             }
-            for (MediaType producesMT : produces) {
-                resourcesByConsumes.get(consumesMT).setResource(runtimeResource, producesMT);
+            for (MediaType producesMT : getProducesMediaTypes(runtimeResource)) {
+                for (MediaType consumedMediaType : consumesMediaTypes) {
+                    resourcesByConsumes.get(consumedMediaType).setResource(runtimeResource, producesMT);
+                }
             }
         }
         for (Holder holder : resourcesByConsumes.values()) {
@@ -116,6 +116,17 @@ public MediaType selectMediaType(ResteasyReactiveRequestContext requestContext,
         return selected;
     }
 
+    private MediaType[] getProducesMediaTypes(RuntimeResource runtimeResource) {
+        return runtimeResource.getProduces() == null
+                ? DEFAULT_MEDIA_TYPES
+                : runtimeResource.getProduces().getSortedOriginalMediaTypes();
+    }
+
+    private List<MediaType> getConsumesMediaTypes(RuntimeResource runtimeResource) {
+        return runtimeResource.getConsumes().isEmpty() ? DEFAULT_MEDIA_TYPES_LIST
+                : runtimeResource.getConsumes();
+    }
+
     private static final class Holder {
 
         private final Map<MediaType, RuntimeResource> mtWithoutParamsToResource = new HashMap<>();
diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java
index 0dcc8430247..f930b447f4c 100644
--- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java
+++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java
@@ -216,4 +216,28 @@ public void postInteger() throws Exception {
         String responseContent = response.readEntity(String.class);
         LOG.debug(String.format("Response: %s", responseContent));
     }
+
+    @Test
+    @DisplayName("Post Multi Media Type Consumer")
+    public void testConsumesMultiMediaType() {
+        WebTarget target = client.target(generateURL("/postMultiMediaTypeConsumer"));
+        Response response = target.request().post(Entity.entity("payload", "application/soap+xml"));
+        Assertions.assertEquals(Response.Status.OK.getStatusCode(),
+                response.getStatus());
+        Assertions.assertEquals("postMultiMediaTypeConsumer", response.readEntity(String.class));
+
+        response = target.request().post(Entity.entity("payload", MediaType.TEXT_XML));
+        Assertions.assertEquals(Response.Status.OK.getStatusCode(),
+                response.getStatus());
+        Assertions.assertEquals("postMultiMediaTypeConsumer", response.readEntity(String.class));
+
+        response = target.request().post(Entity.entity("payload", "any/media-type"));
+        Assertions.assertEquals(Response.Status.OK.getStatusCode(),
+                response.getStatus());
+        Assertions.assertEquals("any/media-type", response.readEntity(String.class));
+
+        response = target.request().post(Entity.entity("payload", "unexpected/media-type"));
+        Assertions.assertEquals(Response.Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode(),
+                response.getStatus());
+    }
 }
diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java
index 993cb9f9a6e..ba8f67206e0 100644
--- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java
+++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java
@@ -3,9 +3,11 @@
 import java.util.Date;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.HeaderParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
@@ -75,4 +77,18 @@ public Response postIntegerProduce(String source) throws Exception {
     public Response postInteger(String source) throws Exception {
         return Response.ok().entity(5).build();
     }
+
+    @Path("postMultiMediaTypeConsumer")
+    @Consumes({ "application/soap+xml", MediaType.TEXT_XML })
+    @POST
+    public Response postMultiMediaTypeConsumer() {
+        return Response.ok("postMultiMediaTypeConsumer").build();
+    }
+
+    @Path("postMultiMediaTypeConsumer")
+    @Consumes({ "any/media-type" })
+    @POST
+    public Response postMultiMediaTypeConsumerAnyContentType(@HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType) {
+        return Response.ok(contentType).build();
+    }
 }