Este contenido no está disponible en el idioma seleccionado.

7.4. Decode the Payload


Procedure 7.1. Task

  1. The process method is only the start. Now we must provide methods to decode the incoming Message payload (the Body):
    		  public void reserveSeat (Message message) throws Exception
    {
    	String seatNumber = message.getBody().get(“org.example.flight.seatnumber”);
    	String flight = 
            message.getBody().get(“org.example.flight.flightnumber”);
    	
    	boolean success = 
            airlineReservationSystem.reserveSeat(seatNumber, flight);
    	
    	// now create a response Message
    	Message responseMessage = ...
    	
    	responseMessage.getHeader().getCall().setTo(
            message.getHeader().getCall().getReplyTo()
        );
        
    	responseMessage.getHeader().getCall().setRelatesTo(
            message.getHeader().getCall().getMessageID()
        );
    	
    	// now deliver the response Message
    }
    Copy to Clipboard Toggle word wrap
    This code illustrates how the information within the body is extracted and then used to invoke a method on some business logic. In the case of reserveSeat, a response is expected by the client. This response message is constructed using any information returned by the business logic as well as delivery information obtained from the original received message. In this example, we need the To address for the response, which we take from the ReplyTo field of the incoming message. We also need to relate the response with the original request and we accomplish this through the RelatesTo field of the response and the MessageID of the request.
  2. Code every operation supported by the service similarly.

Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat